-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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 closest layer point edge case #9114
base: main
Are you sure you want to change the base?
Fix closest layer point edge case #9114
Conversation
This PR seems to break Polyline.closestLayerPoint, adding new edge between last and first point, and even for a Polygon this shouldn't work when clipping occures. I'd try to construct polygon with both start and last points outside the screen. This should give reduced _parts arrays, and closestLayerPoint would find a point on the [last point; first point] edge, which doesn't exist in original polygon. Serge, author of #9098 |
@se-ti you are right, good catch 👍 but this problem already oocurs on polylines too and has not directly something to do with #9098 Demo Polyline: https://plnkr.co/edit/TzzbNQf5ljXTGRV2 If I read the docs, I would think it will return always the closest point and has nothing todo with clipping. So my suggestion is to do a refactoring and use the actual latlngs (projected to points) and not the clipped parts. |
I agree about docs, @Falke-Design. |
If we replace @mourner @IvanSanchez @jonkoops do you see any problems if we use |
Thought for a while: if you decide to rewrite closestLayerPoint from _parts to _rings, could you please return not only point and distance, but also ring's index, and point's index in ring. (point -- starting point of the edge, closestLayerPoint belongs to). I used closestLayerPoint's as a second filter (after bounding box) when looking for a nearest edge of large and complex geometries. But to find nearest edge i had to rewrite closestLayerPoint for a latlngs array and call it one more time, just to find those indices. |
This pull request addresses an edge case in the closestLayerPoint function where it did not properly consider the segment between the last and first points of a Polygon.
Details:
Testing:
Related Issues:
Fixes: #9098