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

RelateCompute intersection report inconsistent for lines and boundary points #1064

Open
strk opened this issue Apr 7, 2024 · 5 comments
Open

Comments

@strk
Copy link
Member

strk commented Apr 7, 2024

RelateComputer says there's an intersection between line A interior and and line B boundary but says there is no intersection
between B boundary and A.

Line A: 010200000002000000B02EA9C2AE5430400E3994256830514037F136E82055304039FAE86851305140
Line B: 01020000000200000064AB380D714E3040A38E9F0E1F305140E798A2D4E85430405F5969945C305140

A Interior intersects B boundary in dim = 0

   I B E
I: F 0 1
B: F F 0
E: 1 0 2

A has no intersection with Boundary(B)

   I B E
I: F F 1
B: F F 0
E: 0 F 2 

Reported in https://lists.osgeo.org/pipermail/geos-devel/2024-March/011012.html and confirmed in #968 (comment)

@dr-jts
Copy link
Contributor

dr-jts commented Apr 8, 2024

This is not a bug, but a limitation in the ability to compute the relate matrix due to numeric rounding. In order to correctly compute the relate matrix for two lines the node point must be computed (see locationtech/jts#396 for an example of a case which requires noding for correct evaluation). However, due to numeric roundoff the computed node point equals an endpoint of line B, even though the robust Orientation test reports that it lies in the interior of B.

It's not clear that there is an algorithm which can avoid noding, since this would cause an inconsistency in other cases.

Another future option is to support evaluating predicates with a distance tolerance. This will essentially allow avoiding inconsistency due to roundoff. (However, note that this may not be a solution in itself - when used as part of a bigger process, the entire process must be designed to support using a tolerance.)

@strk
Copy link
Member Author

strk commented May 7, 2024

For the record, GEOS-3.8 gives a different intersection matrix for the two lines, saying there is no interior/boundary intersection. Did 3.8 not have this limitation ?

   I B E
I: F F 1
B: F F 0
E: 1 0 2

@strk
Copy link
Member Author

strk commented May 7, 2024

An XML test for this case was added in #1092 - the test passes in 3.8 branch, fails in main branch:

build/bin/test_xmltester -v ../3.8/tests/xmltester/tests/issue/issue-geos-gh1064.xml 
../3.8/tests/xmltester/tests/issue/issue-geos-gh1064.xml: case1: test1: relatestring(A, B): failed. (0 ms)
        Description: See https://github.com/libgeos/geos/issues/1064
        Geometry A: LINESTRING (16.330791631988802 68.75635661578073, 16.332533372319826 68.75496886016562)
        Geometry B: LINESTRING (16.30641253121884 68.75189557630306, 16.33167771310482 68.75565061843871)
        Expected result: FF1FF0102
        Obtained result: F01FF0102

Files: 1
Tests: 1
Failed: 1
Succeeded: 0

strk added a commit to strk/libgeos that referenced this issue May 7, 2024
strk added a commit to strk/libgeos that referenced this issue May 7, 2024
@strk
Copy link
Member Author

strk commented May 7, 2024

@dr-jts
Copy link
Contributor

dr-jts commented May 7, 2024

For the record, GEOS-3.8 gives a different intersection matrix for the two lines, saying there is no interior/boundary intersection. Did 3.8 not have this limitation ?

This might be due to the change in line intersection computation math, from ttmath to DD (in ec219c0). However, the reason that DD was added is that it fixes other cases which were failing using ttmath.

Note that 3.8 is reporting that there is no intersection between the lines at all. However, the 3.12 Orientation predicate is reporting that there is a proper intersection between them (see image below). This uses the best known algorithm we have, so the only thing we can do is to accept it as the correct analysis of the situation. So in this case 3.8 is "wrong", according to current technology.

image

@dr-jts dr-jts changed the title RelateComputer conflicting boundary intersection report RelateComputer conflicting intersection report May 7, 2024
@dr-jts dr-jts changed the title RelateComputer conflicting intersection report RelateCompute intersection report inconsistent for lines and boundary points May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants