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
-- Delete the table that has the same name as other tables.
DROP TABLE IF EXISTS test_update_line;
-- Create a test table.
CREATE TABLE test_update_line(id int primary key, geom geometry(LineString, 4326));
-- Insert data into the test table.
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 an index for the geom column.
CREATE INDEX ON test_update_line using gist(geom);
-- Create a vector pyramid to accelerate the display of data. In addition, if the Raster extension is installed, you must add ::cstring to each parameter to avoid conflicts.
SELECT ST_BuildPyramid('test_update_line', 'geom', 'id', '{"parallel":16}');
-- Insert test data.
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;
-- Update partial data of the vector pyramid.
SELECT ST_UpdatePyramid('test_update_line', 'geom', 'id', Box2D(ST_GeomFromText('LINESTRING(-20 -20, 20 20)')), '{"updateBoxScale":10}';