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

Correct index of closest coordinate when rounding up #74

Merged
merged 3 commits into from
Dec 17, 2018

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented Dec 15, 2018

Clients of LineString.closestCoordinate(to:) expect the resulting index to be rounded down even when the coordinate is rounded up. Both the method and the test have been corrected for consistency with Turf.js. Specifically, the line string in this test fixture has three vertices, not two.

This change has the downstream effect of stabilizing LineString.sliced(from:to:) and LineString.distance(from:to:).

Fixes #27. Reverts a noncritical part of mapbox/mapbox-navigation-ios#284.

/cc @frederoni @JThramer

1ec5 added 3 commits December 15, 2018 11:36
Despite rounding up, clients of this method expect the index to still be rounded down. Both the method and the test have been corrected for consistency with Turf.js.
@1ec5 1ec5 added bug op-ex Refactoring, Tech Debt or any other operational excellence work. labels Dec 15, 2018
@1ec5 1ec5 self-assigned this Dec 15, 2018
@1ec5 1ec5 requested review from frederoni and JThramer December 15, 2018 19:45
Copy link
Contributor

@frederoni frederoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch. Would be cool and beneficial to have custom debug quick look views for all GeoJSON geometries and features including GeoJSON CSS to visualize assertions.

@1ec5 1ec5 merged commit b141a7f into master Dec 17, 2018
@1ec5 1ec5 deleted the 1ec5-linestring-distance-index-27 branch December 17, 2018 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug op-ex Refactoring, Tech Debt or any other operational excellence work.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent results from Polyline.distance
2 participants