Определение
ST_EnvIntersects возвращает 1 (true), если ограничивающие прямоугольники двух геометрий пересекаются. В противном случае возвращается значение 0 (false).
Синтаксис
Oracle
sde.st_envintersects (geometry1 sde.st_geometry, geometry2 sde.st_geometry) sde.st_envintersects (geometry1 sde.st_geometry, minx number, miny number, maxx number, maxy number)
SQLite
st_envintersects (geometry1 geometryblob, geometry2 geoemtryblob) st_envintersects (geometry1 geoemtryblob, minx float64, miny float64, maxx float64, maxy float64)
Тип возврата
Логический
Пример:
В этом примере ищется геометрия, ограничивающий прямоугольник которой пересекается указанным полигоном.
Первое выражение SELECT сравнивает ограничивающие прямоугольники двух геометрий и сами геометрии с целью определения, пересекаются ли эти объекты (или ограничивающие их прямоугольники).
Второе выражение SELECT использует ограничивающий прямоугольник для определения того, попадают ли какие-нибудь объекты внутрь прямоугольника, с которым работает условие WHERE выражения SELECT.
Oracle
--Define and populate the table.
CREATE TABLE sample_geoms (
 id integer,
 geometry sde.st_geometry);
INSERT INTO SAMPLE_GEOMS (id, geometry) VALUES (
 1,
 sde.st_geometry ('linestring (10 10, 50 50)', 4326)
);
INSERT INTO SAMPLE_GEOMS (id, geometry) VALUES (
 2,
 sde.st_geometry ('linestring (10 20, 50 60)', 4326)
);
--Find the intersection of the geometries and the geometries' envelopes.
SELECT a.id, b.id, sde.st_intersects (a.geometry, b.geometry) Intersects, sde.st_envintersects (a.geometry, b.geometry) Envelope_Intersects
 FROM SAMPLE_GEOMS a, SAMPLE_GEOMS b
 WHERE a.id = 1 AND b.id=2; 
ID      ID      INTERSECTS   ENVELOPE_INTERSECTS
1       2       0            1
--Find the geometries whose envelopes intersect the specified envelope.
SELECT id
 FROM SAMPLE_GEOMS
 WHERE sde.st_envintersects(geometry, 5, 5, 60, 65) = 1;
ID 
1
2
SQLite
--Define and populate the table.
CREATE TABLE sample_geoms (
 id integer primary key autoincrement not null
);
SELECT AddGeometryColumn (
 NULL,
 'sample_geoms',
 'geometry',
 4326,
 'linestring',
 'xy',
 'null'
);
INSERT INTO SAMPLE_GEOMS (geometry) VALUES (
 st_geometry ('linestring (10 10, 50 50)', 4326)
);
INSERT INTO SAMPLE_GEOMS (geometry) VALUES (
 st_geometry ('linestring (10 20, 50 60)', 4326)
);
--Find the intersection of the geometries and the geometries' envelopes.
SELECT a.id AS aid, b.id AS bid, st_intersects (a.geometry, b.geometry) AS "Intersects",
 st_envintersects (a.geometry, b.geometry) AS "Envelope_Intersects"
 FROM SAMPLE_GEOMS a, SAMPLE_GEOMS b
 WHERE a.id = 1 AND b.id = 2; 
aid     bid     Intersects   Envelope_Intersects
1       2       0            1
--Find the geometries whose envelopes intersect the specified envelope.
SELECT id
 FROM SAMPLE_GEOMS
 WHERE st_envintersects(geometry, 5, 5, 60, 65) = 1;
ID 
1
2