Définition
ST_Overlaps accepte deux objets géométrie et retourne 1 (Oracle et SQLite) ou t (PostgreSQL) si l'intersection des objets résulte en un objet géométrie de la même dimension, mais différent des objets source ; dans le cas contraire, la fonction retourne 0 (Oracle et SQLite) ou t (PostgreSQL).
Syntaxe
Oracle et PostgreSQL
sde.st_overlaps (geometry1 sde.st_geometry, geometry2 sde.st_geometry)
SQLite
st_overlaps (geometry1 geometryblob, geometry2 geometryblob)
Type de retour
Booléen
Exemple
Le responsable de l'aménagement du territoire a besoin d'une liste des zones sensibles qui sont superposées au rayon de la zone tampon des sites de dépôt de déchets dangereux. La table sensitive_areas contient plusieurs colonnes qui décrivent les institutions menacées en plus de la colonne shape qui stocke les géométries ST_Polygon des institutions.
La table hazardous_sites stocke l'identité des sites dans la colonne id, tandis que l'emplacement géographique réel de chaque site est stocké dans la colonne des points de site.
Les tables sensitive_areas et hazardous_sites sont jointes par la fonction ST_Overlaps qui renvoie l'ID de toutes les lignes de la table sensitive_areas qui contiennent des polygones superposés au rayon bufférisé des points de la table hazardous_sites.
Oracle
CREATE TABLE sensitive_areas (
id integer,
shape sde.st_geometry
);
CREATE TABLE hazardous_sites (
id integer,
site sde.st_geometry
);
INSERT INTO sensitive_areas VALUES (
1,
sde.st_geometry ('polygon ((.20 .30, .30 .30, .30 .40, .20 .40, .20 .30))', 4326)
);
INSERT INTO sensitive_areas VALUES (
2,
sde.st_geometry ('polygon ((.30 .30, .30 .50, .50 .50, .50 .30, .30 .30))', 4326)
);
INSERT INTO sensitive_areas VALUES (
3,
sde.st_geometry ('polygon ((.40 .40, .40 .60, .60 .60, .60 .40, .40 .40))', 4326)
);
INSERT INTO hazardous_sites VALUES (
4,
sde.st_geometry ('point (.60 .60)', 4326)
);
INSERT INTO hazardous_sites VALUES (
5,
sde.st_geometry ('point (.30 .30)', 4326)
);
SELECT UNIQUE (hs.id)
FROM HAZARDOUS_SITES hs, SENSITIVE_AREAS sa
WHERE sde.st_overlaps (sde.st_buffer (hs.site, .001), sa.shape) = 1;
ID
4
5
PostgreSQL
CREATE TABLE sensitive_areas (
id serial,
shape sde.st_geometry
);
CREATE TABLE hazardous_sites (
id serial,
site sde.st_geometry
);
INSERT INTO sensitive_areas (shape) VALUES (
sde.st_geometry ('polygon ((.20 .30, .30 .30, .30 .40, .20 .40, .20 .30))', 4326)
);
INSERT INTO sensitive_areas (shape) VALUES (
sde.st_geometry ('polygon ((.30 .30, .30 .50, .50 .50, .50 .30, .30 .30))', 4326)
);
INSERT INTO sensitive_areas (shape) VALUES (
sde.st_geometry ('polygon ((.40 .40, .40 .60, .60 .60, .60 .40, .40 .40))', 4326)
);
INSERT INTO hazardous_sites (site) VALUES (
sde.st_geometry ('point (.60 .60)', 4326)
);
INSERT INTO hazardous_sites (site) VALUES (
sde.st_geometry ('point (.30 .30)', 4326)
);
SELECT DISTINCT (hs.id) AS "Hazardous Site ID"
FROM hazardous_sites hs, sensitive_areas sa
WHERE sde.st_overlaps (sde.st_buffer (hs.site, .001), sa.shape) = 't';
id
1
2
SQLite
CREATE TABLE sensitive_areas (
id integer primary key autoincrement not null
);
SELECT AddGeometryColumn(
NULL,
'sensitive_areas',
'shape',
4326,
'polygon',
'xy',
'null'
);
CREATE TABLE hazardous_sites (
id integer primary key autoincrement not null,
site_name varchar(30)
);
SELECT AddGeometryColumn(
NULL,
'hazardous_sites',
'site',
4326,
'point',
'xy',
'null'
);
INSERT INTO sensitive_areas (shape) VALUES (
st_geometry ('polygon ((.20 .30, .30 .30, .30 .40, .20 .40, .20 .30))', 4326)
);
INSERT INTO sensitive_areas (shape) VALUES (
st_geometry ('polygon ((.30 .30, .30 .50, .50 .50, .50 .30, .30 .30))', 4326)
);
INSERT INTO sensitive_areas (shape) VALUES (
st_geometry ('polygon ((.40 .40, .40 .60, .60 .60, .60 .40, .40 .40))', 4326)
);
INSERT INTO hazardous_sites (site_name, site) VALUES (
'Kemlabs',
st_geometry ('point (.60 .60)', 4326)
);
INSERT INTO hazardous_sites (site_name, site) VALUES (
'Medi-Waste',
st_geometry ('point (.30 .30)', 4326)
);
SELECT DISTINCT (hs.site_name) AS "Hazardous Site"
FROM hazardous_sites hs, sensitive_areas sa
WHERE st_overlaps (st_buffer (hs.site, .001), sa.shape) = 1;
Hazardous Site
Kemlabs
Medi-Waste