Rechercher dans le manuel MySQL
12.16.7.3 LineString and MultiLineString Property Functions
A LineString
consists of
Point
values. You can extract particular
points of a LineString
, count the number of
points that it contains, or obtain its length.
Some functions in this section also work for
MultiLineString
values.
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 has an SRID value that refers to an undefined spatial reference system (SRS), an
ER_SRS_NOT_FOUND
error occurs.Otherwise, the return value is non-
NULL
.
These functions are available for obtaining linestring properties:
Returns the
Point
that is the endpoint of theLineString
valuels
.ST_EndPoint()
handles its arguments as described in the introduction to this section.- +----------------------------------------------+
- | ST_AsText(ST_EndPoint(ST_GeomFromText(@ls))) |
- +----------------------------------------------+
- +----------------------------------------------+
For a
LineString
valuels
,ST_IsClosed()
returns 1 ifls
is closed (that is, itsST_StartPoint()
andST_EndPoint()
values are the same).For a
MultiLineString
valuels
,ST_IsClosed()
returns 1 ifls
is closed (that is, theST_StartPoint()
andST_EndPoint()
values are the same for eachLineString
inls
).ST_IsClosed()
returns 0 ifls
is not closed, andNULL
ifls
isNULL
.ST_IsClosed()
handles its arguments as described in the introduction to this section, with this exception:If the geometry has an SRID value for a geographic spatial reference system (SRS), an
ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
error occurs.
- +------------------------------------+
- | ST_IsClosed(ST_GeomFromText(@ls1)) |
- +------------------------------------+
- | 0 |
- +------------------------------------+
- +------------------------------------+
- | ST_IsClosed(ST_GeomFromText(@ls2)) |
- +------------------------------------+
- | 1 |
- +------------------------------------+
- +------------------------------------+
- | ST_IsClosed(ST_GeomFromText(@ls3)) |
- +------------------------------------+
- | 0 |
- +------------------------------------+
Returns a double-precision number indicating the length of the
LineString
orMultiLineString
valuels
in its associated spatial reference system. The length of aMultiLineString
value is equal to the sum of the lengths of its elements.ST_Length()
computes a result as follows:If the geometry is a valid
LineString
in a Cartesian SRS, the return value is the Cartesian length of the geometry.If the geometry is a valid
MultiLineString
in a Cartesian SRS, the return value is the sum of the Cartesian lengths of its elements.If the geometry is a valid
LineString
in a geographic SRS, the return value is the geodetic length of the geometry in that SRS, in meters.If the geometry is a valid
MultiLineString
in a geographic SRS, the return value is the sum of the geodetic lengths of its elements in that SRS, in meters.
ST_Length()
handles its arguments as described in the introduction to this section, with these exceptions:If the geometry is not a
LineString
orMultiLineString
, the return value isNULL
.If the geometry is geometrically invalid, either the result is an undefined length (that is, it can be any number), or an error occurs.
If the length computation result is
+inf
, anER_DATA_OUT_OF_RANGE
error occurs.If the geometry has a geographic SRS with a longitude or latitude that is out of range, an error occurs:
If any longitude argument is not in the range (−180, 180], an
ER_LONGITUDE_OUT_OF_RANGE
error occurs.If any latitude argument is not in the range [−90, 90], an
ER_LATITUDE_OUT_OF_RANGE
error occurs.
Ranges shown are in degrees. The exact range limits deviate slightly due to floating-point arithmetic.
As of MySQL 8.0.15,
ST_Length()
permits an optionalunit
argument that specifies the linear unit for the returned length 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.28, “The INFORMATION_SCHEMA ST_UNITS_OF_MEASURE Table”.- +--------------------+
- | ST_Length(@ls) |
- +--------------------+
- | 2.8284271247461903 |
- +--------------------+
- +-------------------+
- | ST_Length(@mls) |
- +-------------------+
- | 4.242640687119286 |
- +-------------------+
- +-------------------+
- | ST_Length(@ls) |
- +-------------------+
- | 313701.9623204328 |
- +-------------------+
- +-------------------------+
- | ST_Length(@ls, 'metre') |
- +-------------------------+
- | 313701.9623204328 |
- +-------------------------+
- +------------------------+
- | ST_Length(@ls, 'foot') |
- +------------------------+
- | 1029205.9131247795 |
- +------------------------+
Returns the number of
Point
objects in theLineString
valuels
.ST_NumPoints()
handles its arguments as described in the introduction to this section.Returns the
N
-thPoint
in theLinestring
valuels
. Points are numbered beginning with 1.ST_PointN()
handles its arguments as described in the introduction to this section.- +----------------------------------------------+
- | ST_AsText(ST_PointN(ST_GeomFromText(@ls),2)) |
- +----------------------------------------------+
- +----------------------------------------------+
Returns the
Point
that is the start point of theLineString
valuels
.ST_StartPoint()
handles its arguments as described in the introduction to this section.- +------------------------------------------------+
- | ST_AsText(ST_StartPoint(ST_GeomFromText(@ls))) |
- +------------------------------------------------+
- +------------------------------------------------+
Traduction non disponible
Le manuel MySQL n'est pas encore traduit en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Document créé le 26/06/2006, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/mysql-rf-gis-linestring-property-functions.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.