ST_Overlaps — Teste si deux géométries ont la même dimension et se croisent, mais si chacune a au moins un point qui n'est pas dans l'autre
boolean ST_Overlaps(
geometry A, geometry B)
;
Returns TRUE if geometry A and B "spatially overlap". Two geometries overlap if they have the same dimension, their interiors intersect in that dimension. and each has at least one point inside the other (or equivalently, neither one covers the other). The overlaps relation is symmetric and irreflexive.
In mathematical terms: ST_Overlaps(A, B) ⇔ ( dim(A) = dim(B) = dim( Int(A) ⋂ Int(B) )) ∧ (A ⋂ B ≠ A) ∧ (A ⋂ B ≠ B)
Cette fonction inclut une comparaison de la boîte englobante qui utilise tous les index disponibles sur les géométries. Pour éviter l'utilisation d'un index, utilisez la fonction |
Effectué par le module GEOS
Amélioration : 3.0.0 a permis la prise en charge de |
NOTE : il s'agit de la version "autorisée" qui renvoie un booléen et non un entier.
Cette méthode implémente la spécification OGC Simple Features Implementation Specification for SQL 1.1.
s2.1.1.2 // s2.1.13.3
Cette méthode implémente la spécification SQL/MM.
SQL-MM 3: 5.1.32
ST_Overlaps
renvoie TRUE
dans les situations suivantes :
Un point sur une LineString est contenu, mais comme il a une dimension inférieure, il ne se chevauche pas et ne se croise pas.
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
Une chaîne de lignes qui recouvre partiellement un polygone l'intersecte et le traverse, mais ne se chevauche pas car elle a des dimensions différentes.
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
Deux polygones qui se croisent mais dont aucun n'est contenu par l'autre se chevauchent, mais ne se croisent pas car leur intersection a la même dimension.
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