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

Contains gives the error answer, but ContainsPrep gives the correct one #43

Open
cuteDen-ECNU opened this issue Jan 16, 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 16, 2024

Consider the statement:

DROP TABLE IF EXISTS t0;
CREATE TABLE t0 (id int, geom geometry, valid boolean);
INSERT INTO t0 (id, geom) VALUES (1,ST_GeomFromText('LINESTRING(1 2,1 1)',0));
INSERT INTO t0 (id, geom) VALUES (2,ST_GeomFromText('GEOMETRYCOLLECTION(POINT(2 2),POINT(1 0),LINESTRING(1 2,1 1))',0));
INSERT INTO t0 (id, geom) VALUES (3,ST_GeomFromText('POLYGON((1 0,0 4,2 2,1 0))',0));
SELECT a1.id, a2.id FROM t0 As a1 JOIN t0 As a2 ON ST_Contains(a1.geom, a2.geom);      
-- result: {1,1; 2,1; 2,2; 3,1; 3,2; 3, 3}   
SELECT  ST_Contains(a1.geom, a2.geom) FROM t0 as a1, t0 as a2 WHERE a1.id = 3 and a2.id = 2;
-- expected: true; actual: false

g3 contains g2 because POINTs of g2 lie in the boundary of g3 and LINESTRING of g2 lies in the interior of g3, which satisfied the sematics of contains:

ST_Contains(A, B) ⇔ (A ⋂ B = B) ∧ (Int(A) ⋂ Int(B) ≠ ∅)

I consider the issue different from #982 because the boundary of g3 is not ambiguous.

The predicate of ContainsPrep gives the correct answer. A simple statement reproduced in Geos:

bin/geosop -a 'POLYGON((1 0,0 4,2 2,1 0))' -b 'GEOMETRYCOLLECTION(POINT(2 2),POINT(1 0),LINESTRING(1 2,1 1))' contains
# false
bin/geosop -a 'POLYGON((1 0,0 4,2 2,1 0))' -b 'GEOMETRYCOLLECTION(POINT(2 2),POINT(1 0),LINESTRING(1 2,1 1))' containsPrep
# true

The version of Geos is the latest one:
libgeos/geos@6f70b63

@cuteDen-ECNU cuteDen-ECNU added sytax trans Add point to the boundary of geometry libgeos labels Jan 16, 2024
@cuteDen-ECNU cuteDen-ECNU changed the title Contains gives the error answer, but ContainsPrep gives the right one Contains gives the error answer, but ContainsPrep gives the correct one Jan 16, 2024
@cuteDen-ECNU
Copy link
Owner Author

bugtracker link: libgeos/geos#1033

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