mapbox / mapbox-navigation-ios

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

passiveLocationDataSourceDidUpdate notifications should include key points #2789

Closed 1ec5 closed 2 years ago

1ec5 commented 3 years ago

When posting a passiveLocationDataSourceDidUpdate notification, PassiveLocationDataSource should include key points in the user info dictionary. The keyPointsKey should be set to a LineString or perhaps an array of CLLocations representing the locations that lead up to the current location, derived from the NavigationStatus.key_points property.

https://github.com/mapbox/mapbox-navigation-ios/blob/fd6d1d1c7067a78d4256b360d260b06a570835ba/MapboxCoreNavigation/PassiveLocationDataSource.swift#L151-L156

Here’s the Android implementation for comparison:

https://github.com/mapbox/mapbox-navigation-android/blob/b9a36dd2b0596d55d42f927609508336e58e0937/libnavigation-core/src/main/java/com/mapbox/navigation/core/trip/session/MapboxTripSession.kt#L502 https://github.com/mapbox/mapbox-navigation-android/blob/fa5a2b059289ba188285ac411d7bf7f250d3780b/libnavigation-core/src/main/java/com/mapbox/navigation/core/trip/session/LocationObserver.kt#L17-L24

/cc @mapbox/navigation-ios @mattlozada

1ec5 commented 3 years ago

As a workaround, PassiveLocationDataSource does emit the latest snapped location as locationKey (also provided in PassiveLocationDataSourceDelegate methods), so you could keep track of the snapped locations as they come in. The downside is that, whenever the map matcher changes its mind about which road the user is traveling along, that cache of historical locations won’t be completely consistent with the current match.

S2Ler commented 2 years ago

@1ec5 passiveLocationDataSourceDidUpdate now contains matching result that contains keypoints.

1ec5 commented 2 years ago

passiveLocationDataSourceDidUpdate now contains matching result that contains keypoints.

For reference, this notification has been renamed to Notification.Name.passiveLocationManagerDidUpdate. As of #3669, mapMatchingResultKey is set to a MapMatchingResult; that class has a keyPoints property.