All Products
Search
Document Center

Lindorm:Functions for spatial relationships

Last Updated:Mar 28, 2026

Lindorm GanosBase provides functions to determine the spatial relationships between geometry objects, such as containment, intersection, overlap, and proximity.

Applicable engines and versions

These functions apply only to LindormTable and are supported by all versions of LindormTable.

Functions

FunctionDescription
ST_ContainsReturns true if geomA contains geomB.
ST_DWithinReturns true if the 2D distance between two geometry objects is within the specified range. The distance is measured in degrees (SRID 4326).
ST_DWithinSphereReturns true if the spherical distance between two geometry objects is within the specified range. The distance is measured in meters.
ST_IntersectsReturns true if two geometry objects share any spatial space.
ST_OverlapsReturns true if two geometry objects spatially overlap but one is not included in the other.
ST_WithinReturns true if geomA completely lies within geomB.

ST_Contains

Returns true if geomA contains geomB — that is, all points of geomB lie in the interior or on the boundary of geomA.

ST_Contains is the inverse of ST_Within: ST_Contains(A, B) returns the same result as ST_Within(B, A).

Syntax

-- Check whether geomA contains geomB
boolean ST_Contains(geometry geomA, geometry geomB)

-- Check whether geom contains the point (x, y)
boolean ST_Contains(geometry geom, double x, double y)

Parameters

ParameterDescription
geomAThe first geometry object.
geomBThe second geometry object.
geomThe geometry object.
xThe longitude of the point.
yThe latitude of the point.

Supported geometry types: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection.

Examples

Check whether a polygon contains a point object:

SELECT ST_Contains(ST_GeomFromText('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'), ST_GeomFromText('POINT(5 5)')) AS iscontain;

Result:

+-----------+
| iscontain |
+-----------+
| true      |
+-----------+

Check whether a polygon contains the point (5, 5) specified by coordinates:

SELECT ST_Contains(ST_GeomFromText('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'), 5, 5) AS iscontain;

Result:

+-----------+
| iscontain |
+-----------+
| true      |
+-----------+

Check whether a polygon contains a point outside its boundary:

SELECT ST_Contains(ST_GeomFromText('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'), ST_GeomFromText('POINT(180 23)')) AS iscontain;

Result:

+-----------+
| iscontain |
+-----------+
| false     |
+-----------+

Same check using coordinates:

SELECT ST_Contains(ST_GeomFromText('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'), 180, 23) AS iscontain;

Result:

+-----------+
| iscontain |
+-----------+
| false     |
+-----------+

ST_DWithin

Returns true if the 2D (planar) distance between two geometry objects is within the specified range. The distance is measured in degrees under Spatial Reference System Identifier (SRID) 4326.

Use ST_DWithin for planar distance comparisons in SRID 4326 degree units. To measure real-world distances in meters on a sphere, use ST_DWithinSphere instead.

Syntax

-- Check whether the 2D distance between geomA and geomB is within the range
boolean ST_DWithin(geometry geomA, geometry geomB, double distanceOfSrid)

-- Check whether the 2D distance between geom and the point (x, y) is within the range
boolean ST_DWithin(geometry geom, double x, double y, double distanceOfSrid)

Parameters

ParameterDescription
geomAThe first geometry object.
geomBThe second geometry object.
distanceOfSridThe maximum distance threshold in SRID 4326. Unit: degree.
geomThe geometry object.
xThe longitude of the point.
yThe latitude of the point.

Supported geometry types: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection.

Examples

Check whether two points are within 10 degrees of each other:

SELECT ST_DWithin(ST_GeomFromText('POINT(5 5)'), ST_GeomFromText('POINT(6 6)'), 10) AS iswithin;

Result:

+----------+
| iswithin |
+----------+
| true     |
+----------+

Same check using coordinates for the second point:

SELECT ST_DWithin(ST_GeomFromText('POINT(5 5)'), 6, 6, 10) AS iswithin;

Result:

+----------+
| iswithin |
+----------+
| true     |
+----------+

ST_DWithinSphere

Returns true if the spherical distance between two geometry objects is within the specified range. The distance is measured in meters on a sphere.

Use ST_DWithinSphere when you need to measure real-world distances in meters. Results may have an error of centimeters due to the spherical approximation.

Syntax

-- Check whether the spherical distance between geomA and geomB is within the range
boolean ST_DWithinSphere(geometry geomA, geometry geomB, double distance)

-- Check whether the spherical distance between geom and the point (x, y) is within the range
boolean ST_DWithinSphere(geometry geom, double x, double y, double distance)

Parameters

ParameterDescription
geomAThe first geometry object.
geomBThe second geometry object.
distanceThe maximum distance threshold. Unit: meter. Results may have an error of centimeters.
geomThe geometry object.
xThe longitude of the point.
yThe latitude of the point.

Supported geometry types: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection.

