5. Geospatial Functions : Overlaps
 
Share this page                  
Overlaps
OVERLAPS(g1 Geometry, g2 Geometry)
Alias: ST_OVERLAPS
Returns 1 if g1 and g2 have some points that they share and the object that forms this intersection is of the same dimension as g1 and g2. Returns 0 if one of them shares every point with the other (CONTAINS) or if they share no points (DISJOINT).
Result type: integer
Examples:
g1 and g2 intersect at a single POINT, which has a lower dimension than g1 and g2:
SELECT OVERLAPS(LINEFROMTEXT('LINESTRING(0 0, 10 10)'), LINEFROMTEXT('LINESTRING(0 10, 10 0)'));
-------------
col1
-------------
0
-------------
g1 and g2 intersect at a LINESTRING, which has the same dimension as g1 and g2:
SELECT OVERLAPS(LINEFROMTEXT('LINESTRING(0 10, 6 4)'), LINEFROMTEXT('LINESTRING(4 6, 10 0)'));
-------------
col1
-------------
1
-------------
g1 and g2 do not share any points:
SELECT OVERLAPS(POLYFROMTEXT('POLYGON((0 0, 10 0, 7 10, 3 10, 0 0))'), POLYFROMTEXT('POLYGON((9 5, 19 5, 16 15, 12 15, 9 5))'));
-------------
col1
-------------
0
-------------