Fork me on GitHub

ST_Crosses

Signatures

BOOLEAN ST_Crosses(GEOMETRY geomA, GEOMETRY geomB);

Description

Returns true if geomA crosses geomB.

Crosses means that:

  • The intersection between geomA and geomB gives a new Geometry whose dimension is less than the maximum dimension of the input Geometries.
  • geomA and geomB have some, but not all interior points in common.
  • The intersection set is interior to both geomA and geomB.
Implements the OpenGIS Simple Features Implementation Specification for SQL version 1.2.1.
This predicate does not yet support spatial indices, but it will in a future release. Use it in conjunction with && operator. See here for more details.
Note

In the OpenGIS Simple Features Specification this predicate is only defined for (POINT, LINESTRING), (POINT, POLYGON), (LINESTRING, LINESTRING), and (LINESTRING, POLYGON) situations.

JTS and Geos extend this definition to (POLYGON, LINESTRING), (POLYGON, POINT) and (LINESTRING, POINT) situations.

Examples

Cases where ST_Crosses is true
SELECT ST_Crosses(geomA, geomB) FROM input_table;
-- Answer:    TRUE
geomA MULTIPOINT geomB LINESTRING
MULTIPOINT((1 3), (4 1), (4 3)) LINESTRING(1 1, 5 2, 2 5)

geomA MULTIPOINT geomB POLYGON
MULTIPOINT((1 3), (4 1), (4 3)) POLYGON((2 2, 5 2, 5 5, 2 5, 2 2))

geomA LINESTRING geomB LINESTRING
LINESTRING(1 3, 5 3) LINESTRING(1 1, 5 2, 2 5)

geomA LINESTRING geomB POLYGON
LINESTRING(1 3, 5 3) POLYGON((2 2, 5 2, 5 5, 2 5, 2 2))

geomA POLYGON geomB LINESTRING
POLYGON((1 1, 4 1, 4 4, 1 4, 1 1)) LINESTRING(1 5, 5 1)

geomA POLYGON geomB MULTIPOINT
POLYGON((1 1, 4 1, 4 4, 1 4, 1 1)) MULTIPOINT((2 3), (4 5), (5 1))

geomA LINESTRING geomB MULTIPOINT
LINESTRING(2 1, 1 3, 3 4) MULTIPOINT((1 3), (4 1), (4 3))

Cases where ST_Crosses is false
SELECT ST_Crosses(geomA, geomB) FROM input_table;
-- Answer:    FALSE
geomA POLYGON geomB POLYGON
POLYGON((1 1, 4 1, 4 4, 1 4, 1 1)) POLYGON((2 2, 5 2, 5 5, 2 5, 2 2))

geomA POLYGON geomB POLYGON
LINESTRING(1 1, 5 2, 2 5) LINESTRING(3 4, 5 2)

See also