Examples

Check whether two geographic points are within 570,000 meters of each other:

The spherical distance between (120, 36) and (116, 40) is approximately 566,034.79 meters, which is within 570,000 meters.

SELECT ST_DWithinSphere(ST_GeomFromText('POINT(120 36)'), ST_GeomFromText('POINT(116 40)'), 570000) AS iswithin;

Result:

+----------+
| iswithin |
+----------+
| true     |
+----------+

Same check using coordinates for the second point:

SELECT ST_DWithinSphere(ST_GeomFromText('POINT(120 36)'), 116, 40, 570000) AS iswithin;

Result:

+----------+
| iswithin |
+----------+
| true     |
+----------+

ST_Intersects

Returns true if two geometry objects share any spatial space.

Syntax

-- Check whether geomA and geomB intersect
boolean ST_Intersects(geometry geomA, geometry geomB)

-- Check whether geom intersects the point (x, y)
boolean ST_Intersects(geometry geom, double x, double y)

Parameters

ParameterDescription
geomAThe first geometry object.
geomBThe second geometry object.
geomThe geometry object.
xThe longitude of the point.
yThe latitude of the point.

Supported geometry types: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection.

Examples

Check whether a point and a line that do not touch each other intersect:

SELECT ST_Intersects(ST_GeomFromText('POINT(0 0)'), ST_GeomFromText('LINESTRING ( 2 0, 0 2 )')) AS isinter;

Result:

+---------+
| isinter |
+---------+
| false   |
+---------+

Same check using coordinates for the point:

SELECT ST_Intersects(ST_GeomFromText('LINESTRING ( 2 0, 0 2 )'), 0, 0) AS isinter;

Result:

+---------+
| isinter |
+---------+
| false   |
+---------+

Check whether a point and a line that share an endpoint intersect:

SELECT ST_Intersects(ST_GeomFromText('POINT(0 0)'), ST_GeomFromText('LINESTRING ( 0 0, 0 2 )')) AS isinter;

Result:

+---------+
| isinter |
+---------+
| true    |
+---------+

Same check using coordinates for the point:

SELECT ST_Intersects(ST_GeomFromText('LINESTRING ( 0 0, 0 2 )'), 0, 0) AS isinter;

Result:

+---------+
| isinter |
+---------+
| true    |
+---------+

ST_Overlaps

Returns true if two geometry objects spatially overlap but one is not included in the other.

Syntax

-- Check whether geomA and geomB overlap
boolean ST_Overlaps(geometry geomA, geometry geomB)

-- Check whether geom overlaps the point (x, y)
boolean ST_Overlaps(geometry geom, double x, double y)

Parameters

ParameterDescription
geomAThe first geometry object.
geomBThe second geometry object.
geomThe geometry object.
xThe longitude of the point.
yThe latitude of the point.

Supported geometry types: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection.

Examples

Check whether two partially overlapping line segments overlap:

SELECT ST_Overlaps(ST_GeomFromText('LINESTRING(0 0,0 2)'), ST_GeomFromText('LINESTRING(0 1,0 3)')) AS overlaps;

Result:

+----------+
| overlaps |
+----------+
| true     |
+----------+

Check whether a line and a point on that line overlap:

SELECT ST_Overlaps(ST_GeomFromText('LINESTRING(0 0,0 2)'), ST_GeomFromText('POINT(0 1)')) AS overlaps;

Result:

+----------+
| overlaps |
+----------+
| false    |
+----------+

Same check using coordinates for the point:

SELECT ST_Overlaps(ST_GeomFromText('LINESTRING(0 0,0 2)'), 0, 1) AS overlaps;

Result:

+----------+
| overlaps |
+----------+
| false    |
+----------+

ST_Within

Returns true if geomA completely lies within geomB.

ST_Within is the inverse of ST_Contains: ST_Within(A, B) returns the same result as ST_Contains(B, A).

If both ST_Within(A, B) and ST_Within(B, A) return true, A and B are spatially equal.

Syntax

-- Check whether geomA completely lies within geomB
boolean ST_Within(geometry geomA, geometry geomB)

-- Check whether the point (x, y) lies within geom
boolean ST_Within(double x, double y, geometry geom)

Parameters

ParameterDescription
geomAThe first geometry object.
geomBThe second geometry object.
geomThe geometry object.
xThe longitude of the point.
yThe latitude of the point.

Supported geometry types: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection.

Examples

Check whether a point lies within a polygon:

SELECT ST_Within(ST_GeomFromText('POINT(5 5)'), ST_GeomFromText('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))')) AS iswithin;

Result:

+----------+
| iswithin |
+----------+
| true     |
+----------+

Same check using coordinates for the point:

SELECT ST_Within(5, 5, ST_GeomFromText('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))')) AS iswithin;

Result:

+----------+
| iswithin |
+----------+
| true     |
+----------+