Rerouting (v2.0.x)

When navigating on the route a new route can be calculated and the currently applied route can be changed. This may happen due to the following reasons:

  • when traffic update has happened. In this case the SDK calculates a new route using the updated traffic information. If the new one is better than the old one the SDK will notify you via the onRouteCalculationSucceededWithReason:andInfo: or onRouteCalculationFailedWithReason:andInfo: with NMRouteCalculationReasonReroutingCausedByTraffic reason.
  • when a driver is following the route and at one point, wishing it or not, misses a turn. In this case the SDK initiates route re-calculation which can be distinguished by the NMRouteCalculationReasonRerouting reason passed to the NMRoutingListener callbacks.

To enable/disable this option use reroutingEnabled property of the NMRoutingService. There are also two parameters you can specify defining when re-routing is triggered:

  • timeThresholdForReroutingByTrafficInMinutes - defines that the new route, calculated because of the traffic update, will be applied only if its estimated travel time (ETT) is less than the active route ETT by the specified number of minutes.

  • lengthThresholdForReroutingByTrafficInPercents - defines that the new route, calculated because of the traffic update, will be applied only if its length is less than the active route length by the specified percentage.

//enables rerouting when a route 15 minutes faster or 10% shorter is calculated
[[NMSdk sharedInstance].routingService setReroutingEnabled:YES];
[[NMSdk sharedInstance].routingService setTimeThresholdForReroutingByTrafficInMinutes:15.f];
[[NMSdk sharedInstance].routingService setLengthThresholdForReroutingByTrafficInPercents:10.f];

To be able to react to the routing callbacks you need to implement the NMRoutingListener protocol.


Please note that the SDK will initiate rerouting process only if the current route was calculated from the current position. To calculate route from the current position you must use calculateRouteFromCurrentPositionWithRoutePlan: or calculateRouteFromCurrentPositionWithRoutePlan:andSettings: methods of NMRoutingService.