- Notifications
You must be signed in to change notification settings - Fork161
UDF Relationships
Qubiq1337 edited this pageApr 3, 2020 ·7 revisions
Overloads:
ST_Contains(geometry1, geometry2)return true if geometry1 contains geometry2
Example:
SELECT ST_Contains(ST_Polygon(1,1,1,4,4,4,4,1), ST_Point(2,3))from srcLIMIT1;-- return trueSELECT ST_Contains(ST_Polygon(1,1,1,4,4,4,4,1), ST_Point(8,8))from srcLIMIT1;-- return false
Overloads:
ST_Crosses(geometry1, geometry2)return true if geometry1 crosses geometry2
Example:
SELECT ST_Crosses(st_linestring(0,0,1,1), st_linestring(1,0,0,1))from srcLIMIT1;-- return trueSELECT ST_Crosses(st_linestring(2,0,2,3), st_polygon(1,1,1,4,4,4,4,1))from srcLIMIT1;-- return trueSELECT ST_Crosses(st_linestring(0,2,0,1), ST_linestring(2,0,1,0))from srcLIMIT1;-- return false
Overloads:
ST_Disjoint(geometry1, geometry2)return true if the intersection of geometry1 and geometry2 is empty
Example:
SELECT ST_Disjoint(ST_LineString(0,0,0,1), ST_LineString(1,1,1,0))from srcLIMIT1;-- return trueSELECT ST_Disjoint(ST_LineString(0,0,1,1), ST_LineString(1,0,0,1))from srcLIMIT1;-- return false
Overloads:
ST_EnvIntersects(ST_Geometry1, ST_Geometry2)return true if the envelopes of ST_Geometry1 and ST_Geometry2 intersect
Example:
SELECT ST_EnvIntersects(ST_LineString(0,0,1,1), ST_LineString(1,3,2,2))from srcLIMIT1;-- return falseSELECT ST_EnvIntersects(ST_LineString(0,0,2,2), ST_LineString(1,0,3,2))from srcLIMIT1;-- return true
Overloads:
ST_Equals(geometry1, geometry2)return true if geometry1 equals geometry2
Example:
SELECT ST_Equals(st_linestring(0,0,1,1), st_linestring(1,1,0,0))from srcLIMIT1;-- return trueSELECT ST_Equals(st_linestring(0,0,1,1), st_linestring(1,0,0,1))from srcLIMIT1;-- return false
Overloads:
ST_Intersects(geometry1, geometry2)return true if geometry1 intersects geometry2
Example:
SELECT ST_Intersects(st_linestring(0,0,1,1), st_linestring(1,1,0,0))from srcLIMIT1;-- return trueSELECT ST_Intersects(st_linestring(0,0,1,1), st_linestring(1,0,0,1))from srcLIMIT1;-- return trueSELECT ST_Intersects(ST_LineString(2,0,2,3), ST_Polygon(1,1,4,1,4,4,1,4))from srcLIMIT1;-- return trueSELECT ST_Intersects(ST_LineString(8,7,7,8), ST_Polygon(1,1,4,1,4,4,1,4))from srcLIMIT1;-- return false
Overloads:
ST_Overlaps(geometry1, geometry2)return true if geometry1 overlaps geometry2
Example:
SELECT ST_Overlaps(st_polygon(2,0,2,3,3,0), st_polygon(1,1,1,4,4,4,4,1))from srcLIMIT1;-- return trueSELECT ST_Overlaps(st_polygon(2,0,2,1,3,1), ST_Polygon(1,1,1,4,4,4,4,1))from srcLIMIT1;-- return false
Overloads:
ST_Relate(geometry1, geometry2)return true if geometry1 has the specified DE-9IM relationship with geometry2
Example:
SELECT ST_Relate(st_polygon(2,0,2,1,3,1), ST_Polygon(1,1,1,4,4,4,4,1),'****T****')from srcLIMIT1;-- trueSELECT ST_Relate(st_polygon(2,0,2,1,3,1), ST_Polygon(1,1,1,4,4,4,4,1),'T********')from srcLIMIT1;-- falseSELECT ST_Relate(st_linestring(0,0,3,3), ST_linestring(1,1,4,4),'T********')from srcLIMIT1;-- trueSELECT ST_Relate(st_linestring(0,0,3,3), ST_linestring(1,1,4,4),'****T****')from srcLIMIT1;-- false
Overloads:
ST_Touches(geometry1, geometry2)return true if geometry1 touches geometry2
Example:
SELECT ST_Touches(st_point(1,2), st_polygon(1,1,1,4,4,4,4,1))from srcLIMIT1;-- return trueSELECT ST_Touches(st_point(8,8), st_polygon(1,1,1,4,4,4,4,1))from srcLIMIT1;-- return false
Overloads:
ST_Within(geometry1, geometry2)return true if geometry1 is within geometry2
Example:
SELECT ST_Within(st_point(2,3), st_polygon(1,1,1,4,4,4,4,1))from srcLIMIT1;-- return trueSELECT ST_Within(st_point(8,8), st_polygon(1,1,1,4,4,4,4,1))from srcLIMIT1;-- return false