mapbox / mapbox/mapbox-navigation-ios
Route progress should track shape index
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 918
- Forks
- 326
- Avg merge
- 1h 16m
- Merged PRs (30d)
- 3
Description
RouteStep and possibly RouteLeg and Route should have a `shapeIndex` property that tracks the index of the closest coordinate to the current location in the current step’s shape. This change would keep client code from having to call `LineString.closestCoordinate(to:)` for the same information.
This property can be updated automatically whenever `RouteStepProgress.distanceTraveled` changes. There is a cost to performing this calculation, but it turns out that plenty of code is already redundantly performing the same calculation on every location update.
`MBNavigationStatus.shapeIndex` apparently already tracks the same information, and it would be nice to just use that value instead of recalculating the closest coordinate, potentially inconsistently. However, RouteStep’s public API allows client code to manually set `distanceTraveled` (as well as `intersectionIndex` for that matter), so I’m leery of allowing clients to accidentally set just `distanceTraveled` without also updating `shapeIndex` and `intersectionIndex`.
/cc @mapbox/navigation-ios
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading RouteStep, RouteLeg, Route, and RouteStepProgress.distanceTraveled, then compare MBNavigationStatus.shapeIndex with LineString.closestCoordinate(to:). Done means progress exposes a consistent shapeIndex without requiring clients to repeat the closest-coordinate calculation, while accounting for manually set distanceTraveled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api, mobile
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100