文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 14 函数和运算符 / 14.16 空间分析函数 / 14.16.3 从 WKT 值创建几何值的函数
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 80%

14.16.3 从 WKT 值创建几何值的函数14.16.3 Functions That Create Geometry Values from WKT Values

这些函数以 Well-Known Text (WKT) 表示作为参数,并可选择地使用空间参考系统标识符 (SRID)。它们返回相应的几何对象。有关 WKT 格式的说明,请参见 Well-Known Text (WKT) Format。These functions take as arguments a Well-Known Text (WKT) representation and, optionally, a spatial reference system identifier (SRID). They return the corresponding geometry. For a description of WKT format, see Well-Known Text (WKT) Format.

本节中的函数可以检测笛卡尔或地理空间参考系统(SRS)中的参数,并返回适合该 SRS 的结果。Functions in this section detect arguments in either Cartesian or geographic spatial reference systems (SRSs), and return results appropriate to the SRS.

ST_GeomFromText() 接受任何几何类型的 WKT 值作为其第一个参数。其他函数提供了针对每种几何类型的几何值构建的类型特定构建函数。ST_GeomFromText() accepts a WKT value of any geometry type as its first argument. Other functions provide type-specific construction functions for construction of geometry values of each geometry type.

像 ST_MPointFromText() 和 ST_GeomFromText() 这样的函数接受 MultiPoint 值的 WKT 格式表示,允许值中的各个点用括号括起来。例如,下面的两个函数调用都是有效的:Functions such as ST_MPointFromText() and ST_GeomFromText() that accept WKT-format representations of MultiPoint values permit individual points within values to be surrounded by parentheses. 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))')

像 ST_GeomFromText() 这样接受 WKT 几何集合参数的函数,既可以理解 OpenGIS 的 'GEOMETRYCOLLECTION EMPTY' 标准语法,也可以理解 MySQL 的 'GEOMETRYCOLLECTION()' 非标准语法。像 ST_AsWKT() 这样生成 WKT 值的函数,会生成 'GEOMETRYCOLLECTION EMPTY' 标准语法:Functions such as ST_GeomFromText() that accept WKT geometry collection arguments understand both OpenGIS 'GEOMETRYCOLLECTION EMPTY' standard syntax and MySQL 'GEOMETRYCOLLECTION()' nonstandard syntax. Functions such as ST_AsWKT() that produce WKT values produce 'GEOMETRYCOLLECTION EMPTY' standard syntax:

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:

  • 如果任何几何参数为 NULL 或语法上不是格式良好的几何体,或者 SRID 参数为 NULL,则返回值为 NULL。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.

  • 默认情况下,地理坐标(纬度,经度)按照几何参数的空间参考系统指定的顺序进行解释。可以提供一个可选的options参数来覆盖默认的轴顺序。options由用逗号分隔的key=value组成。唯一允许的key值是axis-order,其允许的值为lat-long、long-lat和srid-defined(默认)。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 key=value. The only permitted key value is axis-order, with permitted values of lat-long, long-lat and srid-defined (the default).

    如果options参数为NULL,返回值为NULL。如果options参数无效,将产生错误以说明原因。If the options argument is NULL, the return value is NULL. If the options argument is invalid, an error occurs to indicate why.

  • 如果 SRID 参数引用了未定义的空间参考系统(SRS),将发生ER_SRS_NOT_FOUND错误。If an SRID argument refers to an undefined spatial reference system (SRS), an ER_SRS_NOT_FOUND error occurs.

  • 对于地理 SRS 几何参数,如果任何参数的经度或纬度超出范围,将会发生错误:For geographic SRS geometry arguments, if any argument has a longitude or latitude that is out of range, an error occurs:

    显示的范围以度为单位。如果 SRS 使用其他单位,则范围使用其单位对应的数值。由于浮点运算,精确的范围限制会有轻微偏差。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.

这些函数可用于从 WKT 值创建几何图形:These functions are available for creating geometries from WKT values: