Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContainsProperly returns true when POINT B is on the boundary of GeometryCollection A #981

Open
cuteDen-ECNU opened this issue Nov 1, 2023 · 1 comment
Labels

Comments

@cuteDen-ECNU
Copy link

Consider the following statement:

SELECT ST_ContainsProperly(a1, a2)
FROM ST_GeomFromText('GEOMETRYCOLLECTION(LINESTRING(0 1, 0 0),POINT(0 0))') As a1
,ST_GeomFromText('POINT(0 0)') As a2;
--expected{f}, actual{t}

According to the definition, ContainsProperly returns false when the point of a1 is on the boundary of a2.

Returns true if every point of B lies in the interior of A (or equivalently, no point of B lies in the boundary or exterior of A).
In mathematical terms: ST_ContainsProperly(A, B) ⇔ Int(A) ⋂ B = B

The boundary of a1 (MULTIPOINT((0 1),(0 0), EMPTY)) contains a2, thus, ContainsProperly returns false that is expected.

SELECT ST_AsText(ST_Boundary(a1)), ST_Contains(ST_Boundary(a1), a2)
FROM ST_GeomFromText('GEOMETRYCOLLECTION(LINESTRING(0 1, 0 0),POINT(0 0))') As a1
, ST_GeomFromText('POINT(0 0)') As a2;
--            st_astext           | st_contains 
-- -------------------------------+-------------
--  MULTIPOINT((0 1),(0 0),EMPTY) | t
-- (1 row)

The version is the lastest:
POSTGIS="3.5.0dev 3.4.0rc1-705-g5c3ec8392" [EXTENSION] PGSQL="170" GEOS="3.13.0dev-CAPI-1.18.0" PROJ="8.2.1 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org/ USER_WRITABLE_DIRECTORY=/tmp/proj DATABASE_PATH=/usr/share/proj/proj.db" LIBXML="2.9.13"

@dr-jts
Copy link
Contributor

dr-jts commented Nov 3, 2023

This is due to the same issue discussed here. It's due to a limitation in the design of the algorithm for handling GeometryCollections.

@dr-jts dr-jts added the Bug label Nov 3, 2023
@dr-jts dr-jts changed the title ContainsProperly returns true when POINT A is on the boundary of Geometry B ContainsProperly returns true when POINT B is on the boundary of GeometryCollection A Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants