Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » SQL Anywhere Server - Spatial Data Support » Spatial types and functions » ST_Geometry type

ST_Intersects method

Test if a geometry value spatially intersects another value.

Syntax
geometry-expression.ST_Intersects(geo2)
Parameters
Name Type Description

geo2

ST_Geometry

The other geometry value that is to be compared to the geometry-expression.

Returns
  • BIT

    Returns 1 if the geometry-expression spatially intersects with geo2, otherwise 0.

Remarks

Tests if a geometry value spatially intersects another value. Two geometries intersect if they share one or more common points.

geometry-expression.ST_Intersects( geo2 ) = 1 is equivalent to geometry-expression.ST_Disjoint( geo2 ) = 0.

Note If the geometry-expression contains circularstrings, then these are interpolated to line strings.
Standards
  • SQL/MM (ISO/IEC 13249-3: 2006)

    5.1.27

Example

The following example returns a result with one row for each shape that intersects the specified line.

SELECT ShapeID, "Description"
FROM SpatialShapes
WHERE NEW ST_LineString( 'LineString( 2 2, 4 4 )' ).ST_Intersects( Shape ) = 1
ORDER BY ShapeID

The example returns the following result set:

ShapeID Description
2 Square
3 Rectangle
5 L shape line
18 CircularString
22 Triangle

The following query returns the intersection of the geometries in the SpatialShapes table:

SELECT Shape
FROM SpatialShapes
WHERE NEW ST_LineString( 'LineString( 2 2, 4 4 )' ).ST_Intersects( Shape ) = 1
UNION ALL SELECT NEW ST_LineString( 'LineString( 2 2, 4 4 )' )

The following returns the result 1 because the two linestrings intersect.

SELECT NEW ST_LineString('LineString(0 0,2 0)').ST_Intersects( NEW ST_LineString('LineString(1 -1,1 1)') )

The following returns the result 0 because the two linestrings do not intersect.

SELECT NEW ST_LineString('LineString(0 0,2 0)').ST_Intersects( NEW ST_LineString('LineString(1 1,1 2)') )