12.17.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.MySQL支持本节中列出的函数,用于将几何值从内部几何格式转换为WKT或WKB格式,或交换X和Y坐标的顺序。

There are also functions to convert a string from WKT or WKB format to internal geometry format. 还有一些函数可以将字符串从WKT或WKB格式转换为内部几何格式。See Section 12.17.3, “Functions That Create Geometry Values from WKT Values”, and Section 12.17.4, “Functions That Create Geometry Values from WKB Values”.参见第12.17.3节,“从WKT值创建几何值的函数”第12.17.4节,“从WKB值创建几何值的函数”

Functions such as ST_GeomFromText() that accept WKT geometry collection arguments understand both OpenGIS 'GEOMETRYCOLLECTION EMPTY' standard syntax and MySQL 'GEOMETRYCOLLECTION()' nonstandard syntax. 接受WKT geometry集合参数的函数,如ST_geometryfromtext(),既理解OpenGIS的'GEOMETRYCOLLECTION EMPTY'标准语法,也理解MySQL的'GEOMETRYCOLLECTION()'非标准语法。Another way to produce an empty geometry collection is by calling GeometryCollection() with no arguments. 生成空几何体集合的另一种方法是不带参数调用GeometryCollection()Functions such as ST_AsWKT() that produce WKT values produce 'GEOMETRYCOLLECTION EMPTY' standard syntax:生成WKT值的函数(如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 |
+--------------------------+--------------------------+
mysql> SELECT ST_AsWKT(GeomCollection());
+----------------------------+
| ST_AsWKT(GeomCollection()) |
+----------------------------+
| GEOMETRYCOLLECTION EMPTY   |
+----------------------------+

Unless otherwise specified, functions in this section handle their geometry arguments as follows:除非另有规定,否则本节中的函数按如下方式处理其几何参数:

These functions are available for format conversions or coordinate swapping:这些函数可用于格式转换或坐标交换: