EnvelopesIntersect
The EnvelopesIntersect spatial function accepts two types of input parameters to determine if the minimum bounding rectangles of two geometries intersect.
- Two geometries
EnvelopesIntersect returns 1 if the envelope of the first geometry intersects the envelope of the second geometry. Otherwise, 0 (zero) is returned.
- A geometry, four type DOUBLE coordinate values that define the
lower-left and upper-right corners of a rectangular window, and the
spatial reference system identifier.
EnvelopesIntersect returns 1 if the envelope of the first geometry intersects with the envelope defined by the four type DOUBLE values. Otherwise, 0 (zero) is returned.
If one of the input geometries is empty or null, null is returned.
Syntax
Parameters
- geometry1
- One of the seven distinct spatial data types that represents the geometry whose envelope is to be tested for intersection with the envelope of either geometry2 or the minimum bounding rectangle (MBR) defined by the four type DOUBLE values.
- geometry2
- One of the seven distinct spatial data types that represents the geometry whose envelope is to be tested for intersection with the envelope of geometry1.
- x_min
- Specifies the minimum X coordinate value for the envelope. You
must specify a non-null value for this parameter.
The data type of this parameter is DOUBLE.
- y_min
- Specifies the minimum Y coordinate value for the envelope. You
must specify a non-null value for this parameter.
The data type of this parameter is DOUBLE.
- x_max
- Specifies the maximum X coordinate value for the envelope. You
must specify a non-null value for this parameter.
The data type of this parameter is DOUBLE.
- y_max
- Specifies the maximum Y coordinate value for the envelope. You
must specify a non-null value for this parameter.
The data type of this parameter is DOUBLE.
- srs_id
- Uniquely identifies the spatial reference system. The spatial
reference system identifier must match the spatial reference system
identifier of the geometry parameter. You must specify a non-null
value for this parameter.
The data type of this parameter is INTEGER.
Return type
INTEGER
Example
SET CURRENT PATH = CURRENT PATH, db2gse;
CREATE TABLE counties (id INTEGER, name CHAR(20), geometry ST_Polygon);
INSERT INTO counties VALUES
(1, 'County_1', ST_Polygon('polygon((0 0, 30 0, 40 30, 40 35,
5 35, 5 10, 20 10, 20 5, 0 0))' ,0));
INSERT INTO counties VALUES
(2, 'County_2', ST_Polygon('polygon((15 15, 15 20, 60 20, 60 15,
15 15))' ,0));
INSERT INTO counties VALUES
(3, 'County_3', ST_Polygon('polygon((115 15, 115 20, 160 20, 160 15,
115 15))' ,0));
SELECT name
FROM counties as c
WHERE EnvelopesIntersect(c.geometry, 15, 15, 60, 20, 0) =1;
Name
--------------------
County_1
County_2
