Rechercher dans le manuel MySQL
12.16.9.1 Spatial Relation Functions That Use Object Shapes
The OpenGIS specification defines the following functions to
test the relationship between two geometry values
g1
and g2
, using precise
object shapes. The return values 1 and 0 indicate true and
false, respectively, except for
ST_Distance()
, which returns
distance values.
Functions in this section detect arguments in either Cartesian or geographic spatial reference systems (SRSs), and return results appropriate to the SRS.
Unless otherwise specified, functions in this section handle their arguments as follows:
If any argument is
NULL
or any geometry argument is an empty geometry, the return value isNULL
.If any geometry argument is not a syntactically well-formed geometry, an
ER_GIS_INVALID_DATA
error occurs.If any geometry argument refers to an undefined spatial reference system (SRS), an
ER_SRS_NOT_FOUND
error occurs.For functions that take multiple geometry arguments, if those arguments do not have the same SRID, an
ER_GIS_DIFFERENT_SRIDS
error occurs.If any geometry argument is geometrically invalid, either the result is true or false (it is undefined which), or an error occurs.
For geographic SRS geometry arguments, if any argument has a longitude or latitude that is out of range, an error occurs:
If a longitude value is not in the range (−180, 180], an
ER_LONGITUDE_OUT_OF_RANGE
error occurs.If a latitude value is not in the range [−90, 90], an
ER_LATITUDE_OUT_OF_RANGE
error occurs.
Ranges shown are in degrees. If an SRS uses another unit, the range uses the corresponding values in its unit. The exact range limits deviate slightly due to floating-point arithmetic.
Otherwise, the return value is non-
NULL
.
These object-shape functions are available for testing geometry relationships:
Returns 1 or 0 to indicate whether
g1
completely containsg2
. This tests the opposite relationship asST_Within()
.ST_Contains()
handles its arguments as described in the introduction to this section.Two geometries spatially cross if their spatial relation has the following properties:
Unless
g1
andg2
are both of dimension 1:g1
crossesg2
if the interior ofg2
has points in common with the interior ofg1
, butg2
does not cover the entire interior ofg1
.If both
g1
andg2
are of dimension 1: If the lines cross each other in a finite number of points (that is, no common line segments, only single points in common).
This function returns 1 or 0 to indicate whether
g1
spatially crossesg2
.ST_Crosses()
handles its arguments as described in the introduction to this section except that the return value isNULL
for these additional conditions:g1
is of dimension 2 (Polygon
orMultiPolygon
).g2
is of dimension 1 (Point
orMultiPoint
).
Returns 1 or 0 to indicate whether
g1
is spatially disjoint from (does not intersect)g2
.ST_Disjoint()
handles its arguments as described in the introduction to this section.Returns the distance between
g1
andg2
, measured in the length unit of the spatial reference system (SRS) of the geometry arguments, or in the unit of the optionalunit
argument if that is specified.This function processes geometry collections by returning the shortest distance among all combinations of the components of the two geometry arguments.
ST_Distance()
handles its geometry arguments as described in the introduction to this section, with these exceptions:ST_Distance()
detects arguments in a geographic (ellipsoidal) spatial reference system and returns the geodetic distance on the ellipsoid. As of MySQL 8.0.18,ST_Distance()
supports distance calculations for geographic SRS arguments of all geometry types. Prior to MySQL 8.0.18, the only permitted geographic argument types arePoint
andPoint
, orPoint
andMultiPoint
(in any argument order). If called with other geometry type argument combinations in a geographic SRS, anER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
error occurs.If any argument is geometrically invalid, either the result is an undefined distance (that is, it can be any number), or an error occurs.
If an intermediate or final result produces
NaN
or a negative number, anER_GIS_INVALID_DATA
error occurs.
As of MySQL 8.0.14,
ST_Distance()
permits an optionalunit
argument that specifies the linear unit for the returned distance value. These rules apply:If a unit is specified but not supported by MySQL, an
ER_UNIT_NOT_FOUND
error occurs.If a supported linear unit is specified and the SRID is 0, an
ER_GEOMETRY_IN_UNKNOWN_LENGTH_UNIT
error occurs.If a supported linear unit is specified and the SRID is not 0, the result is in that unit.
If a unit is not specified, the result is in the unit of the SRS of the geometries, whether Cartesian or geographic. Currently, all MySQL SRSs are expressed in meters.
A unit is supported if it is found in the
INFORMATION_SCHEMA
ST_UNITS_OF_MEASURE
table. See Section 25.29, “The INFORMATION_SCHEMA ST_UNITS_OF_MEASURE Table”.- +-----------------------+
- | ST_Distance(@g1, @g2) |
- +-----------------------+
- | 1.4142135623730951 |
- +-----------------------+
- +-----------------------+
- | ST_Distance(@g1, @g2) |
- +-----------------------+
- | 156874.3859490455 |
- +-----------------------+
- +--------------------------------+
- | ST_Distance(@g1, @g2, 'metre') |
- +--------------------------------+
- | 156874.3859490455 |
- +--------------------------------+
- +-------------------------------+
- | ST_Distance(@g1, @g2, 'foot') |
- +-------------------------------+
- | 514679.7439273146 |
- +-------------------------------+
For the special case of distance calculations on a sphere, see the
ST_Distance_Sphere()
function.Returns 1 or 0 to indicate whether
g1
is spatially equal tog2
.ST_Equals()
handles its arguments as described in the introduction to this section, except that it does not returnNULL
for empty geometry arguments.Returns 1 or 0 to indicate whether
g1
spatially intersectsg2
.ST_Intersects()
handles its arguments as described in the introduction to this section.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
g1
spatially overlapsg2
.ST_Overlaps()
handles its arguments as described in the introduction to this section except that the return value isNULL
for the additional condition that the dimensions of the two geometries are not equal.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
g1
spatially touchesg2
.ST_Touches()
handles its arguments as described in the introduction to this section except that the return value isNULL
for the additional condition that both geometries are of dimension 0 (Point
orMultiPoint
).Returns 1 or 0 to indicate whether
g1
is spatially withing2
. This tests the opposite relationship asST_Contains()
.ST_Within()
handles its arguments as described in the introduction to this section.
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 26/06/2006, zuletzt geändert 26/10/2018
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/mysql-rf-spatial-relation-functions-object-shapes.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.