A Point
consists of X and Y coordinates, which may be obtained using the ST_X()
and ST_Y()
functions, respectively. Point
由X和Y坐标组成,可以分别使用ST_X()
和ST_Y()
函数获得。These functions also permit an optional second argument that specifies an X or Y coordinate value, in which case the function result is the 这些函数还允许一个可选的第二个参数指定X或Y坐标值,在这种情况下,函数结果是第一个参数的Point
object from the first argument with the appropriate coordinate modified to be equal to the second argument.Point
对象,相应的坐标修改为等于第二个参数。
For 对于具有地理空间参考系(SRS)的点对象,可以分别使用Point
objects that have a geographic spatial reference system (SRS), the longitude and latitude may be obtained using the ST_Longitude()
and ST_Latitude()
functions, respectively. ST_longitude()
和ST_latitude()
函数获取经度和纬度。These functions also permit an optional second argument that specifies a longitude or latitude value, in which case the function result is the 这些函数还允许指定经度或纬度值的可选第二个参数,在这种情况下,函数结果是第一个参数的点对象,经度或纬度修改为等于第二个参数。Point
object from the first argument with the longitude or latitude modified to be equal to the second argument.
Unless otherwise specified, functions in this section handle their geometry arguments as follows:除非另有规定,否则本节中的函数按如下方式处理其几何参数:
If any argument is 如果任一个参数为NULL
, the return value is NULL
.NULL
,则返回值为NULL
。
If any geometry argument is a valid geometry but not a 如果任一个几何体参数是有效的几何体,但不是Point
object, an ER_UNEXPECTED_GEOMETRY_TYPE
error occurs.Point
对象,则会发生ER_UNEXPECTED_GEOMETRY_TYPE
错误。
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
错误。
If an X or Y coordinate argument is provided and the value is 如果提供了X或Y坐标参数,且值为-inf
, +inf
, or NaN
, an ER_DATA_OUT_OF_RANGE
error occurs.-inf
、+inf
或NaN
,则会发生ER_DATA_OUT_OF_RANGE
错误。
If a longitude or latitude value is out of range, an error occurs:如果经度或纬度值超出范围,则会发生错误:
If a longitude value is not in the range (−180, 180], an 如果经度值不在范围(180,180]内,则会发生ER_LONGITUDE_OUT_OF_RANGE
error occurs.ER_LONGITUDE_OUT_OF_RANGE
错误。
If a latitude value is not in the range [−90, 90], an 如果纬度值不在[-90,90]范围内,则会发生ER_LATITUDE_OUT_OF_RANGE
error occurs.ER_LATITUDE_OUT_OF_RANGE
错误。
Ranges shown are in degrees. 显示的范围以度为单位。The exact range limits deviate slightly due to floating-point arithmetic.由于采用浮点运算,精确的范围限制略有偏差。
Otherwise, the return value is non-否则,返回值为非NULL
.NULL
。
These functions are available for obtaining point properties:这些函数可用于获取点特性:
ST_Latitude(
p
[, new_latitude_val
])
With a single argument representing a valid 对于表示具有地理空间参考系(SRS)的有效Point
object p
that has a geographic spatial reference system (SRS), ST_Latitude()
returns the latitude value of p
as a double-precision number.Point
对象p
的单个参数,ST_Latitude()
将p
的纬度值作为双精度数返回。
With the optional second argument representing a valid latitude value, 对于表示有效纬度值的可选第二个参数,ST_Latitude()
returns a Point
object like the first argument with its latitude equal to the second argument.ST_latitude()
返回一个点对象,它与第一个参数类似,纬度等于第二个参数。
ST_Latitude()
handles its arguments as described in the introduction to this section, with the addition that if the Point
object is valid but does not have a geographic SRS, an ER_SRS_NOT_GEOGRAPHIC
error occurs.ST_Latitude()
按本节简介中所述处理其参数,此外,如果Point
对象有效但没有地理SRS,则会发生ER_SRS_NOT_GEOGRAPHIC
错误。
mysql>SET @pt = ST_GeomFromText('POINT(45 90)', 4326);
mysql>SELECT ST_Latitude(@pt);
+------------------+ | ST_Latitude(@pt) | +------------------+ | 45 | +------------------+ mysql>SELECT ST_AsText(ST_Latitude(@pt, 10));
+---------------------------------+ | ST_AsText(ST_Latitude(@pt, 10)) | +---------------------------------+ | POINT(10 90) | +---------------------------------+
This function was added in MySQL 8.0.12.MySQL 8.0.12中增加了这个函数。
ST_Longitude(
p
[, new_longitude_val
])
With a single argument representing a valid 对于表示具有地理空间参考系(SRS)的有效点对象p的单个参数,Point
object p
that has a geographic spatial reference system (SRS), ST_Longitude()
returns the longitude value of p
as a double-precision number.ST_Longitude()
将p
的经度值作为双精度数字返回。
With the optional second argument representing a valid longitude value, 使用表示有效经度值的可选第二个参数,ST_Longitude()
returns a Point
object like the first argument with its longitude equal to the second argument.ST_longitude()
返回一个点对象,该Point
对象与第一个参数类似,其经度等于第二个参数。
ST_Longitude()
handles its arguments as described in the introduction to this section, with the addition that if the Point
object is valid but does not have a geographic SRS, an ER_SRS_NOT_GEOGRAPHIC
error occurs.ST_Longitude()
按本节简介中所述处理其参数,此外,如果Point
对象有效但没有地理SRS,则会发生ER_SRS_NOT_GEOGRAPHIC
错误。
mysql>SET @pt = ST_GeomFromText('POINT(45 90)', 4326);
mysql>SELECT ST_Longitude(@pt);
+-------------------+ | ST_Longitude(@pt) | +-------------------+ | 90 | +-------------------+ mysql>SELECT ST_AsText(ST_Longitude(@pt, 10));
+----------------------------------+ | ST_AsText(ST_Longitude(@pt, 10)) | +----------------------------------+ | POINT(45 10) | +----------------------------------+
This function was added in MySQL 8.0.12.MySQL 8.0.12中增加了这个函数。
With a single argument representing a valid 对于表示有效Point
object p
, ST_X()
returns the X-coordinate value of p
as a double-precision number. Point
对象p
的单个参数,ST_X()
以双精度数字形式返回p
的X坐标值。As of MySQL 8.0.12, the X coordinate is considered to refer to the axis that appears first in the 从MySQL8.0.12开始,X坐标被认为是指在Point
spatial reference system (SRS) definition.Point
空间参考系(SRS)定义中首先出现的轴。
With the optional second argument, 对于可选的第二个参数,ST_X()
returns a Point
object like the first argument with its X coordinate equal to the second argument. ST_X()
返回与第一个参数类似的点对象,其X坐标等于第二个参数。As of MySQL 8.0.12, if the 从MySQL8.0.12开始,如果Point
object has a geographic SRS, the second argument must be in the proper range for longitude or latitude values.Point
对象具有地理SRS,则第二个参数必须在经度或纬度值的适当范围内。
ST_X()
handles its arguments as described in the introduction to this section.ST_X()
处理其参数,如本节简介中所述。
mysql>SELECT ST_X(Point(56.7, 53.34));
+--------------------------+ | ST_X(Point(56.7, 53.34)) | +--------------------------+ | 56.7 | +--------------------------+ mysql>SELECT ST_AsText(ST_X(Point(56.7, 53.34), 10.5));
+-------------------------------------------+ | ST_AsText(ST_X(Point(56.7, 53.34), 10.5)) | +-------------------------------------------+ | POINT(10.5 53.34) | +-------------------------------------------+
With a single argument representing a valid 对于表示有效点对象Point
object p
, ST_Y()
returns the Y-coordinate value of p
as a double-precision number. p
的单个参数,ST_Y()
以双精度数字形式返回p
的Y坐标值。As of MySQL 8.0.12, the Y coordinate is considered to refer to the axis that appears second in the 从MySQL8.0.12开始,Y坐标被认为是指在Point
spatial reference system (SRS) definition.Point
空间参考系(SRS)定义中出现的第二个轴。
With the optional second argument, 对于可选的第二个参数,ST_Y()
returns a Point
object like the first argument with its Y coordinate equal to the second argument. ST_Y()
返回与第一个参数类似的Point
对象,其Y坐标等于第二个参数。As of MySQL 8.0.12, if the 从MySQL8.0.12开始,如果Point
object has a geographic SRS, the second argument must be in the proper range for longitude or latitude values.Point
对象具有地理SRS,则第二个参数必须在经度或纬度值的适当范围内。
ST_Y()
handles its arguments as described in the introduction to this section.ST_Y()
处理其参数,如本节简介中所述。
mysql>SELECT ST_Y(Point(56.7, 53.34));
+--------------------------+ | ST_Y(Point(56.7, 53.34)) | +--------------------------+ | 53.34 | +--------------------------+ mysql>SELECT ST_AsText(ST_Y(Point(56.7, 53.34), 10.5));
+-------------------------------------------+ | ST_AsText(ST_Y(Point(56.7, 53.34), 10.5)) | +-------------------------------------------+ | POINT(56.7 10.5) | +-------------------------------------------+