Fix line2points() to return explicit [longitude, latitude] arrays - #65
Merged
Conversation
Copilot created this pull request from a session on behalf of
ohanssen
July 15, 2026 11:43
View session
ohanssen
marked this pull request as ready for review
July 15, 2026 11:45
There was a problem hiding this comment.
Pull request overview
This PR refines pol.core.MapBrowser#line2points() so it always returns explicit 2D [longitude, latitude] coordinate arrays, while avoiding unnecessary floating-point noise at the start/end points by not using ol.sphere.offset() for those endpoints.
Changes:
- Makes the zero-distance case return an explicit
[[from[0], from[1]]]instead of returning thefromarray directly. - Seeds the result with an exact copy of the start coordinate and appends an exact copy of the end coordinate.
- Keeps intermediate points computed via
ol.sphere.offset(), but pushes them as explicit[pt[0], pt[1]]arrays.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
line2points()was previously usingol.sphere.offset()for all points including the start/end, and returning[from]directly in the zero-distance case — neither made the[longitude, latitude]format explicit, andol.sphere.offset(from, 0, bearing)introduced unnecessary floating-point noise on the first point.Changes
return [from]→return [[from[0], from[1]]][[from[0], from[1]]]— exact, nool.sphere.offset(…, 0, bearing)approximationol.sphere.offsetresult destructured as[pt[0], pt[1]]— explicitly[longitude, latitude][to[0], to[1]]— exact destination, not a geodesic offset approximation of it