OpenGIS 提出了一些可以生成几何体的函数。这些函数旨在实现空间运算符。除不适用的情况外,这些函数支持所有参数类型的组合,根据 开放地理空间联盟 的规范。OpenGIS proposes a number of functions that can produce geometries. 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 也实现了一些作为 OpenGIS 扩展的函数,这在函数描述中有所说明。此外,第 14.16.7 节,“几何属性函数” 讨论了几个从现有几何体构建新几何体的函数。有关这些函数的说明,请参见该节:MySQL also implements certain functions that are extensions to OpenGIS, as noted in the function descriptions. In addition, Section 14.16.7, “Geometry Property Functions”, discusses several functions that construct new geometries from existing ones. See that section for descriptions of these functions:
除非另有说明,本节中的函数对其几何参数的处理方式如下:Unless otherwise specified, functions in this section handle their geometry arguments as follows:
如果任何参数为
NULL,则返回值为NULL。If any argument isNULL, the return value isNULL.如果任何几何参数不是语法上格式正确的几何体,则会发生
ER_GIS_INVALID_DATA错误。If any geometry argument is not a syntactically well-formed geometry, anER_GIS_INVALID_DATAerror occurs.如果任何几何参数是在未定义空间参考系统(SRS)中的语法上良构的几何,将会发生
ER_SRS_NOT_FOUND错误。If any geometry argument is a syntactically well-formed geometry in an undefined spatial reference system (SRS), anER_SRS_NOT_FOUNDerror occurs.对于接受多个几何参数的函数,如果这些参数不在相同的 SRS 中,会出现
ER_GIS_DIFFERENT_SRIDS错误。For functions that take multiple geometry arguments, if those arguments are not in the same SRS, anER_GIS_DIFFERENT_SRIDSerror occurs.如果任何几何参数具有地理 SRS 的 SRID 值,而该函数不处理地理几何体,则会出现
ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS错误。If any geometry argument has an SRID value for a geographic SRS and the function does not handle geographic geometries, anER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRSerror 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_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE错误。If a longitude value is not in the range (−180, 180], anER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGEerror occurs.如果纬度值不在范围[−90, 90]内,将发生
ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE错误。If a latitude value is not in the range [−90, 90], anER_GEOMETRY_PARAM_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.
否则,返回值不为
NULL。Otherwise, the return value is non-NULL.
这些空间操作符函数可用:These spatial operator functions are available:
ST_Buffer(g,d[,strategy1[,strategy2[,strategy3]]])返回一个几何体,该几何体表示从几何值
g出发,距离不大于d的所有点。结果的坐标参考系统与几何参数相同。Returns a geometry that represents all points whose distance from the geometry valuegis less than or equal to a distance ofd. The result is in the same SRS as the geometry argument.如果几何参数为空,
ST_Buffer()返回一个空几何体。If the geometry argument is empty,ST_Buffer()returns an empty geometry.如果距离为 0,
ST_Buffer()将返回未改变的几何参数:If the distance is 0,ST_Buffer()returns the geometry argument unchanged: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:
ST_Buffer()支持Polygon和MultiPolygon值的负距离,以及包含Polygon或MultiPolygon值的几何集合。ST_Buffer()supports negative distances forPolygonandMultiPolygonvalues, and for geometry collections containingPolygonorMultiPolygonvalues.如果结果缩小到消失,那么结果就是一个空几何体。If the result is reduced so much that it disappears, the result is an empty geometry.
对于
Point、MultiPoint、LineString和MultiLineString值,以及不包含任何Polygon或MultiPolygon值的几何集合,使用负距离调用ST_Buffer()时,会发生ER_WRONG_ARGUMENTS错误。AnER_WRONG_ARGUMENTSerror occurs forST_Buffer()with a negative distance forPoint,MultiPoint,LineString, andMultiLineStringvalues, and for geometry collections not containing anyPolygonorMultiPolygonvalues.
在地理空间参考系统 (SRS) 中允许
Point几何,前提是满足以下条件:Pointgeometries in a geographic SRS are permitted, subject to the following conditions:如果距离不为负且未指定任何策略,该函数将返回
Point在其 SRS 中的地理缓冲区。distance 参数必须以 SRS 距离单位(目前始终为米)为单位。If the distance is not negative and no strategies are specified, the function returns the geographic buffer of thePointin its SRS. The distance argument must be in the SRS distance unit (currently always meters).如果距离为负或指定了任何策略(
NULL除外),将产生ER_WRONG_ARGUMENTS错误。If the distance is negative or any strategy (exceptNULL) is specified, anER_WRONG_ARGUMENTSerror occurs.
对于非
Point几何图形,将产生ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS错误。For non-Pointgeometries, anER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRSerror occurs.ST_Buffer()允许在距离参数之后最多使用三个可选的策略参数。策略会影响缓冲区计算。这些参数是由ST_Buffer_Strategy()函数生成的字节字符串值,用于点、连接和端点策略:ST_Buffer()permits up to three optional strategy arguments following the distance argument. Strategies influence buffer computation. These arguments are byte string values produced by theST_Buffer_Strategy()function, to be used for point, join, and end strategies:点策略适用于
Point和MultiPoint几何。如果未指定点策略,默认值为ST_Buffer_Strategy('point_circle', 32)。Point strategies apply toPointandMultiPointgeometries. If no point strategy is specified, the default isST_Buffer_Strategy('point_circle', 32).连接策略适用于
LineString、MultiLineString、Polygon和MultiPolygon几何。如果未指定连接策略,默认值为ST_Buffer_Strategy('join_round', 32)。Join strategies apply toLineString,MultiLineString,Polygon, andMultiPolygongeometries. If no join strategy is specified, the default isST_Buffer_Strategy('join_round', 32).端点策略适用于
LineString和MultiLineString几何。如果未指定端点策略,默认值为ST_Buffer_Strategy('end_round', 32)。End strategies apply toLineStringandMultiLineStringgeometries. If no end strategy is specified, the default isST_Buffer_Strategy('end_round', 32).
每种类型最多可以指定一种策略,并且它们可以按任何顺序给出。Up to one strategy of each type may be specified, and they may be given in any order.
如果缓冲策略无效,将会发生
ER_WRONG_ARGUMENTS错误。在以下任何情况下,策略都是无效的:If the buffer strategies are invalid, anER_WRONG_ARGUMENTSerror occurs. 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.
传入了一个
Point策略,但几何图形不包含Point或MultiPoint值。APointstrategy is passed and the geometry contains noPointorMultiPointvalues.传入了一个端点或连接策略,但几何图形不包含
LineString、Polygon、MultiLinestring或MultiPolygon值。An end or join strategy is passed and the geometry contains noLineString,Polygon,MultiLinestringorMultiPolygonvalues.
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])此函数返回一个策略字节字符串,用于
ST_Buffer(),以影响缓冲区计算。This function returns a strategy byte string for use withST_Buffer()to influence buffer computation.有关策略的信息可在 Boost.org 获得。Information about strategies is available at Boost.org.
第一个参数必须是一个表示策略选项的字符串:The first argument must be a string indicating a strategy option:
对于点策略,允许的值是
'point_circle'和'point_square'。For point strategies, permitted values are'point_circle'and'point_square'.对于连接策略,允许的值是
'join_round'和'join_miter'。For join strategies, permitted values are'join_round'and'join_miter'.对于端点策略,允许的值是
'end_round'和'end_flat'。For end strategies, permitted values are'end_round'and'end_flat'.
如果第一个参数是
'point_circle'、'join_round'、'join_miter'或'end_round',则points_per_circle参数必须给出一个正数值。points_per_circle的最大值为系统变量max_points_in_geometry的值。If the first argument is'point_circle','join_round','join_miter', or'end_round', thepoints_per_circleargument must be given as a positive numeric value. The maximumpoints_per_circlevalue is the value of themax_points_in_geometrysystem variable.有关示例,请参见
ST_Buffer()的描述。For examples, see the description ofST_Buffer().ST_Buffer_Strategy()按本节介绍中描述的方式处理其参数,但有以下例外:ST_Buffer_Strategy()handles its arguments as described in the introduction to this section, with these exceptions:如果任何参数无效,将发生
ER_WRONG_ARGUMENTS错误。If any argument is invalid, anER_WRONG_ARGUMENTSerror occurs.如果第一个参数为
'point_square'或'end_flat',则points_per_circle参数不得给出,否则将发生ER_WRONG_ARGUMENTS错误。If the first argument is'point_square'or'end_flat', thepoints_per_circleargument must not be given or anER_WRONG_ARGUMENTSerror occurs.
返回表示几何值
g的凸包的几何对象。Returns a geometry that represents the convex hull of the geometry valueg.该函数通过首先检查其顶点是否共线来计算几何的凸包。如果顶点共线,则函数返回线性凸包,否则返回多边形凸包。该函数处理几何集合时,会提取集合中所有组件的所有顶点,创建一个
MultiPoint值,并计算其凸包。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 aMultiPointvalue from them, and computing its convex hull.ST_ConvexHull()按本节介绍中的方式处理其参数,但有如下例外:ST_ConvexHull()handles its arguments as described in the introduction to this section, with this exception:当参数是空几何集合时,返回值为
NULL。The return value isNULLfor the additional condition that the argument is an empty geometry collection.
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)) | +-----------------------------------------------+返回一个几何体,表示几何值
g1与g2的点集差异。结果使用与几何参数相同的空间参考系统 (SRS)。Returns a geometry that represents the point set difference of the geometry valuesg1andg2. The result is in the same SRS as the geometry arguments.ST_Difference()允许参数使用笛卡尔或地理空间参考系统,并按本节开头介绍的方式处理其参数。ST_Difference()permits arguments in either a Cartesian or a geographic SRS, and handles its arguments as described in the introduction to this section.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) | +------------------------------------+返回一个几何对象,表示几何值
g1与g2的点集交集。结果使用与几何参数相同的空间参考系统(SRS)。Returns a geometry that represents the point set intersection of the geometry valuesg1andg2. The result is in the same SRS as the geometry arguments.ST_Intersection()允许参数使用笛卡尔或地理空间参考系统,并按照本节介绍中描述的方式处理其参数。ST_Intersection()permits arguments in either a Cartesian or a geographic SRS, and handles its arguments as described in the introduction to this section.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)该函数接受一个
LineString几何体和一个范围在 [0.0, 1.0] 内的分数距离,并返回沿LineString从起点到终点的给定分数距离处的Point。它可以用于回答诸如沿几何参数描述的道路中点的Point位置的问题。This function takes aLineStringgeometry and a fractional distance in the range [0.0, 1.0] and returns thePointalong theLineStringat the given fraction of the distance from its start point to its endpoint. It can be used to answer questions such as whichPointlies halfway along the road described by the geometry argument.该函数可在所有空间参考系统的
LineString几何体上使用,包括笛卡尔和地理坐标系统。The function is implemented forLineStringgeometries in all spatial reference systems, both Cartesian and geographic.如果
fractional_distance参数为 1.0,由于近似值计算中的数值不精确,结果可能并不正好是LineString参数的最后一个点,而是接近它的一个点。If thefractional_distanceargument is 1.0, the result may not be exactly the last point of theLineStringargument but a point close to it due to numerical inaccuracies in approximate-value computations.一个相关的函数,
ST_LineInterpolatePoints(),接收类似的参数,但返回一个MultiPoint,其中包含沿LineString每个从起点到终点距离分数位置的Point值。有关两个函数的示例,请参见ST_LineInterpolatePoints()的说明。A related function,ST_LineInterpolatePoints(), takes similar arguments but returns aMultiPointconsisting ofPointvalues along theLineStringat each fraction of the distance from its start point to its endpoint. For examples of both functions, see theST_LineInterpolatePoints()description.ST_LineInterpolatePoint()按本节介绍中描述的方式处理其参数,但有以下例外:ST_LineInterpolatePoint()handles its arguments as described in the introduction to this section, with these exceptions:如果 geometry 参数不是
LineString,将发生ER_UNEXPECTED_GEOMETRY_TYPE错误。If the geometry argument is not aLineString, anER_UNEXPECTED_GEOMETRY_TYPEerror occurs.如果分数距离参数超出 [0.0, 1.0] 范围,将发生
ER_DATA_OUT_OF_RANGE错误。If the fractional distance argument is outside the range [0.0, 1.0], anER_DATA_OUT_OF_RANGEerror occurs.
ST_LineInterpolatePoint()是 MySQL 对 OpenGIS 的扩展。ST_LineInterpolatePoint()is a MySQL extension to OpenGIS.ST_LineInterpolatePoints(ls,fractional_distance)此函数接受一个
LineString几何体和范围在 (0.0, 1.0] 的分数距离,并返回MultiPoint,包括LineString的起点,以及沿LineString从起点到终点每个距离分数处的Point值。它可以用于回答诸如在几何体参数描述的道路上,每隔 10% 的距离在哪些Point值的位置的问题。This function takes aLineStringgeometry and a fractional distance in the range (0.0, 1.0] and returns theMultiPointconsisting of theLineStringstart point, plusPointvalues along theLineStringat each fraction of the distance from its start point to its endpoint. It can be used to answer questions such as whichPointvalues lie every 10% of the way along the road described by the geometry argument.该函数可在所有空间参考系统的
LineString几何体上使用,包括笛卡尔和地理坐标系统。The function is implemented forLineStringgeometries in all spatial reference systems, both Cartesian and geographic.如果
fractional_distance参数能整除 1.0 而余数为零,由于近似值计算中的数值不准确,结果可能不包含LineString参数的最后一点,而是靠近它的一点。If thefractional_distanceargument divides 1.0 with zero remainder the result may not contain the last point of theLineStringargument but a point close to it due to numerical inaccuracies in approximate-value computations.一个相关的函数,
ST_LineInterpolatePoint(),接受类似的参数,但返回沿着LineString从起点到终点的给定距离比例处的Point。A related function,ST_LineInterpolatePoint(), takes similar arguments but returns thePointalong theLineStringat the given fraction of the distance from its start point to its endpoint.ST_LineInterpolatePoints()处理它的参数如本节介绍所述,以下情况除外:ST_LineInterpolatePoints()handles its arguments as described in the introduction to this section, with these exceptions:如果 geometry 参数不是
LineString,将发生ER_UNEXPECTED_GEOMETRY_TYPE错误。If the geometry argument is not aLineString, anER_UNEXPECTED_GEOMETRY_TYPEerror occurs.如果分数距离参数超出 [0.0, 1.0] 范围,将发生
ER_DATA_OUT_OF_RANGE错误。If the fractional distance argument is outside the range [0.0, 1.0], anER_DATA_OUT_OF_RANGEerror occurs.
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()是 MySQL 对 OpenGIS 的扩展。ST_LineInterpolatePoints()is a MySQL extension to OpenGIS.ST_PointAtDistance(ls,distance)此函数接受一个
LineString几何对象和一个在 [0.0,ST_Length(] 范围内的距离,该距离以ls)LineString的空间参考系统 (SRS) 的单位为单位,并返回从起点开始沿LineString指定距离的Point。它可用于回答诸如道路起点起多少米的Point值等问题。This function takes aLineStringgeometry and a distance in the range [0.0,ST_Length(] measured in the unit of the spatial reference system (SRS) of thels)LineString, and returns thePointalong theLineStringat that distance from its start point. It can be used to answer questions such as whichPointvalue is 400 meters from the start of the road described by the geometry argument.该函数可在所有空间参考系统的
LineString几何体上使用,包括笛卡尔和地理坐标系统。The function is implemented forLineStringgeometries in all spatial reference systems, both Cartesian and geographic.ST_PointAtDistance()按本节介绍中描述的方式处理其参数,但有以下例外:ST_PointAtDistance()handles its arguments as described in the introduction to this section, with these exceptions:如果 geometry 参数不是
LineString,将发生ER_UNEXPECTED_GEOMETRY_TYPE错误。If the geometry argument is not aLineString, anER_UNEXPECTED_GEOMETRY_TYPEerror occurs.如果分数距离参数超出 [0.0,
ST_Length(] 范围,将会发生ls)ER_DATA_OUT_OF_RANGE错误。If the fractional distance argument is outside the range [0.0,ST_Length(], anls)ER_DATA_OUT_OF_RANGEerror occurs.
ST_PointAtDistance()是对 OpenGIS 的 MySQL 扩展。ST_PointAtDistance()is a MySQL extension to OpenGIS.返回一个几何体,该几何体表示几何值
g1和g2的点集合对称差,其定义如下:Returns a geometry that represents the point set symmetric difference of the geometry valuesg1andg2, which is defined as:g1symdifferenceg2:= (g1uniong2) difference (g1intersectiong2)或者,用函数调用表示法:Or, in function call notation:
ST_SymDifference(
g1,g2) = ST_Difference(ST_Union(g1,g2), ST_Intersection(g1,g2))结果与几何参数的空间参考系统相同。The result is in the same SRS as the geometry arguments.
ST_SymDifference()允许参数为笛卡尔或地理空间参考系统(SRS),并按照本节介绍中描述的方式处理其参数。ST_SymDifference()permits arguments in either a Cartesian or a geographic SRS, and handles its arguments as described in the introduction to this section.mysql>
SET @g1 = ST_GeomFromText('MULTIPOINT(5 0,15 10,15 25)');mysql>SET @g2 = ST_GeomFromText('MULTIPOINT(1 1,15 10,15 25)');mysql>SELECT ST_AsText(ST_SymDifference(@g1, @g2));+---------------------------------------+ | ST_AsText(ST_SymDifference(@g1, @g2)) | +---------------------------------------+ | MULTIPOINT((1 1),(5 0)) | +---------------------------------------+将几何体从一个空间参考系统(SRS)转换到另一个。返回值是与输入几何体相同类型的几何体,所有坐标已转换为目标 SRID,
target_srid。MySQL 支持 EPSG 定义的所有 SRS,除了这里列出的那些:Transforms a geometry from one spatial reference system (SRS) to another. The return value is a geometry of the same type as the input geometry with all coordinates transformed to the target SRID,target_srid. MySQL supports all SRSs defined by EPSG except for those listed here:EPSG 1042 克罗瓦克修改版EPSG 1042 Krovak Modified
EPSG 1043 克罗瓦克修改版(北向)EPSG 1043 Krovak Modified (North Orientated)
EPSG 9816 突尼斯矿业网格EPSG 9816 Tunisia Mining Grid
EPSG 9826 兰伯特圆锥等角(西向)EPSG 9826 Lambert Conic Conformal (West Orientated)
ST_Transform()按本节介绍中描述的方式处理其参数,但有以下例外情况:ST_Transform()handles its arguments as described in the introduction to this section, with these exceptions:对于具有地理空间参考系统 (SRS) 的 SRID 值的几何参数不会产生错误。Geometry arguments that have an SRID value for a geographic SRS do not produce an error.
如果几何体或目标 SRID 参数具有引用未定义空间参考系统(SRS)的 SRID 值,将会发生
ER_SRS_NOT_FOUND错误。If the geometry or target SRID argument has an SRID value that refers to an undefined spatial reference system (SRS), anER_SRS_NOT_FOUNDerror occurs.如果几何体处于
ST_Transform()无法转换的 SRS,将会发生ER_TRANSFORM_SOURCE_SRS_NOT_SUPPORTED错误。If the geometry is in an SRS thatST_Transform()cannot transform from, anER_TRANSFORM_SOURCE_SRS_NOT_SUPPORTEDerror occurs.如果目标 SRID 位于
ST_Transform()无法转换到的 SRS 中,将会发生ER_TRANSFORM_TARGET_SRS_NOT_SUPPORTED错误。If the target SRID is in an SRS thatST_Transform()cannot transform to, anER_TRANSFORM_TARGET_SRS_NOT_SUPPORTEDerror occurs.如果几何图形位于非 WGS 84 的 SRS 中且没有 TOWGS84 子句,将会发生
ER_TRANSFORM_SOURCE_SRS_MISSING_TOWGS84错误。If the geometry is in an SRS that is not WGS 84 and has no TOWGS84 clause, anER_TRANSFORM_SOURCE_SRS_MISSING_TOWGS84error occurs.如果目标 SRID 位于非 WGS 84 的 SRS 中且没有 TOWGS84 子句,将会发生
ER_TRANSFORM_TARGET_SRS_MISSING_TOWGS84错误。If the target SRID is in an SRS that is not WGS 84 and has no TOWGS84 clause, anER_TRANSFORM_TARGET_SRS_MISSING_TOWGS84error occurs.
ST_SRID(g, target_srid)和ST_Transform(g, target_srid)的区别如下:ST_SRID(andg,target_srid)ST_Transform(differ as follows:g,target_srid)ST_SRID()改变几何的 SRID 值,而不转换其坐标。ST_SRID()changes the geometry SRID value without transforming its coordinates.ST_Transform()除了改变 SRID 值之外,还会转换几何坐标。ST_Transform()transforms the geometry coordinates in addition to changing its SRID value.
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) | +---------------------------------------------+返回一个表示几何值
g1和g2点集合并的几何。结果使用与几何参数相同的 SRS。Returns a geometry that represents the point set union of the geometry valuesg1andg2. The result is in the same SRS as the geometry arguments.ST_Union()允许参数使用笛卡尔或地理空间参考系统,并按本节介绍的方式处理其参数。ST_Union()permits arguments in either a Cartesian or a geographic SRS, and handles its arguments as described in the introduction to this section.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)) | +--------------------------------------+