These functions take as arguments a Well-Known Text (WKT) representation and, optionally, a spatial reference system identifier (SRID). 这些函数将众所周知的文本(WKT)表示和空间参考系统标识符(SRID)作为参数。They return the corresponding geometry. 它们返回相应的几何图形。For a description of WKT format, see Well-Known Text (WKT) Format.有关WKT格式的说明,请参阅众所周知的文本(WKT)格式。
Functions in this section detect arguments in either Cartesian or geographic spatial reference systems (SRSs), and return results appropriate to the SRS.本节中的函数检测笛卡尔坐标系或地理空间参考系(SRS)中的参数,并返回适合SRS的结果。
ST_GeomFromText()
accepts a WKT value of any geometry type as its first argument. ST_GeomFromText()
接受任何几何体类型的WKT值作为其第一个参数。Other functions provide type-specific construction functions for construction of geometry values of each geometry type.其他函数提供特定于类型的构造函数,用于构造每个几何图形类型的几何图形值。
Functions such as 接受多点值的WKT格式表示形式的函数,如ST_MPointFromText()
and ST_GeomFromText()
that accept WKT-format representations of MultiPoint
values permit individual points within values to be surrounded by parentheses. ST_MPointFromText()
和ST_GeomFromText()
,允许值中的各个点用括号括起来。For example, both of the following function calls are valid:例如,以下两个函数调用都是有效的:
ST_MPointFromText('MULTIPOINT (1 1, 2 2, 3 3)') ST_MPointFromText('MULTIPOINT ((1 1), (2 2), (3 3))')
Functions such as 接受WKT geometry集合参数的函数,如ST_GeomFromText()
that accept WKT geometry collection arguments understand both OpenGIS 'GEOMETRYCOLLECTION EMPTY'
standard syntax and MySQL 'GEOMETRYCOLLECTION()'
nonstandard syntax. ST_geometryfromtext()
,既理解OpenGIS的'GEOMETRYCOLLECTION EMPTY'
标准语法,也理解MySQL的“GEOMETRYCOLLECTION()
”非标准语法。Functions such as 生成WKT值的函数(如ST_AsWKT()
that produce WKT values produce 'GEOMETRYCOLLECTION EMPTY'
standard syntax:ST_AsWKT()
)将生成'GEOMETRYCOLLECTION EMPTY'
标准语法:
mysql>SET @s1 = ST_GeomFromText('GEOMETRYCOLLECTION()');
mysql>SET @s2 = ST_GeomFromText('GEOMETRYCOLLECTION EMPTY');
mysql>SELECT ST_AsWKT(@s1), ST_AsWKT(@s2);
+--------------------------+--------------------------+ | ST_AsWKT(@s1) | ST_AsWKT(@s2) | +--------------------------+--------------------------+ | GEOMETRYCOLLECTION EMPTY | GEOMETRYCOLLECTION EMPTY | +--------------------------+--------------------------+
Unless otherwise specified, functions in this section handle their geometry arguments as follows:除非另有规定,否则本节中的函数按如下方式处理其几何参数:
If any geometry argument is 如果任何NULL
or is not a syntactically well-formed geometry, or if the SRID argument is NULL
, the return value is NULL
.geometry
参数为NULL
或不是语法格式良好的geometry
,或者SRID参数为NULL
,则返回值为NULL
。
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
参数来覆盖默认的轴顺序。选项由逗号分隔的key=value列表组成。options
consists of a list of comma-separated
. key
=value
The only permitted 唯一允许的key
value is axis-order
, with permitted values of lat-long
, long-lat
and srid-defined
(the default).key
值是axis-order
,允许值为lat-long
、long-lat
和srid-defined
(默认值)。
If the 如果options
argument is NULL
, the return value is NULL
. options
参数为NULL
,则返回值为NULL
。If the 如果options
argument is invalid, an error occurs to indicate why.options
参数无效,则会出现一个错误来说明原因。
If an SRID argument refers to an undefined spatial reference system (SRS), an 如果SRID参数引用未定义的空间参考系(SRS),则会发生ER_SRS_NOT_FOUND
error occurs.ER_SRS_NOT_FOUND
错误。
For geographic SRS geometry arguments, if any argument has a longitude or latitude that is out of range, an error occurs:对于地理SRS几何参数,如果任何参数的经度或纬度超出范围,则会发生错误:
If a longitude value is not in the range (−180, 180], an 如果经度值不在范围(180,180)内,则会发生ER_LONGITUDE_OUT_OF_RANGE
error occurs.ER_LONGITUDE_OUT_OF_RANGE
错误。
If a latitude value is not in the range [−90, 90], an 如果纬度值不在[90,90]范围内,则会发生ER_LATITUDE_OUT_OF_RANGE
error occurs.ER_LATITUDE_OUT_OF_RANGE
错误。
Ranges shown are in degrees. 显示的范围以度为单位。If an SRS uses another unit, the range uses the corresponding values in its unit. 如果SRS使用另一个单位,则范围使用其单位中的相应值。The exact range limits deviate slightly due to floating-point arithmetic.由于采用浮点运算,精确的范围限制略有偏差。
These functions are available for creating geometries from WKT values:这些函数可用于从WKT值创建几何图形:
ST_GeomCollFromText(
, wkt
[, srid
[, options
]])ST_GeometryCollectionFromText(
, wkt
[, srid
[, options
]])ST_GeomCollFromTxt(
wkt
[, srid
[, options
]])
Constructs a 使用其WKT表示和SRID构造GeometryCollection
value using its WKT representation and SRID.GeometryCollection
值。
These functions handle their arguments as described in the introduction to this section.这些函数处理它们的参数,如本节简介中所述。
mysql>SET @g = "MULTILINESTRING((10 10, 11 11), (9 9, 10 10))";
mysql>SELECT ST_AsText(ST_GeomCollFromText(@g));
+--------------------------------------------+ | ST_AsText(ST_GeomCollFromText(@g)) | +--------------------------------------------+ | MULTILINESTRING((10 10,11 11),(9 9,10 10)) | +--------------------------------------------+
ST_GeomFromText(
, wkt
[, srid
[, options
]])ST_GeometryFromText(
wkt
[, srid
[, options
]])
Constructs a geometry value of any type using its WKT representation and SRID.使用WKT表示和SRID构造任何类型的几何体值。
These functions handle their arguments as described in the introduction to this section.这些函数处理它们的参数,如本节简介中所述。
ST_LineFromText(
, wkt
[, srid
[, options
]])ST_LineStringFromText(
wkt
[, srid
[, options
]])
Constructs a 使用其WKT表示形式和SRID构造一个LineString
value using its WKT representation and SRID.LineString
值。
These functions handle their arguments as described in the introduction to this section.这些函数处理它们的参数,如本节简介中所述。
ST_MLineFromText(
, wkt
[, srid
[, options
]])ST_MultiLineStringFromText(
wkt
[, srid
[, options
]])
Constructs a 使用WKT表示和SRID构造MultiLineString
value using its WKT representation and SRID.MultiLineString
。
These functions handle their arguments as described in the introduction to this section.这些函数处理它们的参数,如本节简介中所述。
ST_MPointFromText(
, wkt
[, srid
[, options
]])ST_MultiPointFromText(
wkt
[, srid
[, options
]])
Constructs a 使用WKT表示和SRID构造MultiPoint
value using its WKT representation and SRID.MultiPoint
。
These functions handle their arguments as described in the introduction to this section.这些函数处理它们的参数,如本节简介中所述。
ST_MPolyFromText(
, wkt
[, srid
[, options
]])ST_MultiPolygonFromText(
wkt
[, srid
[, options
]])
Constructs a 使用WKT表示和SRID构造MultiPolygon
value using its WKT representation and SRID.MultiPolygon
。
These functions handle their arguments as described in the introduction to this section.这些函数处理它们的参数,如本节简介中所述。
ST_PointFromText(
wkt
[, srid
[, options
]])
Constructs a 使用其WKT表示和SRID构造一个Point
value using its WKT representation and SRID.Point
值。
ST_PointFromText()
handles its arguments as described in the introduction to this section.ST_PointFromText()
处理其参数,如本节简介中所述。
ST_PolyFromText(
, wkt
[, srid
[, options
]])ST_PolygonFromText(
wkt
[, srid
[, options
]])
Constructs a 使用其WKT表示和SRID构造Polygon
value using its WKT representation and SRID.Polygon
值。
These functions handle their arguments as described in the introduction to this section.这些函数处理它们的参数,如本节简介中所述。