對向量金字塔進行局部更新,修改範圍由參數update_extent(Box2D格式)指定。主要用於,當原始向量資料表進行了資料更新(插入、刪除或修改)後,將更新發生的座標系範圍作為參數調用本函數,從而允許使用者看到更新後的可視化結果。
文法
boolean ST_UpdatePyramid(cstring table, cstring geom_field, cstring id_field, BOX2D update_extent, cstring rules) ;參數
| 參數名稱 | 描述 |
| table | 向量資料表的名稱。 |
| geom_field | 向量資料表中Geometry屬性的列名。 |
| id_field | 向量資料表中ID屬性的列名。 |
| update_extent | 需要進行更新的EPSG格式座標地區範圍(Box2D格式),EPSG格式由參數rules指定,預設為4326。 例如:Box2D(ST_GeomFromText('LINESTRING(-120 -80, -100 -50)'))指定 |
| rules | JSON格式的更新參數值,參數包括updateBoxScale和sourceSRS。
說明 updateBoxScale用於控制更新在精度和效率之間的取捨:
|
樣本
DROP TABLE IF EXISTS test_update_line;
CREATE TABLE test_update_line(id int primary key, geom geometry(LineString, 4326));
INSERT INTO test_update_line(id, geom)
SELECT i,
ST_GeomFromText(format('LINESTRING(%s,%s,%s,%s)',
(floor(i/100)*0.01+10), (floor(i%100)*0.01+10),
(floor(i/100+1)*0.01+10), (floor(i%100+1)*0.01+10)), 4326)
FROM generate_series(1, 10000) i;
CREATE INDEX ON test_update_line using gist(geom);
SELECT ST_BuildPyramid('test_update_line', 'geom', 'id', '{"parallel":16}');
st_buildpyramid
-----------------
t
(1 row)
INSERT INTO test_update_line(id, geom)
SELECT i,
ST_GeomFromText(
format('LINESTRING(%s,%s,%s,%s)',
(floor(i/100)*0.01-10), (floor(i%100)*0.01-10),
(floor(i/100+1)*0.01+10), (floor(i%100+1)*0.01+10)),
4326)
FROM generate_series(10001, 15000) i;
SELECT ST_UpdatePyramid('test_update_line', 'geom', 'id', Box2D(ST_GeomFromText('LINESTRING(-20 -20, 20 20)')), '{"updateBoxScale":10}';
st_updatepyramid
-----------------
t
(1 row)