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 gives incorrect answer after mutating POLYGON to MULTIPOLYGON #1027

Open
cuteDen-ECNU opened this issue Jan 14, 2024 · 0 comments
Open
Labels

Comments

@cuteDen-ECNU
Copy link

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:
6f70b63

@cuteDen-ECNU cuteDen-ECNU changed the title ST_Covers give incorrect answer after mutating POLYGON to MULTIPOLYGON ST_Covers gives incorrect answer after mutating POLYGON to MULTIPOLYGON Jan 14, 2024
@dr-jts dr-jts added the Bug label Jan 24, 2024
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