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

Reroute proactively, not opportunistically #1230

Merged
merged 1 commit into from
Mar 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

## Master

#### User Interface
#### User interface
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we Caps-casing everything but "User interface"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Everything should be in sentence case. “Core Navigation” is a framework name, so it just looks like title case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Aha! Totally makes sense.

* Added support for abbreviated top banner instructions. [#1169](https://github.com/mapbox/mapbox-navigation-ios/pull/1169)
* Reveal the steps list by swiping down on the top banner. [#1150](https://github.com/mapbox/mapbox-navigation-ios/pull/1150)

#### Core Navigation
* Renamed the `RouteController.reroutesOpportunistically` property to `RouteController.reroutesProactively`, `RouteControllerOpportunisticReroutingInterval` global variable to `RouteControllerProactiveReroutingInterval`, and the `RouteControllerNotificationUserInfoKey.isOpportunisticKey` value to `RouteControllerNotificationUserInfoKey.isProactiveKey`. ([#1230](https://github.com/mapbox/mapbox-navigation-ios/pull/1230))

## v0.15.0 (March 13, 2018)

#### Breaking changes
Expand Down
2 changes: 1 addition & 1 deletion MapboxCoreNavigation/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public var RouteControllerNumberOfSecondsForRerouteFeedback: TimeInterval = 10
/**
The number of seconds between attempts to automatically calculate a more optimal route while traveling.
*/
public var RouteControllerOpportunisticReroutingInterval: TimeInterval = 120
public var RouteControllerProactiveReroutingInterval: TimeInterval = 120

let FasterRouteFoundEvent = "navigation.fasterRoute"

Expand Down
6 changes: 3 additions & 3 deletions MapboxCoreNavigation/MBRouteController.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extern const NSNotificationName MBRouteControllerWillRerouteNotification;
/**
Posted when `MBRouteController` obtains a new route in response to the user diverging from a previous route.

The user info dictionary contains the keys `MBRouteControllerLocationKey` and `MBRouteControllerIsOpportunisticKey`.
The user info dictionary contains the keys `MBRouteControllerLocationKey` and `MBRouteControllerIsProactiveKey`.

:nodoc:
*/
Expand Down Expand Up @@ -73,6 +73,6 @@ extern const MBRouteControllerNotificationUserInfoKey MBRouteControllerRawLocati
extern const MBRouteControllerNotificationUserInfoKey MBRouteControllerRoutingErrorKey;

/**
A key in the user info dictionary of a `Notification.Name.RouteControllerDidReroute` notification. The corresponding value is an `NSNumber` instance containing a Boolean value indicating whether `RouteController` opportunistically rerouted the user onto a faster route.
A key in the user info dictionary of a `Notification.Name.RouteControllerDidReroute` notification. The corresponding value is an `NSNumber` instance containing a Boolean value indicating whether `RouteController` proactively rerouted the user onto a faster route.
*/
extern const MBRouteControllerNotificationUserInfoKey MBRouteControllerIsOpportunisticKey;
extern const MBRouteControllerNotificationUserInfoKey MBRouteControllerIsProactiveKey;
2 changes: 1 addition & 1 deletion MapboxCoreNavigation/MBRouteController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
const MBRouteControllerNotificationUserInfoKey MBRouteControllerLocationKey = @"location";
const MBRouteControllerNotificationUserInfoKey MBRouteControllerRawLocationKey = @"rawLocation";
const MBRouteControllerNotificationUserInfoKey MBRouteControllerRoutingErrorKey = @"error";
const MBRouteControllerNotificationUserInfoKey MBRouteControllerIsOpportunisticKey = @"RouteControllerDidFindFasterRoute";
const MBRouteControllerNotificationUserInfoKey MBRouteControllerIsProactiveKey = @"RouteControllerDidFindFasterRoute";

NSString *const MBErrorDomain = @"ErrorDomain";
16 changes: 8 additions & 8 deletions MapboxCoreNavigation/RouteController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extension Notification.Name {
/**
Posted when `RouteController` obtains a new route in response to the user diverging from a previous route.

The user info dictionary contains the keys `RouteControllerNotificationUserInfoKey.locationKey` and `RouteControllerNotificationUserInfoKey.isOpportunisticKey`.
The user info dictionary contains the keys `RouteControllerNotificationUserInfoKey.locationKey` and `RouteControllerNotificationUserInfoKey.isProactiveKey`.
*/
public static let routeControllerDidReroute = MBRouteControllerDidReroute

Expand Down Expand Up @@ -172,9 +172,9 @@ open class RouteController: NSObject {
@objc public var isDeadReckoningEnabled = false

/**
If true, the `RouteController` attempts to calculate a more optimal route for the user on an interval defined by `RouteControllerOpportunisticReroutingInterval`.
If true, the `RouteController` attempts to calculate a more optimal route for the user on an interval defined by `RouteControllerProactiveReroutingInterval`.
*/
@objc public var reroutesOpportunistically = false
@objc public var reroutesProactively = false

var didFindFasterRoute = false

Expand All @@ -198,7 +198,7 @@ open class RouteController: NSObject {
if let location = locationManager.location {
userInfo[.locationKey] = location
}
userInfo[.isOpportunisticKey] = didFindFasterRoute
userInfo[.isProactiveKey] = didFindFasterRoute
NotificationCenter.default.post(name: .routeControllerDidReroute, object: self, userInfo: userInfo)
}
}
Expand Down Expand Up @@ -465,7 +465,7 @@ extension RouteController {
}

@objc func didReroute(notification: NSNotification) {
if let didFindFasterRoute = notification.userInfo?[RouteControllerNotificationUserInfoKey.isOpportunisticKey] as? Bool, didFindFasterRoute {
if let didFindFasterRoute = notification.userInfo?[RouteControllerNotificationUserInfoKey.isProactiveKey] as? Bool, didFindFasterRoute {
_ = enqueueFoundFasterRouteEvent()
}

Expand Down Expand Up @@ -575,7 +575,7 @@ extension RouteController: CLLocationManagerDelegate {
updateSpokenInstructionProgress(for: location)

// Check for faster route given users current location
guard reroutesOpportunistically else { return }
guard reroutesProactively else { return }
// Only check for faster alternatives if the user has plenty of time left on the route.
guard routeProgress.durationRemaining > 600 else { return }
// If the user is approaching a maneuver, don't check for a faster alternatives
Expand Down Expand Up @@ -663,7 +663,7 @@ extension RouteController: CLLocationManagerDelegate {
}

// Only check every so often for a faster route.
guard location.timestamp.timeIntervalSince(lastLocationDate) >= RouteControllerOpportunisticReroutingInterval else { return }
guard location.timestamp.timeIntervalSince(lastLocationDate) >= RouteControllerProactiveReroutingInterval else { return }
let durationRemaining = routeProgress.durationRemaining

getDirections(from: location) { [weak self] (route, error) in
Expand All @@ -680,7 +680,7 @@ extension RouteController: CLLocationManagerDelegate {
strongSelf.routeProgress = RouteProgress(route: route, legIndex: 0, spokenInstructionIndex: strongSelf.routeProgress.currentLegProgress.currentStepProgress.spokenInstructionIndex)
strongSelf.delegate?.routeController?(strongSelf, didRerouteAlong: route)
strongSelf.didReroute(notification: NSNotification(name: .routeControllerDidReroute, object: nil, userInfo: [
RouteControllerNotificationUserInfoKey.isOpportunisticKey: true
RouteControllerNotificationUserInfoKey.isProactiveKey: true
]))
strongSelf.didFindFasterRoute = false
}
Expand Down
2 changes: 1 addition & 1 deletion MapboxNavigation/RouteMapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class RouteMapViewController: UIViewController {
}
}

if notification.userInfo![RouteControllerNotificationUserInfoKey.isOpportunisticKey] as! Bool {
if notification.userInfo![RouteControllerNotificationUserInfoKey.isProactiveKey] as! Bool {
let title = NSLocalizedString("FASTER_ROUTE_FOUND", bundle: .mapboxNavigation, value: "Faster Route Found", comment: "Indicates a faster route was found")
showStatus(title: title, withSpinner: true, for: 3)
}
Expand Down
2 changes: 1 addition & 1 deletion MapboxNavigation/RouteVoiceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ open class RouteVoiceController: NSObject, AVSpeechSynthesizerDelegate, AVAudioP

@objc func didReroute(notification: NSNotification) {
// Play reroute sound when a faster route is found
if notification.userInfo?[RouteControllerNotificationUserInfoKey.isOpportunisticKey] as! Bool {
if notification.userInfo?[RouteControllerNotificationUserInfoKey.isProactiveKey] as! Bool {
pauseSpeechAndPlayReroutingDing(notification: notification)
}
}
Expand Down