Renders a specific tile of a pyramid as a PNG image.
Syntax
bytea ST_AsPng(cstring name, cstring key, cstring style);
bytea ST_AsPng(cstring name, int x, int y, int z, cstring style);Parameters
| Parameter | Description |
|---|---|
name | The name of the pyramid. |
key | The tile ID in z_x_y format. |
x | The x coordinate of the tile. |
y | The y coordinate of the tile. |
z | The z coordinate of the tile. |
style | The rendering style as a JSON string. If not specified, the default style is used. |
Style fields
| Field | Type | Default | Description |
|---|---|---|---|
background | string | #FFFFFFFF | The RGBA background color. Default: white. |
line_color | string | #000000FF | The RGBA color of dots and edges. Default: black. |
fill_color | string | #F4A460FF | The RGBA fill color of the tile. Default: brown. |
line_width | int | 1 | The line width, in pixels. |
point_size | int | 10 | The size per dot, in pixels. Default: a circle with a 10-pixel diameter. |
parallel_unit | int | 50000 | The number of elements each parallel task renders. |
Example style:
{
"background": "#FFFFFFFF",
"line_color": "#000000FF",
"fill_color": "#F4A460FF",
"line_width": 1,
"point_size": 10
}Usage notes
The tile ID (
key) uses thez_x_yformat and follows theEPSG:4326orEPSG:3857coordinate system.In
EPSG:4326, a tile consists of multiple chunks, and the number of chunks on the x axis is twice the number on the y axis. The z coordinate starts from 1. When z is 1, the only valid tile IDs are1_0_0and1_1_0.The output PNG image size equals the
tileSizevalue specified when the pyramid was built. For details, see ST_BuildPyramid.
Examples
Query by tile ID string:
select ST_AsPng('roads', '3_1_6', '');Output:
st_aspng
----------
0xFFAABB8D8A6678...Query by tile coordinates:
select ST_AsPng('roads', 1, 6, 3, '');Output:
st_aspng
----------
0xFFAABB8D8A6678...该文章对您有帮助吗?