diff --git a/MapboxCoreNavigation/MBRouteController.h b/MapboxCoreNavigation/MBRouteController.h index d90cfee324e..fd52f5cd0ff 100644 --- a/MapboxCoreNavigation/MBRouteController.h +++ b/MapboxCoreNavigation/MBRouteController.h @@ -3,7 +3,7 @@ /** Posted when `MBRouteController` receives a user location update representing movement along the expected route. - The user info dictionary contains the keys `MBRouteControllerRouteProgressKey`, `MBRouteControllerLocationKey`, and `MBRouteControllerEstimatedTimeUntilManeuverKey`. + The user info dictionary contains the keys `MBRouteControllerRouteProgressKey` and `MBRouteControllerLocationKey`. :nodoc: */ @@ -62,11 +62,6 @@ extern const MBRouteControllerNotificationUserInfoKey MBRouteControllerRouteProg */ extern const MBRouteControllerNotificationUserInfoKey MBRouteControllerLocationKey; -/** - A key in the user info dictionary of a `Notification.Name.RouteControllerProgressDidChange` notification. The corresponding value is an `NSNumber` instance containing a double value indicating the estimated time remaining, in seconds, until the user reaches the next maneuver point. - */ -extern const MBRouteControllerNotificationUserInfoKey MBRouteControllerEstimatedTimeUntilManeuverKey; - /** A key in the user info dictionary of a `Notification.Name.RouteControllerDidFailToReroute` notification. The corresponding value is an `NSError` object indicating why `RouteController` was unable to calculate a new route. */ diff --git a/MapboxCoreNavigation/MBRouteController.m b/MapboxCoreNavigation/MBRouteController.m index d8884dde5d6..ce5dbad2ca7 100644 --- a/MapboxCoreNavigation/MBRouteController.m +++ b/MapboxCoreNavigation/MBRouteController.m @@ -8,7 +8,6 @@ const MBRouteControllerNotificationUserInfoKey MBRouteControllerRouteProgressKey = @"progress"; const MBRouteControllerNotificationUserInfoKey MBRouteControllerLocationKey = @"location"; -const MBRouteControllerNotificationUserInfoKey MBRouteControllerEstimatedTimeUntilManeuverKey = @"seconds"; const MBRouteControllerNotificationUserInfoKey MBRouteControllerRoutingErrorKey = @"error"; const MBRouteControllerNotificationUserInfoKey MBRouteControllerIsOpportunisticKey = @"RouteControllerDidFindFasterRoute"; diff --git a/MapboxCoreNavigation/RouteController.swift b/MapboxCoreNavigation/RouteController.swift index be038d9d579..a60161e0844 100644 --- a/MapboxCoreNavigation/RouteController.swift +++ b/MapboxCoreNavigation/RouteController.swift @@ -36,7 +36,7 @@ extension Notification.Name { /** Posted when `RouteController` receives a user location update representing movement along the expected route. - The user info dictionary contains the keys `RouteControllerNotificationUserInfoKey.routeProgressKey`, `RouteControllerNotificationUserInfoKey.locationKey`, and `RouteControllerNotificationUserInfoKey.estimatedTimeUntilManeuverKey`. + The user info dictionary contains the keys `RouteControllerNotificationUserInfoKey.routeProgressKey` and `RouteControllerNotificationUserInfoKey.locationKey`. */ public static let routeControllerProgressDidChange = MBRouteControllerProgressDidChange @@ -617,8 +617,6 @@ extension RouteController: CLLocationManagerDelegate { } let polyline = Polyline(routeProgress.currentLegProgress.currentStep.coordinates!) - guard let userSnapToStepDistanceFromManeuver = userSnapToStepDistanceFromManeuver else { return } - let secondsToEndOfStep = userSnapToStepDistanceFromManeuver / location.speed let currentStepProgress = routeProgress.currentLegProgress.currentStepProgress let currentStep = currentStepProgress.step @@ -626,21 +624,17 @@ extension RouteController: CLLocationManagerDelegate { if let closestCoordinate = polyline.closestCoordinate(to: location.coordinate) { let remainingDistance = polyline.distance(from: closestCoordinate.coordinate) let distanceTraveled = currentStep.distance - remainingDistance - if distanceTraveled != currentStepProgress.distanceTraveled { - currentStepProgress.distanceTraveled = distanceTraveled - NotificationCenter.default.post(name: .routeControllerProgressDidChange, object: self, userInfo: [ - RouteControllerNotificationUserInfoKey.routeProgressKey: routeProgress, - RouteControllerNotificationUserInfoKey.locationKey: location, - RouteControllerNotificationUserInfoKey.estimatedTimeUntilManeuverKey: secondsToEndOfStep - ]) - } + currentStepProgress.distanceTraveled = distanceTraveled + NotificationCenter.default.post(name: .routeControllerProgressDidChange, object: self, userInfo: [ + RouteControllerNotificationUserInfoKey.routeProgressKey: routeProgress, + RouteControllerNotificationUserInfoKey.locationKey: location + ]) } updateDistanceToIntersection(from: location) updateRouteStepProgress(for: location) updateRouteLegProgress(for: location) - guard userIsOnRoute(location) || !(delegate?.routeController?(self, shouldRerouteFrom: location) ?? true) else { reroute(from: location) return diff --git a/MapboxNavigation/NavigationViewController.swift b/MapboxNavigation/NavigationViewController.swift index 7d546c8fba5..27d1c9fc629 100644 --- a/MapboxNavigation/NavigationViewController.swift +++ b/MapboxNavigation/NavigationViewController.swift @@ -396,7 +396,7 @@ public class NavigationViewController: UIViewController, RouteMapViewControllerD @objc func progressDidChange(notification: NSNotification) { let routeProgress = notification.userInfo![RouteControllerNotificationUserInfoKey.routeProgressKey] as! RouteProgress let location = notification.userInfo![RouteControllerNotificationUserInfoKey.locationKey] as! CLLocation - let secondsRemaining = notification.userInfo![RouteControllerNotificationUserInfoKey.estimatedTimeUntilManeuverKey] as! TimeInterval + let secondsRemaining = routeProgress.currentLegProgress.currentStepProgress.durationRemaining mapViewController?.notifyDidChange(routeProgress: routeProgress, location: location, secondsRemaining: secondsRemaining)