This topic describes the ST_ContainsProperly function. This function checks whether the second geometry object that you specify completely lies in the first geometry object that you specify. If the second geometry object completely lies in the first geometry object, this function returns True. Otherwise, this function returns False.
Syntax
boolean ST_ContainsProperly(geometry geomA , geometry geomB);Parameters
| Parameter | Description |
|---|---|
| geomA | The first geometry object that you want to specify. |
| geomB | The second geometry object that you want to specify. |
Description
- If the second geometry object that you specify intersects with the interior of the first geometry object that you specify but does not touch the boundary or exterior of the first geometry object, this function returns True. All points of the second geometry object lie inside the first geometry object.
- The DE-9IM matrix patterns of the geometry objects that you specify conform to [T**FF*FF*].
- This function does not support GeometryCollection objects.
- Do not specify invalid geometry objects. If you specify invalid geometry objects, this function returns an unexpected result.
- This function generates a bounding box, which allows you to use the indexes that are available on the geometry objects that you specify. If you do not want to use the indexes, we recommend that you use the _ST_ContainsProperly function.
Examples
The following example shows the difference between the ST_ContainsProperly function
and the ST_Contains function.
SELECT ST_Contains(g1,g2), ST_ContainsProperly(g1,g2),ST_ContainsProperly(g1,g3)
FROM (SELECT 'POLYGON((0 0,0 3,3 3,3 0,0 0))'::geometry as g1,
'POLYGON((0 0,0 1,1 1,1 0,0 0))'::geometry as g2,
'POLYGON((1 1,1 2,2 2,2 1,1 1))'::geometry as g3 ) as test;
st_contains | st_containsproperly | st_containsproperly
-------------+---------------------+---------------------
t | f | t
(1 row)