Cette rubrique décrit la fonction ST_UpdatePyramid, qui met à jour certaines pyramides vectorielles. Le paramètre update_extent définit la plage de mise à jour au format Box2D. Appelez cette fonction après avoir modifié la table vectorielle source. Par exemple, en cas d'ajout ou de suppression de données, transmettez la plage de coordonnées concernée au paramètre update_extent pour visualiser le résultat de la mise à jour.
Syntaxe
boolean ST_UpdatePyramid(cstring table, cstring geom_field, cstring id_field, BOX2D update_extent, cstring rules) ;
Paramètres
Paramètre | Description |
table | Nom de la table vectorielle. |
geom_field | Nom de la colonne contenant l'attribut Geometry dans la table vectorielle. |
id_field | Nom de la colonne contenant l'attribut ID dans la table vectorielle. |
update_extent | Plage de coordonnées à mettre à jour, au format Box2D. Le paramètre Par exemple, |
rules | Règles de mise à jour des pyramides vectorielles. Ce paramètre accepte une valeur au format JSON comprenant les champs
Remarque Le champ
|
Exemples
-- 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}';