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 启用了对 |
注意:这是返回布尔值而不是整数的“允许”版本。
此方法实现了 SQL 1.1 的 OGC 简单功能规范。 s2.1.1.2 // s2.1.13.3
该方法实现了SQL/MM规范。 SQL-MM 3: 5.1.32
ST_Overlaps
在以下情况返回TRUE
:
|
|
|
包含 LineString 上的点,但由于它的维度较低,因此不会重叠或交叉。
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