-
Notifications
You must be signed in to change notification settings - Fork 369
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 incorrect for Line/Point due to geometric robustness #968
Comments
This is indeed a bug. Ironically it's due to the high-precision evaluation of the line-point orientation predicate. Not sure what a suitable fix is at the moment. Likely it will involve some sort of precision rounding, but that needs to be done carefully to ensure there are no other impacts. |
Thank you for your prompt response. It's greatly appreciated. |
The PostGIS The bottom line is that you can't rely on topological relationships being preserved through floating-point operations. This is the essence of the well-known issue of geometrical robustness failures. The solution is usually either to use exact arithmetic (often impractical) or use tolerance values (not a panacea, but very often works). |
Thank you for your prompt response. |
I'm working on a new implementation of spatial predicate evaluation that should allow for a tolerance value. So stay tuned! |
The tolerance value for predicate evaluation sounds good! |
Could this be the same problem reported in https://lists.osgeo.org/pipermail/geos-devel/2024-March/011012.html ? |
Yes, it's the same issue. In this case, the intersection of the two lines is computed as being equal to the endpoint of one of the lines, due to roundoff error. So the relate result for two lines is inconsistent with the result for the boundary points. Unfortunately the new relate algorithm doesn't fix this. |
This exact thing is happening also with GEOS C++ API v3.12.1 using Is there currently any fast and easy workaround? I thought about these two solutions:
I think the first workaround is more efficient, but could you give me your opinion? |
Yes, using That's a good work-around for this issue. Perhaps in the future RelateNG will support a distance tolerance, which will have the same effect. |
One possible for for this is to use FP computation in the Orientation predicate, and use the result if the point and line are collinear; otherwise use the DD computation for more accuracy. This changes a whole bunch of unit test results, however (which may not indicate a problem, just different results). |
Consider the following code:
Line a should cover point b because the distance between point b and line a is 0.
But Shapely doesn't consider line a covers point b.
The issue cannot be reproduced with integers only, indicating a potential floating-point issue. After all coordinate points are magnified ten times, the results are in line with expectations.
The text was updated successfully, but these errors were encountered: