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

ST_Covers give incorrect answer after mutating POLYGON to MULTIPOLYGON. #41

Open
cuteDen-ECNU opened this issue Jan 14, 2024 · 1 comment
Labels
bug-confirm libgeos sytax trans Add point to the boundary of geometry

Comments

@cuteDen-ECNU
Copy link
Owner

cuteDen-ECNU commented Jan 14, 2024

Considering the following statement:

SELECT ST_Covers(g2, g1), ST_Covers(g3, g1) FROM
(SELECT 
ST_GeomFromText('GEOMETRYCOLLECTION ( LINESTRING (1 2, 1 1), POINT (0 0))') As g1
, ST_GeomFromText(' MULTIPOLYGON (((0 0, 3 0, 3 3, 0 3, 0 0)))  ') As g2
, ST_GeomFromText(' POLYGON ((0 0, 3 0, 3 3, 0 3, 0 0))  ') As g3
);
-- expected: {true, true}; actual: {false, true}

The 2nd geometry covers the 1st one, because each point in the 1st geometry lies inside the 2nd one, according to the definition of ST_Covers:

ST_Covers(A, B) ⇔ A ⋂ B = B

However, PostGIS doesn't consider the ST_Covers relation, which seems to be a bug. After normalizing MULTIPOLYGON to POLYGON as g3, ST_Covers(g3, g1) gives the correct answer.

Here is a simple reproduction for libgeos:

bin/geosop -a 'GEOMETRYCOLLECTION ( LINESTRING (1 2, 1 1), POINT (0 0))' -b 'MULTIPOLYGON (((0 0, 3 0, 3 3, 0 3, 0 0)))' covers
# false

geos version is the latest one in GitHub:
6f70b63a0d976ce31dd2952094bc1a39209f8a20

@cuteDen-ECNU cuteDen-ECNU added sytax trans Add point to the boundary of geometry libgeos reported labels Jan 14, 2024
@cuteDen-ECNU
Copy link
Owner Author

bugtracker link: libgeos/geos#1027

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-confirm libgeos sytax trans Add point to the boundary of geometry
Projects
None yet
Development

No branches or pull requests

1 participant