MySQL 5.7 Reference Manual Including MySQL NDB Cluster 7.5 and NDB Cluster 7.6

The OpenGIS specification defines the following functions to
test the relationship between two geometry values
* g1* and

`g2`

`ST_Distance()`

and
`Distance()`

, which return distance
values.
These functions support all argument type combinations except those that are inapplicable according to the Open Geospatial Consortium specification.

`ST_Crosses()`

and`Crosses()`

are synonyms. For more information, see the description of`ST_Crosses()`

.`Crosses()`

is deprecated; expect it to be removed in a future MySQL release. Use`ST_Crosses()`

instead.`ST_Distance()`

and`Distance()`

are synonyms. For more information, see the description of`ST_Distance()`

.`Distance()`

is deprecated; expect it to be removed in a future MySQL release. Use`ST_Distance()`

instead.Returns 1 or 0 to indicate whether

completely contains`g1`

. This tests the opposite relationship as`g2`

`ST_Within()`

.The term

*spatially crosses*denotes a spatial relation between two given geometries that has the following properties:The two geometries intersect.

Their intersection results in a geometry that has a dimension that is one less than the maximum dimension of the two given geometries.

Their intersection is not equal to either of the two given geometries.

This function returns 1 or 0 to indicate whether

spatially crosses`g1`

. If`g2`

is a`g1`

`Polygon`

or a`MultiPolygon`

, or ifis a`g2`

`Point`

or a`MultiPoint`

, the return value is`NULL`

.This function returns 0 if called with an inapplicable geometry argument type combination. For example, it returns 0 if the first argument is a

`Polygon`

or`MultiPolygon`

and/or the second argument is a`Point`

or`MultiPoint`

.Returns 1 if

spatially crosses`g1`

. Returns`g2`

`NULL`

ifis a`g1`

`Polygon`

or a`MultiPolygon`

, or ifis a`g2`

`Point`

or a`MultiPoint`

. Otherwise, returns 0.This function returns 0 if called with an inapplicable geometry argument type combination. For example, it returns 0 if the first argument is a

`Polygon`

or`MultiPolygon`

and/or the second argument is a`Point`

or`MultiPoint`

.`ST_Crosses()`

and`Crosses()`

are synonyms.Returns 1 or 0 to indicate whether

is spatially disjoint from (does not intersect)`g1`

.`g2`

Returns the distance between

and`g1`

. If either argument is`g2`

`NULL`

or an empty geometry, the return value is`NULL`

.This function processes geometry collections by returning the shortest distance among all combinations of the components of the two geometry arguments.

If an intermediate or final result produces NaN or a negative number, an

`ER_GIS_INVALID_DATA`

error occurs.mysql>

mysql>`SET @g1 = Point(1,1);`

mysql>`SET @g2 = Point(2,2);`

+-----------------------+ | ST_Distance(@g1, @g2) | +-----------------------+ | 1.4142135623730951 | +-----------------------+`SELECT ST_Distance(@g1, @g2);`

`ST_Distance()`

and`Distance()`

are synonyms.Returns 1 or 0 to indicate whether

is spatially equal to`g1`

.`g2`

mysql>

mysql>`SET @g1 = Point(1,1), @g2 = Point(2,2);`

+---------------------+---------------------+ | ST_Equals(@g1, @g1) | ST_Equals(@g1, @g2) | +---------------------+---------------------+ | 1 | 0 | +---------------------+---------------------+`SELECT ST_Equals(@g1, @g1), ST_Equals(@g1, @g2);`

Returns 1 or 0 to indicate whether

spatially intersects`g1`

.`g2`

Two geometries

*spatially overlap*if they intersect and their intersection results in a geometry of the same dimension but not equal to either of the given geometries.This function returns 1 or 0 to indicate whether

spatially overlaps`g1`

.`g2`

This function returns 0 if called with an inapplicable geometry argument type combination. For example, it returns 0 if called with geometries of different dimensions or any argument is a

`Point`

.Two geometries

*spatially touch*if their interiors do not intersect, but the boundary of one of the geometries intersects either the boundary or the interior of the other.This function returns 1 or 0 to indicate whether

spatially touches`g1`

.`g2`

This function returns 0 if called with an inapplicable geometry argument type combination. For example, it returns 0 if either of the arguments is a

`Point`

or`MultiPoint`

.`ST_Touches()`

and`Touches()`

are synonyms.Returns 1 or 0 to indicate whether

is spatially within`g1`

. This tests the opposite relationship as`g2`

`ST_Contains()`

.`ST_Touches()`

and`Touches()`

are synonyms. For more information, see the description of`ST_Touches()`

.`Touches()`

is deprecated; expect it to be removed in a future MySQL release. Use`ST_Touches()`

instead.