这些函数的参数是包含已知二进制 (WKB) 表示的 BLOB,以及可选的空间参考系统标识符 (SRID)。它们返回相应的几何体。有关 WKB 格式的描述,请参见 已知二进制 (WKB) 格式。These functions take as arguments a
BLOB containing a Well-Known Binary
(WKB) representation and, optionally, a spatial reference system
identifier (SRID). They return the corresponding geometry. For a
description of WKB format, see Well-Known Binary (WKB) 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_GeomFromWKB() 接受任意几何类型的 WKB 值作为其第一个参数。其他函数为每种几何类型提供特定类型的构造函数,用于构造各几何类型的几何值。ST_GeomFromWKB() accepts a WKB
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.
在 MySQL 8.4 之前,这些函数也接受由第 14.16.5 节,“创建几何值的 MySQL 特定函数”中的函数返回的几何对象。几何参数不再被允许,并会导致错误。要将调用从使用几何参数迁移到使用 WKB 参数,请遵循以下指南:Prior to MySQL 8.4, these functions also accepted geometry objects as returned by the functions in Section 14.16.5, “MySQL-Specific Functions That Create Geometry Values”. Geometry arguments are no longer permitted and produce an error. To migrate calls from using geometry arguments to using WKB arguments, follow these guidelines:
将类似
ST_GeomFromWKB(Point(0, 0))的结构重写为Point(0, 0)。Rewrite constructs such asST_GeomFromWKB(Point(0, 0))asPoint(0, 0).将类似
ST_GeomFromWKB(Point(0, 0), 4326)的结构重写为ST_SRID(Point(0, 0), 4326)或ST_GeomFromWKB(ST_AsWKB(Point(0, 0)), 4326)。Rewrite constructs such asST_GeomFromWKB(Point(0, 0), 4326)asST_SRID(Point(0, 0), 4326)orST_GeomFromWKB(ST_AsWKB(Point(0, 0)), 4326).
除非另有说明,本节中的函数对其几何参数的处理方式如下:Unless otherwise specified, functions in this section handle their geometry arguments as follows:
如果 WKB 或 SRID 参数为
NULL,则返回值为NULL。If the WKB or SRID argument isNULL, the return value isNULL.默认情况下,地理坐标(纬度,经度)按照几何参数的空间参考系统指定的顺序进行解释。可以提供一个可选的
options参数来覆盖默认的轴顺序。options由用逗号分隔的组成。唯一允许的key=valuekey值是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 optionaloptionsargument may be given to override the default axis order.optionsconsists of a list of comma-separated. The only permittedkey=valuekeyvalue isaxis-order, with permitted values oflat-long,long-latandsrid-defined(the default).如果
options参数为NULL,返回值为NULL。如果options参数无效,将产生错误以说明原因。If theoptionsargument isNULL, the return value isNULL. If theoptionsargument 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), anER_SRS_NOT_FOUNDerror occurs.对于地理 SRS 几何参数,如果任何参数的经度或纬度超出范围,将会发生错误:For geographic SRS geometry arguments, if any argument has a longitude or latitude that is out of range, an error occurs:
如果经度值不在 (−180, 180] 范围内,将会发生
ER_LONGITUDE_OUT_OF_RANGE错误。If a longitude value is not in the range (−180, 180], anER_LONGITUDE_OUT_OF_RANGEerror occurs.如果纬度值不在 [−90, 90] 范围内,将会发生
ER_LATITUDE_OUT_OF_RANGE错误。If a latitude value is not in the range [−90, 90], anER_LATITUDE_OUT_OF_RANGEerror 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.
这些函数可用于从 WKB 值创建几何图形:These functions are available for creating geometries from WKB values:
ST_GeomCollFromWKB(,wkb[,srid[,options]])ST_GeometryCollectionFromWKB(wkb[,srid[,options]])使用其 WKB 表示和 SRID 构建一个
GeometryCollection值。Constructs aGeometryCollectionvalue using its WKB representation and SRID.这些函数按照本节介绍中描述的方式处理它们的参数。These functions handle their arguments as described in the introduction to this section.
ST_GeomFromWKB(,wkb[,srid[,options]])ST_GeometryFromWKB(wkb[,srid[,options]])使用其 WKB 表示和 SRID 构造任何类型的几何值。Constructs a geometry value of any type using its WKB representation and SRID.
这些函数按照本节介绍中描述的方式处理它们的参数。These functions handle their arguments as described in the introduction to this section.
ST_LineFromWKB(,wkb[,srid[,options]])ST_LineStringFromWKB(wkb[,srid[,options]])使用其 WKB 表示和 SRID 构造一个
LineString值。Constructs aLineStringvalue using its WKB representation and SRID.这些函数按照本节介绍中描述的方式处理它们的参数。These functions handle their arguments as described in the introduction to this section.
ST_MLineFromWKB(,wkb[,srid[,options]])ST_MultiLineStringFromWKB(wkb[,srid[,options]])使用其 WKB 表示和 SRID 构造一个
MultiLineString值。Constructs aMultiLineStringvalue using its WKB representation and SRID.这些函数按照本节介绍中描述的方式处理它们的参数。These functions handle their arguments as described in the introduction to this section.
ST_MPointFromWKB(,wkb[,srid[,options]])ST_MultiPointFromWKB(wkb[,srid[,options]])使用其 WKB 表示和 SRID 构造
MultiPoint值。Constructs aMultiPointvalue using its WKB representation and SRID.这些函数按照本节介绍中描述的方式处理它们的参数。These functions handle their arguments as described in the introduction to this section.
ST_MPolyFromWKB(,wkb[,srid[,options]])ST_MultiPolygonFromWKB(wkb[,srid[,options]])使用其 WKB 表示和 SRID 构建
MultiPolygon值。Constructs aMultiPolygonvalue using its WKB representation and SRID.这些函数按照本节介绍中描述的方式处理它们的参数。These functions handle their arguments as described in the introduction to this section.
ST_PointFromWKB(wkb[,srid[,options]])使用其 WKB 表示和 SRID 构建一个
Point值。Constructs aPointvalue using its WKB representation and SRID.ST_PointFromWKB()按本节介绍处理其参数。ST_PointFromWKB()handles its arguments as described in the introduction to this section.ST_PolyFromWKB(,wkb[,srid[,options]])ST_PolygonFromWKB(wkb[,srid[,options]])使用其 WKB 表示和 SRID 构建一个
Polygon值。Constructs aPolygonvalue using its WKB representation and SRID.这些函数按照本节介绍中描述的方式处理它们的参数。These functions handle their arguments as described in the introduction to this section.