MySQL 提供了一组用于创建几何值的有用非标准函数。本节中描述的函数是 MySQL 对 OpenGIS 规范的扩展。MySQL provides a set of useful nonstandard functions for creating geometry values. The functions described in this section are MySQL extensions to the OpenGIS specification.
这些函数根据 WKB 值或几何对象作为参数生成几何对象。如果任何参数不是正确的 WKB 或适当类型的几何表示,则返回值为 NULL。These functions produce geometry objects from either WKB values or
geometry objects as arguments. If any argument is not a proper WKB
or geometry representation of the proper object type, the return
value is NULL.
例如,你可以将 Point() 的几何返回值直接插入到 POINT 列中:For example, you can insert the geometry return value from
Point() directly into a
POINT column:
INSERT INTO t1 (pt_col) VALUES(Point(1,2));
根据几何参数构造一个
GeomCollection值。Constructs aGeomCollectionvalue from the geometry arguments.GeomCollection()返回参数中包含的所有有效几何,即使存在不支持的几何也会返回有效几何。GeomCollection()returns all the proper geometries contained in the arguments even if a nonsupported geometry is present.GeomCollection()不带参数也是允许的,可用于创建一个空几何。此外,像ST_GeomFromText()这样的函数接受 WKT 几何集合参数,可以理解 OpenGIS'GEOMETRYCOLLECTION EMPTY'标准语法和 MySQL'GEOMETRYCOLLECTION()'非标准语法。GeomCollection()with no arguments is permitted as a way to create an empty geometry. Also, functions such asST_GeomFromText()that accept WKT geometry collection arguments understand both OpenGIS'GEOMETRYCOLLECTION EMPTY'standard syntax and MySQL'GEOMETRYCOLLECTION()'nonstandard syntax.GeomCollection()和GeometryCollection()是同义词,其中GeomCollection()是首选函数。GeomCollection()andGeometryCollection()are synonymous, withGeomCollection()the preferred function.GeometryCollection(g[,g] ...)根据几何参数构造一个
GeomCollection值。Constructs aGeomCollectionvalue from the geometry arguments.GeometryCollection()返回参数中包含的所有有效几何,即使存在不支持的几何。GeometryCollection()returns all the proper geometries contained in the arguments even if a nonsupported geometry is present.GeometryCollection()不带参数是允许的,这是一种创建空几何图形的方法。此外,像ST_GeomFromText()这样的函数接受 WKT 几何集合参数,它们既能理解 OpenGIS'GEOMETRYCOLLECTION EMPTY'标准语法,也能理解 MySQL'GEOMETRYCOLLECTION()'非标准语法。GeometryCollection()with no arguments is permitted as a way to create an empty geometry. Also, functions such asST_GeomFromText()that accept WKT geometry collection arguments understand both OpenGIS'GEOMETRYCOLLECTION EMPTY'standard syntax and MySQL'GEOMETRYCOLLECTION()'nonstandard syntax.GeomCollection()和GeometryCollection()是同义词,其中GeomCollection()是首选函数。GeomCollection()andGeometryCollection()are synonymous, withGeomCollection()the preferred function.从若干个
Point或 WKBPoint参数构造一个LineString值。如果参数数量少于两个,返回值为NULL。Constructs aLineStringvalue from a number ofPointor WKBPointarguments. If the number of arguments is less than two, the return value isNULL.MultiLineString(ls[,ls] ...)使用
LineString或 WKBLineString参数构造一个MultiLineString值。Constructs aMultiLineStringvalue usingLineStringor WKBLineStringarguments.使用
Point或 WKBPoint参数构建MultiPoint值。Constructs aMultiPointvalue usingPointor WKBPointarguments.MultiPolygon(poly[,poly] ...)从一组
Polygon或 WKBPolygon参数构建MultiPolygon值。Constructs aMultiPolygonvalue from a set ofPolygonor WKBPolygonarguments.使用坐标构建
Point。Constructs aPointusing its coordinates.从多个
LineString或 WKBLineString参数构造一个Polygon值。如果任何参数不表示LinearRing(即非闭合且简单的LineString),则返回值为NULL。Constructs aPolygonvalue from a number ofLineStringor WKBLineStringarguments. If any argument does not represent aLinearRing(that is, not a closed and simpleLineString), the return value isNULL.