為一個空間幾何資料表建立向量金字塔,加速資料顯示。
文法
boolean ST_BuildPyramid(cstring table, cstring geom, cstring fid, cstring config)參數
| 參數名稱 | 描述 |
| table | 空間幾何表名。 |
| geom | 幾何欄位名。 |
| fid | 要素識別欄位名。 |
| config | 建立金字塔的參數,JSON格式的字串。 |
config參數說明如下。
| 參數名稱 | 類型 | 預設值 | 說明 |
| name | string | 與table名稱相同 | 金字塔的名稱。 |
| parallel | int | 0 | 並行構建任務數,需要設定max_prepared_transactions參數,0表示並行最大化。 |
| tileSize | int | 1024 | 瓦片大小,取值需大於0且小於4096。 |
| tileExtend | int | 8 | 瓦片的外擴大小,取值需大於0。 |
| userExtent | array[double] | null | 自訂地理輪廓,設定 [], 分別為:minx、miny、maxx、maxy。 |
| splitSize | int | 10000 | 決定索引節點分裂的最大要素數量。數值越大,金字塔越稀疏。 |
| maxLevel | int | 16 | 金字塔的最大層級,取值為0~20。 |
| sourceSRS | int | -1 | 來源資料的座標系。如果不設定,則讀取中繼資料的 SRID。 |
| destSRS | int | 3857 | 輸出瓦片座標系參考編碼(EPSG),僅支援3857和4326兩個值。 |
| updateExtentSRS | int | 4326 | 更新金字塔函數的修改範圍使用的EPSG格式,詳情見ST_UpdatePyramid函數的說明。 |
| updateBoxScale | int | 10 | 影響更新金字塔操作的精度,詳情見ST_UpdatePyramid函數的說明。 |
| buildRules | array[object] | null | 構建規則,每個object中包含level和value兩個值。 |
| └level | array[int] | null | 規則適用的層級數組。 |
| └value | object | null | 構建規則值。 |
| └filter | string | "" | 過濾運算式,PostgreSQL的查詢文法。 |
| └attrFields | array[string] | null | mvt中的屬性欄位名稱。 |
| └merge | array[string] | null | 對資料進行分組合并的過濾條件。 |
config樣本:
{
"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"]
}
}
]
}樣本
--為空白間幾何表roads建立向量金字塔。
select ST_BuildPyramid('roads', 'geom', 'id', '');
st_buildpyramid
----------
t