OpenGIS proposes a number of functions that can produce geometries. OpenGIS提出了许多可以生成几何图形的函数。They are designed to implement spatial operators. 它们被设计用来实现空间操作符。These functions support all argument type combinations except those that are inapplicable according to the Open Geospatial Consortium specification.这些函数支持所有参数类型组合,但根据开放地理空间联盟规范不适用的参数类型组合除外。
MySQL also implements certain functions that are extensions to OpenGIS, as noted in the function descriptions. MySQL还实现了某些函数,这些函数是OpenGIS的扩展,如函数描述中所述。In addition, Section 12.17.7, “Geometry Property Functions”, discusses several functions that construct new geometries from existing ones. 此外,第12.17.7节,“几何特性函数”讨论了从现有几何构造新几何的几个函数。See that section for descriptions of these functions:有关这些功能的说明,请参见该部分:
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 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
错误。
If any geometry argument has an SRID value for a geographic SRS and the function does not handle geographic geometries, an 如果任何geometry参数具有地理SRS的SRID值,并且函数不处理地理几何体,则会发生ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
error occurs.ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
错误。
For geographic SRS geometry arguments, if any argument has 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. 显示的范围以度为单位。If an SRS uses another unit, the range uses the corresponding values in its unit. 如果SRS使用另一个单位,则范围使用其单位中的相应值。The exact range limits deviate slightly due to floating-point arithmetic.由于采用浮点运算,精确的范围限制略有偏差。
Otherwise, the return value is non-否则,返回值为非NULL
.NULL
。
These spatial operator functions are available:这些空间运算符功能可用:
ST_Buffer(
g
, d
[, strategy1
[, strategy2
[, strategy3
]]])
Returns a geometry that represents all points whose distance from the geometry value 返回一个几何体,它表示与几何体值g
is less than or equal to a distance of d
. g
的距离小于或等于d
的所有点。The result is in the same SRS as the geometry argument.结果与geometry参数的SRS相同。
If the geometry argument is empty, 如果几何体参数为空,则ST_Buffer()
returns an empty geometry.ST_Buffer()
返回一个空的几何体。
If the distance is 0, 如果距离为0,则ST_Buffer()
returns the geometry argument unchanged:ST_Buffer()
原封不动地返回几何体参数:
mysql>SET @pt = ST_GeomFromText('POINT(0 0)');
mysql>SELECT ST_AsText(ST_Buffer(@pt, 0));
+------------------------------+ | ST_AsText(ST_Buffer(@pt, 0)) | +------------------------------+ | POINT(0 0) | +------------------------------+
If the geometry argument is in a Cartesian SRS:如果几何参数在笛卡尔坐标系中:
stu ST_Buffer()
supports negative distances for Polygon
and MultiPolygon
values, and for geometry collections containing Polygon
or MultiPolygon
values.Buffer()
支持Polygon
和MultiPolygon
值以及包含Polygon
或MultiPolygon
值的几何体集合的负距离。
If the result is reduced so much that that it disappears, the result is an empty geometry.如果结果减少得太多以至于消失,则结果是一个空几何体。
An 对于ER_WRONG_ARGUMENTS
error occurs for ST_Buffer()
with a negative distance for Point
, MultiPoint
, LineString
, and MultiLineString
values, and for geometry collections not containing any Polygon
or MultiPolygon
values.Point
、MultiPoint
、LineString
和MultiLineString
值的距离为负的ST_Buffer()
,以及不包含任何Polygon
或MultiPolygon
值的几何体集合,会发生ER_WRONG_ARGUMENTS
错误。
If the geometry argument is in a geographic SRS:如果几何体参数位于地理区域中:
Prior to MySQL 8.0.26, an 在MySQL8.0.26之前,会出现ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
error occurs.ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
错误。
As of MySQL 8.0.26, 从MySQL8.0.26开始,允许使用地理SRS中的Point
geometries in a geographic SRS are permitted. Point
几何体。For non-对于非Point
geometries, an ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
error still occurs.Point
几何体,仍然会发生ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
错误。
For MySQL versions that permit geographic 对于允许地理Point
geometries:Point
几何图形的MySQL版本:
If the distance is not negative and no strategies are specified, the function returns the geographic buffer of the 如果距离不是负数并且没有指定策略,则函数返回SRS中该Point
in its SRS. Point
的地理缓冲区。The distance argument must be in the SRS distance unit (currently always meters).距离参数必须以SRS距离单位为单位(当前始终为米)。
If the distance is negative or any strategy (except 如果距离为负数或指定了任何策略(NULL
) is specified, an ER_WRONG_ARGUMENTS
error occurs.NULL
除外),则会发生ER_WRONG_ARGUMENTS
错误。
ST_Buffer()
permits up to three optional strategy arguments following the distance argument. ST_Buffer()
允许在距离参数之后最多有三个可选策略参数。Strategies influence buffer computation. 策略影响缓冲区计算。These arguments are byte string values produced by the 这些参数是由ST_Buffer_Strategy()
function, to be used for point, join, and end strategies:ST_Buffer_Strategy()
函数生成的字节字符串值,用于点、连接和末端策略:
Point strategies apply to 点策略适用于Point
and MultiPoint
geometries. Point
和MultiPoint
几何体。If no point strategy is specified, the default is 如果未指定点策略,则默认值为ST_Buffer_Strategy('point_circle', 32)
.ST_Buffer_Strategy('point_circle', 32)
。
Join strategies apply to 连接策略适用于LineString
, MultiLineString
, Polygon
, and MultiPolygon
geometries. LineString
、MultiLineString
、Polygon
和MultiPolygon
几何体。If no join strategy is specified, the default is 如果未指定连接策略,则默认值为ST_Buffer_Strategy('join_round', 32)
.ST_Buffer_Strategy('join_round', 32)
。
End strategies apply to 末端策略适用于LineString
and MultiLineString
geometries. LineString
和MultiLineString
几何体。If no end strategy is specified, the default is 如果未指定结束策略,则默认值为ST_Buffer_Strategy('end_round', 32)
.ST_Buffer_Strategy('end_round', 32)
。
Up to one strategy of each type may be specified, and they may be given in any order.每种类型最多可以指定一种策略,并且可以按任意顺序给出。
If the buffer strategies are invalid, an 如果缓冲区策略无效,则会发生ER_WRONG_ARGUMENTS
error occurs. ER_WRONG_ARGUMENTS
错误。Strategies are invalid under any of these circumstances:在下列任何情况下,策略都是无效的:
Multiple strategies of a given type (point, join, or end) are specified.指定了给定类型(点、连接或结束)的多个策略。
A value that is not a strategy (such as an arbitrary binary string or a number) is passed as a strategy.不是策略的值(如任意二进制字符串或数字)作为策略传递。
A 传Point
strategy is passed and the geometry contains no Point
or MultiPoint
values.Point
策略,并且几何体不包含Point
或MultiPoint
值。
An end or join strategy is passed and the geometry contains no 传递末端策略或连接策略,并且几何体不包含LineString
, Polygon
, MultiLinestring
or MultiPolygon
values.LineString
、Polygon
、MultiLineString
或MultiPolygon
值。
mysql>SET @pt = ST_GeomFromText('POINT(0 0)');
mysql>SET @pt_strategy = ST_Buffer_Strategy('point_square');
mysql>SELECT ST_AsText(ST_Buffer(@pt, 2, @pt_strategy));
+--------------------------------------------+ | ST_AsText(ST_Buffer(@pt, 2, @pt_strategy)) | +--------------------------------------------+ | POLYGON((-2 -2,2 -2,2 2,-2 2,-2 -2)) | +--------------------------------------------+
mysql>SET @ls = ST_GeomFromText('LINESTRING(0 0,0 5,5 5)');
mysql>SET @end_strategy = ST_Buffer_Strategy('end_flat');
mysql>SET @join_strategy = ST_Buffer_Strategy('join_round', 10);
mysql>SELECT ST_AsText(ST_Buffer(@ls, 5, @end_strategy, @join_strategy))
+---------------------------------------------------------------+ | ST_AsText(ST_Buffer(@ls, 5, @end_strategy, @join_strategy)) | +---------------------------------------------------------------+ | POLYGON((5 5,5 10,0 10,-3.5355339059327373 8.535533905932738, | | -5 5,-5 0,0 0,5 0,5 5)) | +---------------------------------------------------------------+
ST_Buffer_Strategy(
strategy
[, points_per_circle
])
This function returns a strategy byte string for use with 此函数返回一个策略字节字符串,与ST_Buffer()
to influence buffer computation.ST_Buffer()
一起使用以影响缓冲区计算。
Information about strategies is available at Boost.org.有关战略的信息,请访问Boost.org。
The first argument must be a string indicating a strategy option:第一个参数必须是表示策略选项的字符串:
For point strategies, permitted values are 对于点策略,允许的值是'point_circle'
and 'point_square'
.'point_circle'
和'point_square'
。
For join strategies, permitted values are 对于连接策略,允许的值为'join_round'
and 'join_miter'
.'join_round'
和'join_miter'
。
For end strategies, permitted values are 对于结束策略,允许的值为'end_round'
and 'end_flat'
.'end_round'
和'end_flat'
。
If the first argument is 如果第一个参数是'point_circle'
, 'join_round'
, 'join_miter'
, or 'end_round'
, the points_per_circle
argument must be given as a positive numeric value. 'point_circle'
、'join_round'
、'join_miter'
或'end_round'
,则必须将points_per_circle
参数指定为正数值。The maximum points_per_circle
value is the value of the max_points_in_geometry
system variable.points_per_circle
值是max_points_in_geometry
系统变量的值。
For examples, see the description of 有关示例,请参见ST_Buffer()
.ST_Buffer()
的说明。
ST_Buffer_Strategy()
handles its arguments as described in the introduction to this section, with these exceptions:ST_Buffer_Strategy()
按本节简介中所述处理其参数,但有以下例外:
If any argument is invalid, an 如果任何参数无效,则会发生ER_WRONG_ARGUMENTS
error occurs.ER_WRONG_ARGUMENTS
错误。
If the first argument is 如果第一个参数是'point_square'
or 'end_flat'
, the points_per_circle
argument must not be given or an ER_WRONG_ARGUMENTS
error occurs.'point_square'
或'end_flat'
,则不能给出points_per_circle
参数,否则会出现ER_WRONG_ARGUMENTS
错误。
Returns a geometry that represents the convex hull of the geometry value 返回表示几何体值g
.g
的凸包的几何体。
This function computes a geometry's convex hull by first checking whether its vertex points are colinear. 此函数通过首先检查几何体的顶点是否共线来计算几何体的凸包。The function returns a linear hull if so, a polygon hull otherwise. 该函数返回线性外壳(如果是),否则返回多边形外壳。This function processes geometry collections by extracting all vertex points of all components of the collection, creating a 此函数通过提取集合所有组件的所有顶点、从中创建MultiPoint
value from them, and computing its convex hull.MultiPoint
值并计算其凸包来处理几何体集合。
ST_ConvexHull()
handles its arguments as described in the introduction to this section, with this exception:ST_ConvexHull()
按本节简介中所述处理其参数,但有以下例外:
The return value is 对于参数为空几何体集合的附加条件,返回值为NULL
for the additional condition that the argument is an empty geometry collection.NULL
。
mysql>SET @g = 'MULTIPOINT(5 0,25 0,15 10,15 25)';
mysql>SELECT ST_AsText(ST_ConvexHull(ST_GeomFromText(@g)));
+-----------------------------------------------+ | ST_AsText(ST_ConvexHull(ST_GeomFromText(@g))) | +-----------------------------------------------+ | POLYGON((5 0,25 0,15 25,5 0)) | +-----------------------------------------------+
Returns a geometry that represents the point set difference of the geometry values 返回表示几何图形值g1
and g2
. g1
和g2
的点集差的几何图形。The result is in the same SRS as the geometry arguments.结果与几何参数的SRS相同。
As of MySQL 8.0.26, 从MySQL 8.0.26开始,ST_Difference()
permits arguments in either a Cartesian or a geographic SRS. ST_Difference()
允许使用笛卡尔或地理坐标系中的参数。Prior to MySQL 8.0.26, 在MySQL8.0.26之前,ST_Difference()
permits arguments in a Cartesian SRS only; for arguments in a geographic SRS, an ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
error occurs.ST_Difference()
只允许笛卡尔SRS中的参数;对于地理SRS中的参数,会发生ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
错误。
ST_Difference()
handles its arguments as described in the introduction to this section.ST_Difference()
处理其参数,如本节简介中所述。
mysql>SET @g1 = Point(1,1), @g2 = Point(2,2);
mysql>SELECT ST_AsText(ST_Difference(@g1, @g2));
+------------------------------------+ | ST_AsText(ST_Difference(@g1, @g2)) | +------------------------------------+ | POINT(1 1) | +------------------------------------+
Returns a geometry that represents the point set intersection of the geometry values 返回表示几何图形值g1
and g2
. g1
和g2
的点集交点的几何图形。The result is in the same SRS as the geometry arguments.结果与几何参数的SRS相同。
As of MySQL 8.0.27, 从MySQL 8.0.27开始,ST_Intersection()
permits arguments in either a Cartesian or a geographic SRS. ST_Intersection()
允许使用笛卡尔或地理坐标系中的参数。Prior to MySQL 8.0.27, 在MySQL8.0.27之前,ST_Intersection()
permits arguments in a Cartesian SRS only; for arguments in a geographic SRS, an ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
error occurs.ST_Intersection()
只允许笛卡尔SRS中的参数;对于地理SRS中的参数,会发生ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
错误。
ST_Intersection()
handles its arguments as described in the introduction to this section.ST_Intersection()
处理其参数,如本节简介中所述。
mysql>SET @g1 = ST_GeomFromText('LineString(1 1, 3 3)');
mysql>SET @g2 = ST_GeomFromText('LineString(1 3, 3 1)');
mysql>SELECT ST_AsText(ST_Intersection(@g1, @g2));
+--------------------------------------+ | ST_AsText(ST_Intersection(@g1, @g2)) | +--------------------------------------+ | POINT(2 2) | +--------------------------------------+
ST_LineInterpolatePoint(
ls
, fractional_distance
)
This function takes a 此函数用于获取LineString
geometry and a fractional distance in the range [0.0, 1.0] and returns the Point
along the LineString
at the given fraction of the distance from its start point to its endpoint. LineString
几何体和[0.0,1.0]范围内的分数距离,并返回线串上从起点到终点距离的给定分数处的点。It can be used to answer questions such as which 它可以用来回答诸如哪一个Point
lies halfway along the road described by the geometry argument.Point
位于几何体参数所描述的道路的中间等问题。
The function is implemented for 该函数用于所有空间参考系(包括笛卡尔坐标系和地理坐标系)中的LineString
geometries in all spatial reference systems, both Cartesian and geographic.LineString
几何体。
If the 如果fractional_distance
argument is 1.0, the result may not be exactly the last point of the LineString
argument but a point close to it due to numerical inaccuracies in approximate-value computations.fractional_distance
参数为1.0,则由于近似值计算中的数值不准确,结果可能不是LineString
参数的最后一个点,而是接近它的点。
A related function, 一个相关的函数,ST_LineInterpolatePoints()
, takes similar arguments but returns a MultiPoint
consisting of Point
values along the LineString
at each fraction of the distance from its start point to its endpoint. ST_LineInterpolatePoints()
,接受类似的参数,但返回一个多点,该多点由从起点到终点的距离的每一个分数处的线串上的点值组成。For examples of both functions, see the 有关这两个函数的示例,请参见ST_LineInterpolatePoints()
description.ST_LineInterpolatePoints()
说明。
ST_LineInterpolatePoint()
handles its arguments as described in the introduction to this section, with these exceptions:ST_LineInterpolatePoint()
按照本节简介中所述处理其参数,但有以下例外:
If the geometry argument is not a 如果几何体参数不是LineString
, an ER_UNEXPECTED_GEOMETRY_TYPE
error occurs.LineString
,则会发生ER_UNEXPECTED_GEOMETRY_TYPE
错误。
If the fractional distance argument is outside the range [0.0, 1.0], an 如果分数距离参数超出范围[0.0, 1.0],则会发生ER_DATA_OUT_OF_RANGE
error occurs.ER_DATA_OUT_OF_RANGE
错误。
ST_LineInterpolatePoint()
is a MySQL extension to OpenGIS. ST_LineInterpolatePoint()
是OpenGIS的MySQL扩展。This function was added in MySQL 8.0.24.MySQL 8.0.24中增加了这个函数。
ST_LineInterpolatePoints(
ls
, fractional_distance
)
This function takes a 此函数获取范围(0.0,1.0)内的LineString
geometry and a fractional distance in the range (0.0, 1.0] and returns the MultiPoint
consisting of the LineString
start point, plus Point
values along the LineString
at each fraction of the distance from its start point to its endpoint. LineString
几何图形和分数距离,并返回由LineString
起点组成的MultiPoint
,以及从LineString
起点到LineString
终点的每一分数处沿LineString
的Point
值。It can be used to answer questions such as which 它可以用来回答一些问题,比如几何参数描述的道路沿线每10%就有哪些Point
values lie every 10% of the way along the road described by the geometry argument.Point
值。
The function is implemented for 该函数用于所有空间参考系(包括笛卡尔坐标系和地理坐标系)中的线串几何图形。LineString
geometries in all spatial reference systems, both Cartesian and geographic.
If the 如果fractional_distance
argument divides 1.0 with zero remainder the result may not contain the last point of the LineString
argument but a point close to it due to numerical inaccuracies in approximate-value computations.fractional_distance
参数除以1.0,余数为零,则结果可能不包含LineString
参数的最后一点,而是由于近似值计算中的数值不准确而接近它的一点。
A related function, 一个相关的函数,ST_LineInterpolatePoint()
, takes similar arguments but returns the Point
along the LineString
at the given fraction of the distance from its start point to its endpoint.ST_LineInterpolatePoint()
,接受类似的参数,但返回从起点到终点的距离的给定分数处的LineString
的Point
。
ST_LineInterpolatePoints()
handles its arguments as described in the introduction to this section, with these exceptions:ST_LineInterpolatePoints()
处理其参数,如本节简介中所述,但有以下例外:
If the geometry argument is not a 如果几何体参数不是LineString
, an ER_UNEXPECTED_GEOMETRY_TYPE
error occurs.LineString
,则会发生ER_UNEXPECTED_GEOMETRY_TYPE
错误。
If the fractional distance argument is outside the range [0.0, 1.0], an 如果分数距离参数超出范围[0.0,1.0],则会发生ER_DATA_OUT_OF_RANGE
error occurs.ER_DATA_OUT_OF_RANGE
错误。
mysql>SET @ls1 = ST_GeomFromText('LINESTRING(0 0,0 5,5 5)');
mysql>SELECT ST_AsText(ST_LineInterpolatePoint(@ls1, .5));
+----------------------------------------------+ | ST_AsText(ST_LineInterpolatePoint(@ls1, .5)) | +----------------------------------------------+ | POINT(0 5) | +----------------------------------------------+ mysql>SELECT ST_AsText(ST_LineInterpolatePoint(@ls1, .75));
+-----------------------------------------------+ | ST_AsText(ST_LineInterpolatePoint(@ls1, .75)) | +-----------------------------------------------+ | POINT(2.5 5) | +-----------------------------------------------+ mysql>SELECT ST_AsText(ST_LineInterpolatePoint(@ls1, 1));
+---------------------------------------------+ | ST_AsText(ST_LineInterpolatePoint(@ls1, 1)) | +---------------------------------------------+ | POINT(5 5) | +---------------------------------------------+ mysql>SELECT ST_AsText(ST_LineInterpolatePoints(@ls1, .25));
+------------------------------------------------+ | ST_AsText(ST_LineInterpolatePoints(@ls1, .25)) | +------------------------------------------------+ | MULTIPOINT((0 2.5),(0 5),(2.5 5),(5 5)) | +------------------------------------------------+
ST_LineInterpolatePoints()
is a MySQL extension to OpenGIS. ST_LineInterpolatePoints()
是OpenGIS的MySQL扩展。This function was added in MySQL 8.0.24.MySQL 8.0.24中增加了这个函数。
ST_PointAtDistance(
ls
, distance
)
This function takes a 此函数获LineString
geometry and a distance in the range [0.0, ST_Length(
] measured in the unit of the spatial reference system (SRS) of the ls
)LineString
, and returns the Point
along the LineString
at that distance from its start point. LineString
的几何体和范围[0.0,ST_Length(ls)
]内的距离(以线串的空间参考系(SRS)为单位),并返回线串上距离其起点的点。It can be used to answer questions such as which 它可以用来回答一些问题,例如哪个Point
value is 400 meters from the start of the road described by the geometry argument.Point
值是从几何参数描述的道路起点算起的400米。
The function is implemented for 该函数用于所有空间参考系(包括笛卡尔坐标系和地理坐标系)中的LineString
geometries in all spatial reference systems, both Cartesian and geographic.LineString
几何体。
ST_PointAtDistance()
handles its arguments as described in the introduction to this section, with these exceptions:ST_PointAtDistance()
按本节简介中所述处理其参数,但有以下例外:
If the geometry argument is not a 如果几何体参数不是LineString
, an ER_UNEXPECTED_GEOMETRY_TYPE
error occurs.LineString
,则会发生ER_UNEXPECTED_GEOMETRY_TYPE
错误。
If the fractional distance argument is outside the range [0.0, 如果分数距离参数超出范围[0.0,ST_Length(
], an ls
)ER_DATA_OUT_OF_RANGE
error occurs.ST_Length(ls)
],则会发生ER_DATA_OUT_OF_RANGE
错误。
ST_PointAtDistance()
is a MySQL extension to OpenGIS. ST_PointAtDistance()
是OpenGIS的MySQL扩展。This function was added in MySQL 8.0.24.MySQL 8.0.24中增加了这个函数。
Returns a geometry that represents the point set symmetric difference of the geometry values 返回表示几何图形值g1
and g2
, which is defined as:g1
和g2
的点集对称差的几何图形,定义为:
g1
symdifferenceg2
:= (g1
uniong2
) difference (g1
intersectiong2
)
Or, in function call notation:或者,在函数调用表示法中:
ST_SymDifference(g1
,g2
) = ST_Difference(ST_Union(g1
,g2
), ST_Intersection(g1
,g2
))
ST_SymDifference()
handles its arguments as described in the introduction to this section.ST_SymDifference()
处理其参数,如本节简介中所述。
mysql>SET @g1 = Point(1,1), @g2 = Point(2,2);
mysql>SELECT ST_AsText(ST_SymDifference(@g1, @g2));
+---------------------------------------+ | ST_AsText(ST_SymDifference(@g1, @g2)) | +---------------------------------------+ | MULTIPOINT((1 1),(2 2)) | +---------------------------------------+
Transforms a geometry from one spatial reference system (SRS) to another. 将几何体从一个空间参照系(SRS)变换到另一个空间参照系。The return value is a geometry of the same type as the input geometry with all coordinates transformed to the target SRID, 返回值是与输入几何体类型相同的几何体,所有坐标都转换为目标SRIDtarget_srid
. target_srid
。Transformation support is limited to geographic SRSs, unless the SRID of the geometry argument is the same as the target SRID value, in which case the return value is the input geometry for any valid SRS.转换支持仅限于地理SRS,除非geometry参数的SRID与目标SRID值相同,在这种情况下,返回值是任何有效SRS的输入几何体。
ST_Transform()
handles its arguments as described in the introduction to this section, with these exceptions:ST_Transform()
按本节简介中所述处理其参数,但有以下例外:
Geometry arguments that have an SRID value for a geographic SRS do not produce an error.具有地理SRS的SRID值的几何参数不会产生错误。
If the geometry or target SRID argument has an SRID value that refers to an undefined spatial reference system (SRS), an 如果几何体或目标SRID参数的SRID值引用了未定义的空间参考系(SRS),则会发生ER_SRS_NOT_FOUND
error occurs.ER_SRS_NOT_FOUND
错误。
If the geometry is in an SRS that 如果几何体位于一个SRS中,ST_Transform()
cannot transform from, an ER_TRANSFORM_SOURCE_SRS_NOT_SUPPORTED
error occurs.ST_Transform()
无法从它转换,则会发生ER_TRANSFORM_SOURCE_SRS_NOT_SUPPORTED
错误。
If the target SRID is in an SRS that 如果目标SRID位于ST_Transform()
cannot transform to, an ER_TRANSFORM_TARGET_SRS_NOT_SUPPORTED
error occurs.ST_Transform()
无法转换到的SRS中,则会发生ER_TRANSFORM_TARGET_SRS_NOT_SUPPORTED
错误。
If the geometry is in an SRS that is not WGS 84 and has no TOWGS84 clause, an 如果几何体位于非WGS 84且没有TOWGS84子句的SRS中,则会发生ER_TRANSFORM_SOURCE_SRS_MISSING_TOWGS84
error occurs.ER_TRANSFORM_SOURCE_SRS_MISSING_TOWGS84
错误。
If the target SRID is in an SRS that is not WGS 84 and has no TOWGS84 clause, an 如果目标SRID位于非WGS 84且没有TOWGS84子句的SRS中,则会发生ER_TRANSFORM_TARGET_SRS_MISSING_TOWGS84
error occurs.ER_TRANSFORM_TARGET_SRS_MISSING_TOWGS84
错误。
ST_SRID(
and g
, target_srid
)ST_Transform(
differ as follows:g
, target_srid
)
ST_SRID()
changes the geometry SRID value without transforming its coordinates.ST_SRID()
更改几何体SRID值而不转换其坐标。
ST_Transform()
transforms the geometry coordinates in addition to changing its SRID value.ST_Transform()
除了更改其SRID值之外,还将变换几何体坐标。
mysql>SET @p = ST_GeomFromText('POINT(52.381389 13.064444)', 4326);
mysql>SELECT ST_AsText(@p);
+----------------------------+ | ST_AsText(@p) | +----------------------------+ | POINT(52.381389 13.064444) | +----------------------------+ mysql>SET @p = ST_Transform(@p, 4230);
mysql>SELECT ST_AsText(@p);
+---------------------------------------------+ | ST_AsText(@p) | +---------------------------------------------+ | POINT(52.38208611407426 13.065520672345304) | +---------------------------------------------+
Returns a geometry that represents the point set union of the geometry values 返回表示几何图形值g1
and g2
. g1
和g2
的点集并集的几何图形。The result is in the same SRS as the geometry arguments.结果与几何参数的SRS相同。
As of MySQL 8.0.26, 从MySQL 8.0.26开始,ST_Union()
permits arguments in either a Cartesian or a geographic SRS. ST_Union()
允许使用笛卡尔或地理形式的参数。Prior to MySQL 8.0.26, 在MySQL8.0.26之前,ST_Union()
permits arguments in a Cartesian SRS only; for arguments in a geographic SRS, an ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
error occurs.ST_Union()
只允许笛卡尔SRS中的参数;对于地理SRS中的参数,会发生ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
错误。
ST_Union()
handles its arguments as described in the introduction to this section.ST_Union()
处理其参数,如本节简介中所述。
mysql>SET @g1 = ST_GeomFromText('LineString(1 1, 3 3)');
mysql>SET @g2 = ST_GeomFromText('LineString(1 3, 3 1)');
mysql>SELECT ST_AsText(ST_Union(@g1, @g2));
+--------------------------------------+ | ST_AsText(ST_Union(@g1, @g2)) | +--------------------------------------+ | MULTILINESTRING((1 1,3 3),(1 3,3 1)) | +--------------------------------------+