Skip to content

Latest commit

 

History

History
22 lines (20 loc) · 1.01 KB

41.md

File metadata and controls

22 lines (20 loc) · 1.01 KB

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