MySQL provides several MySQL-specific functions that test the relationship between minimum bounding rectangles (MBRs) of two geometries MySQL提供了几个特定于MySQL的函数,用于测试两种几何体g1
and g2
. g1
和g2
的最小边界矩形(MBR)之间的关系。The return values 1 and 0 indicate true and false, respectively.返回值1和0分别表示true
和false
。
The bounding box of a point is interpreted as a point that is both boundary and interior.点的边界框被解释为既是边界又是内部的点。
The bounding box of a straight horizontal or vertical line is interpreted as a line where the interior of the line is also boundary. 水平直线或垂直直线的边界框被解释为直线内部也是边界的直线。The endpoints are boundary points.端点是边界点。
If any of the parameters are geometry collections, the interior, boundary, and exterior of those parameters are those of the union of all elements in the collection.如果任何参数是几何体集合,则这些参数的内部、边界和外部是集合中所有元素的并集的内部、边界和外部。
Functions in this section detect arguments in either Cartesian or geographic spatial reference systems (SRSs), and return results appropriate to the SRS.本节中的函数检测笛卡尔坐标系或地理空间参考系(SRS)中的参数,并返回适合SRS的结果。
Unless otherwise specified, functions in this section handle their geometry arguments as follows:除非另有规定,否则本节中的函数按如下方式处理其几何参数:
If any argument is 如果任何参数为NULL
or 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
错误。
If any argument is geometrically invalid, either the result is true or false (it is undefined which), or an error occurs.如果任何参数在几何上无效,则结果为真或假(未定义),或者发生错误。
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 MBR functions are available for testing geometry relationships:这些MBR函数可用于测试几何关系:
Returns 1 or 0 to indicate whether the minimum bounding rectangle of 返回1或0以指示g1
contains the minimum bounding rectangle of g2
. This tests the opposite relationship as MBRWithin()
.g1
的最小边框是否包含g2
的最小边框。这将测试与mbriwithin()
相反的关系。
MBRContains()
handles its arguments as described in the introduction to this section.MBRContains()
处理其参数,如本节简介中所述。
mysql>SET @g1 = ST_GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))');
mysql>SET @g2 = ST_GeomFromText('Point(1 1)');
mysql>SELECT MBRContains(@g1,@g2), MBRWithin(@g2,@g1);
+----------------------+--------------------+ | MBRContains(@g1,@g2) | MBRWithin(@g2,@g1) | +----------------------+--------------------+ | 1 | 1 | +----------------------+--------------------+
Returns 1 or 0 to indicate whether the minimum bounding rectangle of 返回1或0以指示g1
is covered by the minimum bounding rectangle of g2
. g1
的最小边框是否被g2
的最小边框覆盖。This tests the opposite relationship as 这将测试相反的关系,如MBRCovers()
.MBRCovers()
。
MBRCoveredBy()
handles its arguments as described in the introduction to this section.MBRCoveredBy()
按照本节简介中所述处理其参数。
mysql>SET @g1 = ST_GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))');
mysql>SET @g2 = ST_GeomFromText('Point(1 1)');
mysql>SELECT MBRCovers(@g1,@g2), MBRCoveredby(@g1,@g2);
+--------------------+-----------------------+ | MBRCovers(@g1,@g2) | MBRCoveredby(@g1,@g2) | +--------------------+-----------------------+ | 1 | 0 | +--------------------+-----------------------+ mysql>SELECT MBRCovers(@g2,@g1), MBRCoveredby(@g2,@g1);
+--------------------+-----------------------+ | MBRCovers(@g2,@g1) | MBRCoveredby(@g2,@g1) | +--------------------+-----------------------+ | 0 | 1 | +--------------------+-----------------------+
Returns 1 or 0 to indicate whether the minimum bounding rectangle of 返回1或0以指示g1
covers the minimum bounding rectangle of g2
. g1
的最小边框是否覆盖g2
的最小边框。This tests the opposite relationship as 这将测试MBRCoveredBy()
. mbrecoveredby()
的相反关系。See the description of 有关示例,请参见MBRCoveredBy()
for examples.MBRCoveredBy()
的说明。
MBRCovers()
handles its arguments as described in the introduction to this section.mbrcolves()
处理其参数,如本节简介中所述。
Returns 1 or 0 to indicate whether the minimum bounding rectangles of the two geometries 返回1或0以指示两个几何体g1
and g2
are disjoint (do not intersect).g1
和g2
的最小边界矩形是否不相交。
MBRDisjoint()
handles its arguments as described in the introduction to this section.MBRDisjoint()
处理其参数,如本节简介中所述。
Returns 1 or 0 to indicate whether the minimum bounding rectangles of the two geometries 返回1或0以指示两个几何体g1
and g2
are the same.g1
和g2
的最小边界矩形是否相同。
MBREquals()
handles its arguments as described in the introduction to this section, except that it does not return NULL
for empty geometry arguments.MBREquals()
按本节简介中所述处理其参数,但对于空的几何体参数,它不返回NULL
。
Returns 1 or 0 to indicate whether the minimum bounding rectangles of the two geometries 返回1或0以指示两个几何体g1
and g2
intersect.g1
和g2
的最小边界矩形是否相交。
MBRIntersects()
handles its arguments as described in the introduction to this section.MBRIntersects()
处理其参数,如本节简介中所述。
Two geometries spatially overlap if they intersect and their intersection results in a geometry of the same dimension but not equal to either of the given geometries.如果两个几何体相交,则它们在空间上会重叠,并且它们的相交会导致一个尺寸相同但不等于给定几何体中任何一个的几何体。
This function returns 1 or 0 to indicate whether the minimum bounding rectangles of the two geometries 此函数返回1或0,以指示两个几何体g1
and g2
overlap.g1
和g2
的最小边界矩形是否重叠。
MBROverlaps()
handles its arguments as described in the introduction to this section.MBROverlaps()
处理其参数,如本节简介中所述。
Two geometries spatially touch if their interiors do not intersect, but the boundary of one of the geometries intersects either the boundary or the interior of the other.如果两个几何体的内部不相交,但其中一个几何体的边界与另一个几何体的边界或内部相交,则两个几何体在空间上相互接触。
This function returns 1 or 0 to indicate whether the minimum bounding rectangles of the two geometries 此函数返回1或0,以指示两个几何体g1
and g2
touch.g1
和g2
的最小边界矩形是否接触。
MBRTouches()
handles its arguments as described in the introduction to this section.mbrTouchs()
处理其参数,如本节简介中所述。
Returns 1 or 0 to indicate whether the minimum bounding rectangle of 返回1或0以指示g1
is within the minimum bounding rectangle of g2
. g1
的最小边框是否在g2
的最小边框内。This tests the opposite relationship as 这将测试相反的关系,如MBRContains()
.mbracontains()
。
MBRWithin()
handles its arguments as described in the introduction to this section.MBRWithin()
处理其参数,如本节简介中所述。
mysql>SET @g1 = ST_GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))');
mysql>SET @g2 = ST_GeomFromText('Polygon((0 0,0 5,5 5,5 0,0 0))');
mysql>SELECT MBRWithin(@g1,@g2), MBRWithin(@g2,@g1);
+--------------------+--------------------+ | MBRWithin(@g1,@g2) | MBRWithin(@g2,@g1) | +--------------------+--------------------+ | 1 | 0 | +--------------------+--------------------+