-
Notifications
You must be signed in to change notification settings - Fork 373
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
Fix PreparedLineStringDistance for lines within envelope and polygons #959
Conversation
The heuristic could be kept if it is only applied to test geometries whose envelope does not contain the indexed geometry envelope. Not sure if this effort is worth it though? |
Is it sufficient to guard the test with
|
No, because the indexed geometry |
Do you have a test case that would fail? I'm sorry, I've spent a good 20 minutes going over this and I can't understand the problem. |
Actually while this heuristic works in the context of |
I think
|
If the indexed geometry has multiple elements, the computed distance to |
I'd like to commit this particular fix, and move the issue of the correctness of |
You're right, the heuristic can be wrong if
and adding the following test to
|
This PR fixes
PreparedLineStringDistance
to handle the cases:Fixing the first situation requires removing an invalid heuristic check from
IndexedFacetDistance.isWithinDistance
code:The check attempts to short-circuit the withinDistance test by checking the distance to the envelope polygon of the tested geometry. However,
IndexedFacetDistance
only computes distances to linework, not to polygonal geometries. So the test is incorrect in some cases (such as #958).This heuristic is not in the JTS code.
Fixing the second situation requires an additional point-in-polygon check in
PreparedLineStringDistance.distance
andPreparedLineStringDistance.isWithinDistance
to test for the prepared line (or element of) lying within a test polygonal geometry.Fixes #958.
Fixes #960.