This topic describes the ST_UpdatePyramid function. This function updates some vector pyramids. The update range is specified by the update_extent parameter. The value of this parameter is labeled by Box2D. You can call this function when the original vector table is modified. For example, if data is added to or deleted from the table, you can call the ST_UpdatePyramid function by passing the update range of the coordinates to the update_extent parameter. This way, you can view the update result.
Syntax
boolean ST_UpdatePyramid(cstring table, cstring geom_field, cstring id_field, BOX2D update_extent, cstring rules) ;
Parameters
Parameter | Description |
---|---|
table | The name of the vector table. |
geom_field | The name of the column that has the Geometry attribute in the vector table. |
id_field | The name of the column that has the ID attribute in the vector table. |
update_extent | The range of the coordinates that you want to update. The range is in the Box2D format.
The coordinates in the EPSG format are specified by the rules parameter. Default value:
4326.
For example, Box2D(ST_GeomFromText('LINESTRING(-120 -80, -100 -50)')) specifies the
update range of |
rules | The rules that are used to update some vector pyramids. The value of this parameter
is in the JSON format and consists of the updateBoxScale and sourceSRS fields.
Note
The UpdateBoxScale field is used to balance the accuracy and efficiency of updates.
|
Examples
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)