Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

As mentioned above NMRouteNavigator is able to handle rerouting automatically. The feature is enabled by default, but NMRouteNavigator class has the reroutingEnabled property, which can be used to disable or enable the feature. If automatic rerouting handling is enabled, the route navigator tracks the on-route state and, once vehicle the GPS position has got off the route, calculates a new route and applies it. The SDK user can get callbacks Callbacks about the automatic rerouting process can be gotten by conforming to NMReroutingListener protocol. The protocol has the onReroutingStarted method, which is called once automatic rerouting starts, and the onReroutingFinished: method, which is called once the process finishes. The onReroutingFinished: method has the newRoute parameter, which is a new instance of NMRoute class representing the new route being navigated. The newRoute can be nil if rerouting handling is no longer required (i.e. user GPS position has returned back to the previous route).

The rerouting engine has an algorithm, which attempts tries to use a route the most similar to the one passed to the startNavigatingTheRoute: method. NMRouteNavigator has the reroutingSettings property, which allows to tune the algorithm a bit.

AUTOMATIC REROUTING BY TRAFFIC HANDLING

As mentioned above NMRouteNavigator is able to handle rerouting by traffic automatically. The feature is enabled by default, but NMRouteNavigator class has the reroutingByTrafficEnabled property, which can be used to disable or enable the feature. If automatic rerouting by traffic handling is enabled, the route navigator internally get gets notifications from the traffic service that traffic near the current position was has been updated, and, once it happens, handles rerouting by traffic. User The SDK user gets notifications callbacks about the rerouting by traffic handling process by conforming to NMReroutingByTrafficListener protocol. The protocol has the a single method, which is called once the rerouting by traffic occurred. Here it is the method declaration:

Code Block
languagecpp
- (void)onReroutingByTrafficOccurredWithOldTimeToDestination:(NSInteger)oldTimeToDestinationInSeconds
                                        newTimeToDestination:(NSInteger)newTimeToDestinationInSeconds
                                                    newRoute:(nullable NMRoute *)newRoute
                                          resemblingOldRoute:(BOOL)doesNewRouteResembleOldOne
                                           alternativeRoutes:(nullable NSArray<NMRoute *> *)alternativeRoutes;

Rerouting The rerouting by traffic engine may change create a new instance of NMRoute class instance used for navigation during rerouting by traffic handling. newRoute . The newRoute parameter will have non-null value if that happens. The doesNewRouteResembleOldOne parameter indicates whether the route, being navigated after the rerouting by traffic occurred, is identical (takes the same roads) to the route being navigated before thatrerouting. So , even if the newRoute is non-null nil but the doesNewRouteResembleOldOne is YES, what  means that means is the route being navigated hasn't changed (takes the same roads).

The alternativeRoutes is the parameter is a list of alternative routes with the latest traffic applied, which can be used by user for navigation. To use Use startNavigatingTheRoute: method to start navigation along one of the alternative routes for navigation user need to call startNavigatingTheRoute: method.