ST_BuildPyramid
Creates a vector pyramid for a spatial geometry table to accelerate data display.
Syntax
boolean ST_BuildPyramid(cstring table, cstring geom, cstring fid, cstring config)
Parameters
|
Parameter |
Description |
|
table |
The name of the spatial geometry table. |
|
geom |
The name of the geometry field. |
|
fid |
The name of the feature ID field. |
|
config |
The parameters for creating the pyramid, as a JSON string. |
configThe following table describes the parameters.
|
Parameter |
Type |
Default value |
Description |
|
name |
string |
Same as table name |
The name of the pyramid. |
|
parallel |
int |
0 |
The number of parallel build tasks. You must set the max_prepared_transactions parameter. 0 indicates maximum parallelism. |
|
tileSize |
int |
1024 |
The tile size. Must be > 0 and < 4096. |
|
tileExtend |
int |
8 |
The tile padding. Must be > 0. |
|
userExtent |
array[double] |
null |
Custom geographic extent. Set [] with values: minx, miny, maxx, maxy. |
|
splitSize |
int |
10000 |
The maximum number of features that determine index node splitting. A larger value results in a sparser pyramid. |
|
maxLevel |
int |
16 |
Max pyramid level. Valid values: 0-20. |
|
sourceSRS |
int |
-1 |
The coordinate system of the source data. If not set, the SRID of the metadata is read. |
|
destSRS |
int |
3857 |
The EPSG code of the output tile coordinate reference system. Only 3857 and 4326 are supported. |
|
updateExtentSRS |
int |
4326 |
The EPSG format used for the update range of the pyramid update function. For details, see the description of the ST_UpdatePyramid function. |
|
updateBoxScale |
int |
10 |
Affects the precision of the pyramid update operation. For details, see the description of the ST_UpdatePyramid function. |
|
buildRules |
array[object] |
null |
Build rules. Each object contains level and value values. |
|
└level |
array[int] |
null |
Levels to which the rule applies. |
|
└value |
object |
null |
Build rule value. |
|
└filter |
string |
"" |
Filter expression using PostgreSQL query syntax. |
|
└attrFields |
array[string] |
null |
Attribute field names in MVT output. |
|
└merge |
array[string] |
null |
Filter conditions for grouping and merging. |
configExample:
{
"name" : "hello",
"parallel": 4,
"tileSize": 512,
"tileExtend": 8,
"userExtent": [-180,-90,180,90],
"splitSize": 5000,
"maxLevel": 16,
"destSRS": 3857,
"buildRules": [
{
"level": [0,1,2],
"value": {
"filter": "code!=0",
"attrFields": ["name","color"],
"merge":["code=1"]
}
}
]
}
Example
-- Create a vector pyramid for the spatial geometry table roads.
select ST_BuildPyramid('roads', 'geom', 'id', '');
st_buildpyramid
----------
t