ST_Envelope
Définition
ST_Envelope renvoie l'emprise minimale d'un objet géométrie sous forme de polygone.
Cette fonction est conforme à la spécification en matière d'entités simples de l'OGC (Open Geospatial Consortium, Inc.) qui indique que l'objet ST_Envelope renvoie un polygone. Pour fonctionner avec des cas particuliers de géométries ponctuelles ou de lignes horizontales et verticales, la fonction ST_Envelope renvoie un polygone autour de ces formes, avec une faible tolérance d'enveloppe calculée sur la base du facteur d'échelle XY du système de référence spatiale de la géométrie. Cette tolérance est soustraite des coordonnées x et y minimales, et ajoutée aux coordonnées x et y maximales pour renvoyer le polygone autour de ces formes.
Syntaxe
Oracle et PostgreSQL
sde.st_envelope (geometry1 sde.st_geometry)
SQLite
st_envelope (geometry1 geometryblob)
Type de retour
Oracle et PostgreSQL
ST_Geometry
SQLite
Geometryblob
Exemple
La colonne geotype de la table envelope_test stocke le nom de la sous-classe de géométrie stockée dans la colonne g1. Les instructions INSERT ci-dessous insèrent les différentes sous-classes de géométrie dans la table envelope_test.
Ensuite, la fonction ST_Envelope est exécuter pour renvoyer l'enveloppe de polygone entourant chaque géométrie.
Oracle
--Create table and insert values.
CREATE TABLE envelope_test (
geotype varchar(20),
g1 sde.st_geometry
);
INSERT INTO ENVELOPE_TEST VALUES (
'Point',
sde.st_geometry ('point (-1509734.232 -36684.757)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Linestring',
sde.st_geometry ('linestring (-1511144.181 -37680.015, -1509734.232 -38841.149, -1508656.036 -39753.469)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Polygon',
sde.st_geometry ('polygon ((-1506333.768 -36435.943, -1504343.252 -36767.695, -1502684.489 -35357.747, -1506333.768 -36435.943))', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multipoint',
sde.st_geometry ('multipoint (-1493229.539 -40665.789, -1494141.859 -40831.665, -1495800.622 -42739.242)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multilinestring',
sde.st_geometry ('multilinestring ((-1504757.943 -33201.355, -1507411.964 -35606.561), (-1502518.613 -38094.706, -1499781.653 -37099.448, -1498952.272 -34694.241))', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multipolygon',
sde.st_geometry ('multipolygon (((-1492068.405 -47300.841, -1492814.848 -45725.016, -1493975.983 -46471.459,
-1493478.354 -47798.47, -1492068.405 -47300.841), (-1497874.076 -48047.284, -1498537.581 -50618.367, -1497210.571 -50037.8,
-1497874.076 -48047.284)))', 102004)
);
--Return the polygon envelope around each geometry in well-known text.
SELECT geotype geometry_type,
sde.st_astext (sde.st_envelope (g1)) envelope
FROM ENVELOPE_TEST;
GEOMETRY_TYPE ENVELOPE
Point |POLYGON (( -1509734.23220000 -36684.75720000, -1509734.23180000 -36684.75720000,
-1509734.23180000 -36684.75680000, -1509734.23220000 -36684.75680000, -1509734.23220000 -36684.75720000))
Linestring |POLYGON (( -1511144.18100000 -39753.46900000, -1508656.03600000 -39753.46900000,
-1508656.03600000 -37680.01500000, -1511144.18100000 -37680.01500000, -1511144.18100000 -39753.46900000))
Polygon |POLYGON (( -1506333.76800000 -36767.69500000, -1502684.48900000 -36767.69500000,
-1502684.48900000 -35357.74700000, -1506333.76800000 -35357.74700000, -1506333.76800000 -36767.69500000))
Multipoint |POLYGON (( -1495800.62200000 -42739.24200000, -1493229.53900000 -42739.24200000,
-1493229.53900000 -40665.78900000, -1495800.62200000 -40665.78900000, -1495800.62200000 -42739.24200000))
Multilinestring |POLYGON (( -1507411.96400000 -38094.70600000, -1498952.27200000 -38094.70600000,
-1498952.27200000 -33201.35500000, -1507411.96400000 -33201.35500000, -1507411.96400000 -38094.70600000))
Multipolygon |POLYGON (( -1498537.58100000 -50618.36700000, -1492068.40500000 -50618.36700000,
-1492068.40500000 -45725.01600000, -1498537.58100000 -45725.01600000, -1498537.58100000 -50618.36700000))
PostgreSQL
--Create table and insert values.
CREATE TABLE envelope_test (
geotype varchar(20),
g1 sde.st_geometry
);
INSERT INTO ENVELOPE_TEST VALUES (
'Point',
sde.st_geometry ('point (-1509734.232 -36684.757)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Linestring',
sde.st_geometry ('linestring (-1511144.181 -37680.015, -1509734.232 -38841.149, -1508656.036 -39753.469)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Polygon',
sde.st_geometry ('polygon ((-1506333.768 -36435.943, -1504343.252 -36767.695, -1502684.489 -35357.747, -1506333.768 -36435.943))', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multipoint',
sde.st_geometry ('multipoint (-1493229.539 -40665.789, -1494141.859 -40831.665, -1495800.622 -42739.242)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multilinestring',
sde.st_geometry ('multilinestring ((-1504757.943 -33201.355, -1507411.964 -35606.561), (-1502518.613 -38094.706, -1499781.653 -37099.448, -1498952.272 -34694.241))', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multipolygon',
sde.st_geometry ('multipolygon (((-1492068.405 -47300.841, -1492814.848 -45725.016, -1493975.983 -46471.459,
-1493478.354 -47798.47, -1492068.405 -47300.841), (-1497874.076 -48047.284, -1498537.581 -50618.367, -1497210.571 -50037.8,
-1497874.076 -48047.284)))', 102004)
);
--Return the polygon envelope around each geometry in well-known text.
SELECT geotype AS geometry_type,
sde.st_astext (sde.st_envelope (g1)) AS Envelope
FROM envelope_test;
geometry_type envelope
"Point" |"POLYGON (( -1509734.23220000 -36684.75720000, -1509734.23180000 -36684.75720000,
-1509734.23180000 -36684.75680000, -1509734.23220000 -36684.75680000, -1509734.23220000 -36684.75720000))"
"Linestring" |"POLYGON (( -1511144.18100000 -39753.46900000, -1508656.03600000 -39753.46900000,
-1508656.03600000 -37680.01500000, -1511144.18100000 -37680.01500000, -1511144.18100000 -39753.46900000))"
"Polygon" |"POLYGON (( -1506333.76800000 -36767.69500000, -1502684.48900000 -36767.69500000,
-1502684.48900000 -35357.74700000, -1506333.76800000 -35357.74700000, -1506333.76800000 -36767.69500000))"
"Multipoint" |"POLYGON (( -1495800.62200000 -42739.24200000, -1493229.53900000 -42739.24200000,
-1493229.53900000 -40665.78900000, -1495800.62200000 -40665.78900000, -1495800.62200000 -42739.24200000))"
"Multilinestring" |"POLYGON (( -1507411.96400000 -38094.70600000, -1498952.27200000 -38094.70600000,
-1498952.27200000 -33201.35500000, -1507411.96400000 -33201.35500000, -1507411.96400000 -38094.70600000))"
"Multipolygon" |"POLYGON (( -1498537.58100000 -50618.36700000, -1492068.40500000 -50618.36700000,
-1492068.40500000 -45725.01600000, -1498537.58100000 -45725.01600000, -1498537.58100000 -50618.36700000))"
SQLite
--Create table and insert values.
CREATE TABLE envelope_test (
geotype varchar(20)
);
SELECT AddGeometryColumn (
NULL,
'envelope_test',
'g1',
4326,
'geometry',
'xy',
'null'
);
INSERT INTO ENVELOPE_TEST VALUES (
'Point',
st_geometry ('point (-1509734.232 -36684.757)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Linestring',
st_geometry ('linestring (-1511144.181 -37680.015, -1509734.232 -38841.149, -1508656.036 -39753.469)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Polygon',
st_geometry ('polygon ((-1506333.768 -36435.943, -1504343.252 -36767.695, -1502684.489 -35357.747, -1506333.768 -36435.943))', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multipoint',
st_geometry ('multipoint (-1493229.539 -40665.789, -1494141.859 -40831.665, -1495800.622 -42739.242)', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multilinestring',
st_geometry ('multilinestring ((-1504757.943 -33201.355, -1507411.964 -35606.561), (-1502518.613 -38094.706, -1499781.653 -37099.448, -1498952.272 -34694.241))', 102004)
);
INSERT INTO ENVELOPE_TEST VALUES (
'Multipolygon',
st_geometry ('multipolygon (((-1492068.405 -47300.841, -1492814.848 -45725.016, -1493975.983 -46471.459,
-1493478.354 -47798.47, -1492068.405 -47300.841), (-1497874.076 -48047.284, -1498537.581 -50618.367, -1497210.571 -50037.8,
-1497874.076 -48047.284)))', 102004)
);
--Return the polygon envelope around each geometry in well-known text.
SELECT geotype AS geometry_type,
st_astext (st_envelope (g1)) AS "Envelope"
FROM envelope_test;
geometry_type Envelope
Point POLYGON (( -1509734.23220000 -36684.75720000, -1509734.23180000 -36684.75720000,
-1509734.23180000 -36684.75680000, -1509734.23220000 -36684.75680000, -1509734.23220000 -36684.75720000))
Linestring POLYGON (( -1511144.18100000 -39753.46900000, -1508656.03600000 -39753.46900000,
-1508656.03600000 -37680.01500000, -1511144.18100000 -37680.01500000, -1511144.18100000 -39753.46900000))
Polygon POLYGON (( -1506333.76800000 -36767.69500000, -1502684.48900000 -36767.69500000,
-1502684.48900000 -35357.74700000, -1506333.76800000 -35357.74700000, -1506333.76800000 -36767.69500000))
Multipoint POLYGON (( -1495800.62200000 -42739.24200000, -1493229.53900000 -42739.24200000,
-1493229.53900000 -40665.78900000, -1495800.62200000 -40665.78900000, -1495800.62200000 -42739.24200000))
Multilinestring POLYGON (( -1507411.96400000 -38094.70600000, -1498952.27200000 -38094.70600000,
-1498952.27200000 -33201.35500000, -1507411.96400000 -33201.35500000, -1507411.96400000 -38094.70600000))
Multipolygon POLYGON (( -1498537.58100000 -50618.36700000, -1492068.40500000 -50618.36700000,
-1492068.40500000 -45725.01600000, -1498537.58100000 -45725.01600000, -1498537.58100000 -50618.36700000))