mapbox / mapbox-navigation-ios

Turn-by-turn navigation logic and UI in Swift on iOS
https://docs.mapbox.com/ios/navigation/
Other
861 stars 314 forks source link

Use speed limit from NavNative in turn-by-turn navigation #3395

Open azarovalex opened 3 years ago

azarovalex commented 3 years ago

Right now in the active navigation we use the speed limit from the Directions response: https://github.com/mapbox/mapbox-navigation-ios/blob/89708651afae2e98ec774d7d2e00c7773aa87fcc/Sources/MapboxCoreNavigation/RouteLegProgress.swift#L209-L236

It's better to migrate to the values returned by NavNative, because they may contain speed limits from the route graph even if the Directions response is missing these values.

1ec5 commented 3 years ago

We can introduce a new private property to RouteStepProgress to indicate the current speed limit. RouteController would set it and this RouteLegProgress property would return its value. The existing implementation can be a fallback in case the property hasn’t been set. For example, this would allow an application to get the speed limit at an arbitrary location along the route by constructing a RouteLegProgress, without having to navigate there first. (That said, this implementation isn’t especially complex, so the application could just inline the logic and rely on MapboxDirections functionality for it.)