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

Covers predicate fails for Line/Point due to geometric robustness #1

Open
cuteDen-ECNU opened this issue Sep 28, 2023 · 1 comment
Open
Labels
bug-confirm PostGIS sytax trans Add point to the boundary of geometry

Comments

@cuteDen-ECNU
Copy link
Owner

cuteDen-ECNU commented Sep 28, 2023

Geometry Description

The distance from Point c ('POINT( 0.2 0.9)') to Line a ('LINESTRING(2 0, 0 1)') is 0. Line b ('LINESTRING(2 0, 0.2 0.9, 0 1)') is Line a plus Point c.

SELECT ST_Equals(Foo.a, Foo.b), ST_Distance(Foo.a, Foo.c)
    FROM (SELECT ST_GeomFromText('LINESTRING(2 0, 0 1)') As a,
    ST_GeomFromText('LINESTRING(2 0, 0.2 0.9, 0 1)') As b,
    ST_GeomFromText('POINT( 0.2 0.9)') As c) As Foo;

image

Expected Behavior

Line a should equal Line b. As the example in the document [link](https://postgis.net/docs/ST_Equals.html):

SELECT ST_Equals(g1, g2) As g1Equalsg2
FROM (SELECT ST_GeomFromText('LINESTRING(0 0, 10 10)') As g1,
    ST_GeomFromText('LINESTRING(0 0, 5 5, 10 10)') As g2) As Foo;
 
g1equalsg2 
------------
 t
(1 row)

Actual Behavior

PostGIS doesn’t think Line a equals Line b. The following statement is the same as the statement in the geometry description. The result of st_equals is false which means Postgis doesn’t think they are the same line.

SELECT ST_Equals(Foo.a, Foo.b), ST_Distance(Foo.a, Foo.c)
    FROM (SELECT ST_GeomFromText('LINESTRING(2 0, 0 1)') As a,
    ST_GeomFromText('LINESTRING(2 0, 0.2 0.9, 0 1)') As b,
    ST_GeomFromText('POINT( 0.2 0.9)') As c) As Foo;

st_equals | st_distance
-----------+-------------
f         |           0
(1 row)

Additional Information

SQLServer thinks the two LINESTRINGs are equal.

DECLARE @g1 geometry;DECLARE @g2 geometry;DECLARE @g3 geometry;
SET @g1 = geometry::STGeomFromText ('LINESTRING(2 0, 0 1)',0);
SET @g2 = geometry::STGeomFromText ('LINESTRING(2 0, 0.2 0.9, 0 1)',0);
SET @g3 = geometry::STGeomFromText ('POINT(0.2 0.9)',0);
SELECT @g1.STEquals(@g2) As g1Equalsg2

g1Equalsg2
----------
         1

(1 rows affected)
@cuteDen-ECNU cuteDen-ECNU added the sytax trans Add point to the boundary of geometry label Sep 28, 2023
@cuteDen-ECNU
Copy link
Owner Author

cuteDen-ECNU commented Nov 1, 2023

bugtracker link: libgeos/geos#968

@cuteDen-ECNU cuteDen-ECNU changed the title Potential bug in the ST_Equals function. Covers predicate fails for Line/Point due to geometric robustness Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-confirm PostGIS sytax trans Add point to the boundary of geometry
Projects
None yet
Development

No branches or pull requests

1 participant