Functions in this section return properties of 本节中的函数返回Polygon
or MultiPolygon
values.Polygon
或MultiPolygon
值的属性。
Unless otherwise specified, functions in this section handle their geometry arguments as follows:除非另有规定,否则本节中的函数按如下方式处理其几何参数:
If any argument is 如果任一个参数为NULL
or any geometry argument is an empty geometry, the return value is NULL
.NULL
或任一个几何体参数为空几何体,则返回值为NULL
。
If any geometry argument is not a syntactically well-formed geometry, an 如果任一个几何参数不是语法格式良好的几何体,则会发生ER_GIS_INVALID_DATA
error occurs.ER_GIS_INVALID_DATA
错误。
If any geometry argument is a syntactically well-formed geometry in an undefined spatial reference system (SRS), an 如果任何几何体参数是未定义空间参考系(SRS)中语法结构良好的几何体,则会发生ER_SRS_NOT_FOUND
error occurs.ER_SRS_NOT_FOUND
错误。
For functions that take multiple geometry arguments, if those arguments are not in the same SRS, an 对于采用多个几何参数的函数,如果这些参数不在同一SRS中,则会发生ER_GIS_DIFFERENT_SRIDS
error occurs.ER_GIS_DIFFERENT_SRIDS
错误。
Otherwise, the return value is non-否则,返回值为非NULL
.NULL
。
These functions are available for obtaining polygon properties:这些函数可用于获取多边形特性:
Returns a double-precision number indicating the area of the 返回一个双精度数字,该数字指示在空间参照系中测量的Polygon
or MultiPolygon
argument, as measured in its spatial reference system.Polygon
或Myltipolygon
参数的面积。
As of MySQL 8.0.13, 从MySQL8.0.13开始,ST_Area()
handles its arguments as described in the introduction to this section, with these exceptions:ST_Area()
将按照本节简介中所述处理其参数,但有以下例外:
If the geometry is geometrically invalid, either the result is an undefined area (that is, it can be any number), or an error occurs.如果几何图形在几何上无效,则结果可能是未定义的区域(即,它可以是任何数字),或者发生错误。
If the geometry is valid but is not a 如果几何体有效,但不是Polygon
or MultiPolygon
object, an ER_UNEXPECTED_GEOMETRY_TYPE
error occurs.Polygon
或MultiPolygon
对象,则会发生ER_UNEXPECTED_GEOMETRY_TYPE
错误。
If the geometry is a valid 如果几何体是笛卡尔SRS中的有效Polygon
in a Cartesian SRS, the result is the Cartesian area of the polygon.Polygon
,则结果是多边形的笛卡尔面积。
If the geometry is a valid 如果几何体是笛卡尔SRS中的有效MultiPolygon
in a Cartesian SRS, the result is the sum of the Cartesian area of the polygons.MultiPolygon
,则结果是多边形的笛卡尔面积之和。
If the geometry is a valid 如果几何体是地理SRS中的有效Polygon
in a geographic SRS, the result is the geodetic area of the polygon in that SRS, in square meters.Polygon
,则结果是该SRS中多边形的大地测量面积,单位为平方米。
If the geometry is a valid 如果几何体是地理SRS中的有效MultiPolygon
in a geographic SRS, the result is the sum of geodetic area of the polygons in that SRS, in square meters.MultiPolygon
,则结果是该SRS中多边形的大地测量面积之和(以平方米为单位)。
If an area computation results in 如果面积计算结果为+inf
, an ER_DATA_OUT_OF_RANGE
error occurs.+inf
,则会发生ER_DATA_OUT_OF_RANGE
错误。
If the geometry has a geographic SRS with 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_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE
error occurs (ER_LONGITUDE_OUT_OF_RANGE
prior to MySQL 8.0.12).ER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE
错误(在MySQL 8.0.12之前发生ER_LONGITUDE_OUT_OF_RANGE
错误)。
If a latitude value is not in the range [−90, 90], an 如果纬度值不在范围[-90,90]内,则会发生ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE
error occurs (ER_LATITUDE_OUT_OF_RANGE
prior to MySQL 8.0.12).ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE
错误(在MySQL 8.0.12之前发生ER_LATITUDE_OUT_OF_RANGE
错误)。
Ranges shown are in degrees. 显示的范围以度为单位。The exact range limits deviate slightly due to floating-point arithmetic.由于采用浮点运算,精确的范围限制略有偏差。
Prior to MySQL 8.0.13, 在MySQL8.0.13之前,ST_Area()
handles its arguments as described in the introduction to this section, with these exceptions:ST_Area()
按照本节简介中所述处理其参数,但有以下例外:
For arguments of dimension 0 or 1, the result is 0.对于维度为0或1的参数,结果为0。
If a geometry is empty, the return value is 0 rather than 如果几何体为空,则返回值为0而不是NULL
.NULL
。
For a geometry collection, the result is the sum of the area values of all components. 对于几何图形集合,结果是所有组件的面积值之和。If the geometry collection is empty, its area is returned as 0.如果几何体集合为空,则其区域返回为0。
If the geometry has an SRID value for a geographic spatial reference system (SRS), an 如果几何体具有地理空间参考系(SRS)的SRID值,则会发生ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
error occurs.ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
错误。
mysql>SET @poly =
'Polygon((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))';
mysql>SELECT ST_Area(ST_GeomFromText(@poly));
+---------------------------------+ | ST_Area(ST_GeomFromText(@poly)) | +---------------------------------+ | 4 | +---------------------------------+ mysql>SET @mpoly =
'MultiPolygon(((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1)))';
mysql>SELECT ST_Area(ST_GeomFromText(@mpoly));
+----------------------------------+ | ST_Area(ST_GeomFromText(@mpoly)) | +----------------------------------+ | 8 | +----------------------------------+
Returns the mathematical centroid for the 返回Polygon
or MultiPolygon
argument as a Point
. Polygon
或MultiPolygon
参数的数学质心,形式为Point
。The result is not guaranteed to be on the 结果不一定是在MultiPolygon
.MultiPolygon
上。
This function processes geometry collections by computing the centroid point for components of highest dimension in the collection. 此函数通过计算集合中维度最高的组件的质心点来处理几何体集合。Such components are extracted and made into a single 这样的组件被提取出来,并形成一个质心计算的单一的MultiPolygon
, MultiLineString
, or MultiPoint
for centroid computation.MultiPolygon
、MultiLineString
,或MultiPoint
。
ST_Centroid()
handles its arguments as described in the introduction to this section, with these exceptions:ST_Centroid()
按本节简介中所述处理其参数,但有以下例外:
The return value is 对于参数为空几何体集合的附加条件,返回值为NULL
for the additional condition that the argument is an empty geometry collection.NULL
。
If the geometry has an SRID value for a geographic spatial reference system (SRS), an 如果几何体具有地理空间参考系(SRS)的SRID值,则会发生ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
error occurs.ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
错误。
mysql>SET @poly =
ST_GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7,5 5))');
mysql>SELECT ST_GeometryType(@poly),ST_AsText(ST_Centroid(@poly));
+------------------------+--------------------------------------------+ | ST_GeometryType(@poly) | ST_AsText(ST_Centroid(@poly)) | +------------------------+--------------------------------------------+ | POLYGON | POINT(4.958333333333333 4.958333333333333) | +------------------------+--------------------------------------------+
Returns the exterior ring of the 以Polygon
value poly
as a LineString
.LineString
形式返回Polygon
值poly
的外环。
ST_ExteriorRing()
handles its arguments as described in the introduction to this section.ST_ExteriorRing()
处理其参数,如本节简介中所述。
mysql>SET @poly =
'Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))';
mysql>SELECT ST_AsText(ST_ExteriorRing(ST_GeomFromText(@poly)));
+----------------------------------------------------+ | ST_AsText(ST_ExteriorRing(ST_GeomFromText(@poly))) | +----------------------------------------------------+ | LINESTRING(0 0,0 3,3 3,3 0,0 0) | +----------------------------------------------------+
Returns the 将N
-th interior ring for the Polygon
value poly
as a LineString
. Polygon
值poly
的第N
个内环以LineString
的形式返回。Rings are numbered beginning with 1.环以1开始编号。
ST_InteriorRingN()
handles its arguments as described in the introduction to this section.ST_InteriorRingN()
处理其参数,如本节简介中所述。
mysql>SET @poly =
'Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))';
mysql>SELECT ST_AsText(ST_InteriorRingN(ST_GeomFromText(@poly),1));
+-------------------------------------------------------+ | ST_AsText(ST_InteriorRingN(ST_GeomFromText(@poly),1)) | +-------------------------------------------------------+ | LINESTRING(1 1,1 2,2 2,2 1,1 1) | +-------------------------------------------------------+
ST_NumInteriorRing(
, poly
)ST_NumInteriorRings(
poly
)
Returns the number of interior rings in the 返回Polygon
value poly
.Polygon
值poly
中内环的数目。
ST_NumInteriorRing()
and ST_NuminteriorRings()
handle their arguments as described in the introduction to this section.ST_NumInteriorRing()
和ST_NuminteriorRings()
处理其参数,如本节简介中所述。
mysql>SET @poly =
'Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))';
mysql>SELECT ST_NumInteriorRings(ST_GeomFromText(@poly));
+---------------------------------------------+ | ST_NumInteriorRings(ST_GeomFromText(@poly)) | +---------------------------------------------+ | 1 | +---------------------------------------------+