ST_Overlaps — 测试两个几何图形是否具有相同的维度并相交,但每个图形都至少有一个点不在另一个图形中
boolean ST_Overlaps(
geometry A, geometry B)
;
如果几何图形 A 和 B “空间重叠”,则返回 TRUE。如果两个几何图形具有相同的维度,它们的内部在该维度中相交,并且每个图形至少有一个点在另一个图形内部(或者等效地,两个图形都不覆盖另一个图形),则它们重叠。重叠关系是对称且非自反的。
用数学术语表示: ST_Overlaps(A, B) ⇔ ( dim(A) = dim(B) = dim( Int(A) ⋂ Int(B) )) ∧ (A ⋂ B ≠ A) ∧ (A ⋂ B ≠ B)
此函数自动包含一个边界框比较,该比较使用几何图形上可用的任何空间索引。要避免使用索引,请使用函数 |
由 GEOS 模块执行
增强功能:3.0.0 启用了对 |
注意:这是返回布尔值的“允许”版本,而不是整数。
此方法实现了 OGC SQL 1.1 简单要素实现规范。 s2.1.1.2 // s2.1.13.3
此方法实现了 SQL/MM 规范。SQL-MM 3: 5.1.32
在以下情况下,ST_Overlaps
返回 TRUE
|
|
|
线串上的点被包含,但由于其维度较低,因此不重叠或交叉。
SELECT ST_Overlaps(a,b) AS overlaps, ST_Crosses(a,b) AS crosses, ST_Intersects(a, b) AS intersects, ST_Contains(b,a) AS b_contains_a FROM (SELECT ST_GeomFromText('POINT (100 100)') As a, ST_GeomFromText('LINESTRING (30 50, 40 160, 160 40, 180 160)') AS b) AS t overlaps | crosses | intersects | b_contains_a ---------+----------------------+-------------- f | f | t | t
部分覆盖多边形的线串会相交和交叉,但由于其维度不同,因此不重叠。
SELECT ST_Overlaps(a,b) AS overlaps, ST_Crosses(a,b) AS crosses, ST_Intersects(a, b) AS intersects, ST_Contains(a,b) AS contains FROM (SELECT ST_GeomFromText('POLYGON ((40 170, 90 30, 180 100, 40 170))') AS a, ST_GeomFromText('LINESTRING(10 10, 190 190)') AS b) AS t; overlap | crosses | intersects | contains ---------+---------+------------+-------------- f | t | t | f
两个相交但彼此都不包含的多边形重叠,但不会交叉,因为它们的交点具有相同的维度。
SELECT ST_Overlaps(a,b) AS overlaps, ST_Crosses(a,b) AS crosses, ST_Intersects(a, b) AS intersects, ST_Contains(b, a) AS b_contains_a, ST_Dimension(a) AS dim_a, ST_Dimension(b) AS dim_b, ST_Dimension(ST_Intersection(a,b)) AS dim_int FROM (SELECT ST_GeomFromText('POLYGON ((40 170, 90 30, 180 100, 40 170))') AS a, ST_GeomFromText('POLYGON ((110 180, 20 60, 130 90, 110 180))') AS b) As t; overlaps | crosses | intersects | b_contains_a | dim_a | dim_b | dim_int ----------+---------+------------+--------------+-------+-------+----------- t | f | t | f | 2 | 2 | 2