returnToRouteWithTraveledDistance abstract method
- Route route,
- Waypoint startingPoint,
- int lastTraveledSectionIndex,
- int traveledDistanceOnLastSectionInMeters,
- CalculateRouteCallback callback,
Asynchronously calculates a new route that leads back to the original route.
The part of the original route which was already traveled by the user is ignored.
Note: Stopover waypoints are guaranteed to be visited. Pass-through waypoints will be ignored. Additionally, the following route options are ignored: RouteOptions.alternatives, RouteOptions.arrivalTime, and RouteOptions.optimizationMode. Most route options are only applied to the newly calculated part back to the route.
An application may use this method to submit a new starting point for a previously calculated route. This method tries to avoid a costly route re-calculation as much as possible. In case returning to the route without re-calculation is not possible, a new route is calculated, while trying to salvage the previous route as much as possible. However, a completely new route containing no part of the previous route is possible, too.
Note that this function uses only a limited amount of map data around the new origin. Therefore, it may also work fine with temporarily cached map data. It may also copy some of the original route data into the new route.
A typical use case is to await at least 3 RouteDeviation events before calling this method.
- Or alternatively, wait at least 10 seconds after getting the first deviation event.
- On top, the user experience can be improved by checking if the vehicle has moved at least 50 meters since calling this method for the last time.
- Optionally, it may make sense to verify if the vehicle was ever following the route by checking if
RouteDeviation.lastLocationOnRouteis set.
Note that deviation events are sent each time a deviation is detected, i.e. for each new location update, regardless if the location has changed or not. More information can be found in the Developer Guide in the "Handle route deviations" section.
-
routeA Route calculated using the online or offline route engine. For the offline case, It should not contain an indoor Section as such routes will fail. For the online case, it should have RouteHandle. -
startingPointThe current location, for example, provided by aRouteDeviationevent. The waypoint needs to be of type WaypointType.stopover. Otherwise, an RoutingError.invalidParameter error is generated. -
lastTraveledSectionIndexIndicates the index of the last traveled route section. Traveled part of the route won't be reused. -
traveledDistanceOnLastSectionInMetersOffset in meter to the last visited position on the route section defined by the last traveled section index. -
callbackCallback object that will be invoked after route calculation. It is always invoked on the main thread.
Returns TaskHandle. Handle that will be used to manipulate the execution of the task.
Implementation
TaskHandle returnToRouteWithTraveledDistance(Route route, Waypoint startingPoint, int lastTraveledSectionIndex, int traveledDistanceOnLastSectionInMeters, CalculateRouteCallback callback);