Rechercher dans le manuel MySQL
12.16.6 Geometry Format Conversion Functions
MySQL supports the functions listed in this section for converting geometry values from internal geometry format to WKT or WKB format, or for swapping the order of X and Y coordinates.
There are also functions to convert a string from WKT or WKB format to internal geometry format. See Section 12.16.3, “Functions That Create Geometry Values from WKT Values”, and Section 12.16.4, “Functions That Create Geometry Values from WKB Values”.
Functions such as ST_GeomFromText()
that accept WKT geometry collection arguments understand both
OpenGIS 'GEOMETRYCOLLECTION EMPTY'
standard
syntax and MySQL 'GEOMETRYCOLLECTION()'
nonstandard syntax. Another way to produce an empty geometry
collection is by calling
GeometryCollection()
with no
arguments. Functions such as
ST_AsWKT()
that produce WKT values produce 'GEOMETRYCOLLECTION
EMPTY'
standard syntax:
- +--------------------------+--------------------------+
- | ST_AsWKT(@s1) | ST_AsWKT(@s2) |
- +--------------------------+--------------------------+
- +--------------------------+--------------------------+
- +----------------------------+
- | ST_AsWKT(GeomCollection()) |
- +----------------------------+
- +----------------------------+
Unless otherwise specified, functions in this section handle their arguments as follows:
If any argument is
NULL
, 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 is in an undefined spatial reference system, the axes are output in the order they appear in the geometry and an
ER_WARN_SRS_NOT_FOUND_AXIS_ORDER
warning occurs.By default, geographic coordinates (latitude, longitude) are interpreted as in the order specified by the spatial reference system of geometry arguments. An optional
options
argument may be given to override the default axis order.options
consists of a list of comma-separated
. The onlypermittedkey
=value
key
value isaxis-order
, with permitted values oflat-long
,long-lat
andsrid-defined
(the default).If the
options
argument isNULL
, the return value isNULL
. If theoptions
argument is invalid, an error occurs to indicate why.Otherwise, the return value is non-
NULL
.
These functions are available for format conversions or coordinate swapping:
ST_AsBinary(
,g
[,options
])ST_AsWKB(
g
[,options
])Converts a value in internal geometry format to its WKB representation and returns the binary result.
The function return value has geographic coordinates (latitude, longitude) in the order specified by the spatial reference system that applies to the geometry argument. An optional
options
argument may be given to override the default axis order.ST_AsBinary()
andST_AsWKB()
handle their arguments as described in the introduction to this section.- +-----------------------------------------+
- | ST_AsText(ST_GeomFromWKB(ST_AsWKB(@g))) |
- +-----------------------------------------+
- +-----------------------------------------+
- +----------------------------------------------------------------+
- | ST_AsText(ST_GeomFromWKB(ST_AsWKB(@g, 'axis-order=long-lat'))) |
- +----------------------------------------------------------------+
- +----------------------------------------------------------------+
- +----------------------------------------------------------------+
- | ST_AsText(ST_GeomFromWKB(ST_AsWKB(@g, 'axis-order=lat-long'))) |
- +----------------------------------------------------------------+
- +----------------------------------------------------------------+
ST_AsText(
,g
[,options
])ST_AsWKT(
g
[,options
])Converts a value in internal geometry format to its WKT representation and returns the string result.
The function return value has geographic coordinates (latitude, longitude) in the order specified by the spatial reference system that applies to the geometry argument. An optional
options
argument may be given to override the default axis order.ST_AsText()
andST_AsWKT()
handle their arguments as described in the introduction to this section.- +--------------------------------+
- | ST_AsText(ST_GeomFromText(@g)) |
- +--------------------------------+
- +--------------------------------+
Output for
MultiPoint
values includes parentheses around each point. For example:- +---------------------------------+
- | ST_AsText(ST_GeomFromText(@mp)) |
- +---------------------------------+
- +---------------------------------+
Accepts an argument in internal geometry format, swaps the X and Y values of each coordinate pair within the geometry, and returns the result.
ST_SwapXY()
handles its arguments as described in the introduction to this section.- +----------------------------+
- | ST_AsText(@g) |
- +----------------------------+
- +----------------------------+
- +----------------------------+
- | ST_AsText(ST_SwapXY(@g)) |
- +----------------------------+
- +----------------------------+
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-format-conversion-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.