Name

ST_ContainsProperly — Tests si chaque point de B se trouve à l'intérieur de A

Synopsis

boolean ST_ContainsProperly(geometry geomA, geometry geomB);

Description

Returns true if every point of B lies in the interior of A (or equivalently, no point of B lies in the the boundary or exterior of A).

In mathematical terms: ST_ContainsProperly(A, B) ⇔ Int(A) ⋂ B = B

A contains B properly if the DE-9IM Intersection Matrix for the two geometries matches [T**FF*FF*]

A ne se contient pas proprement, mais se contient.

Ce prédicat peut être utilisé pour calculer les intersections d'un ensemble de géométries avec une grande géométrie polygonale. L'intersection étant une opération assez lente, il peut être plus efficace d'utiliser containsProperly pour filtrer les géométries de test qui se trouvent entièrement à l'intérieur de la zone. Dans ce cas, on sait a priori que l'intersection correspond exactement à la géométrie d'essai originale.

[Note]

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 _ST_ContainsProperly.

[Note]

L'avantage de ce prédicat par rapport à ST_Contains et ST_Intersects est qu'il peut être calculé plus efficacement, sans qu'il soit nécessaire de calculer la topologie en des points individuels.

Effectué par le module GEOS.

Disponibilité : 1.4.0

[Important]

Amélioration : 3.0.0 a permis la prise en charge de GEOMETRYCOLLECTION

[Important]

N'utilisez pas cette fonction avec des géométries non valides. Vous obtiendrez des résultats inattendus.

Exemples

--a circle within a circle
  SELECT ST_ContainsProperly(smallc, bigc) As smallcontainspropbig,
  ST_ContainsProperly(bigc,smallc) As bigcontainspropsmall,
  ST_ContainsProperly(bigc, ST_Union(smallc, bigc)) as bigcontainspropunion,
  ST_Equals(bigc, ST_Union(smallc, bigc)) as bigisunion,
  ST_Covers(bigc, ST_ExteriorRing(bigc)) As bigcoversexterior,
  ST_ContainsProperly(bigc, ST_ExteriorRing(bigc)) As bigcontainsexterior
  FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
  ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
  --Result
  smallcontainspropbig | bigcontainspropsmall | bigcontainspropunion | bigisunion | bigcoversexterior | bigcontainsexterior
------------------+------------------+------------------+------------+-------------------+---------------------
 f                     | t                    | f                    | t          | t                 | f

 --example demonstrating difference between contains and contains properly
 SELECT ST_GeometryType(geomA) As geomtype, ST_Contains(geomA,geomA) AS acontainsa, ST_ContainsProperly(geomA, geomA) AS acontainspropa,
 ST_Contains(geomA, ST_Boundary(geomA)) As acontainsba, ST_ContainsProperly(geomA, ST_Boundary(geomA)) As acontainspropba
 FROM (VALUES ( ST_Buffer(ST_Point(1,1), 5,1) ),
      ( ST_MakeLine(ST_Point(1,1), ST_Point(-1,-1) ) ),
      ( ST_Point(1,1) )
  ) As foo(geomA);

  geomtype    | acontainsa | acontainspropa | acontainsba | acontainspropba
--------------+------------+----------------+-------------+-----------------
ST_Polygon    | t          | f              | f           | f
ST_LineString | t          | f              | f           | f
ST_Point      | t          | t              | f           | f
 

Voir aussi

ST_GeometryType, ST_Boundary, ST_Contains, ST_Covers, ST_CoveredBy, ST_Equals, ST_Relate, ST_Within