OfflineRoutingEngine (API Reference)
Class OfflineRoutingEngine
- All Implemented Interfaces:
RoutingInterface
Use this class to calculate a route offline from A to B with a number of waypoints in between.
Route calculation is done asynchronously, and requires map data that is
available offline. This can be temporarily cached map data or downloaded
offline map data stored in the persisted storage via MapDownloader.
Note that when using the cache there is a risk of missing data and this may
reduce the overall quality of the route or can result in a
RoutingError.NO_ROUTE_FOUND error.
The resulting route contains various information such as the polyline, route length in meters, estimated time to traverse along the route and maneuver data, but it does not contain traffic information.
Unlike the RoutingEngine (which requires an online connection), this engine
allows to use an unlimited number of waypoints.
As an alternative to this engine, consider to use the RoutingEngine for online
route calculations to get fresher traffic, maneuver, route handles and street
information, and to use a more elaborate algorithms to calculate the fastest route.
For offline bus routing, enable "OFFLINE_BUS_ROUTING" as feature configuration.
For more details, please look at SDKOptions. If this feature is not
enabled, the engine may not be able to find bus routes.
Note: EV routing is available when calculating a route using the RoutingOptions, by setting
the RoutingOptions.evOptions.
Note: Traffic related information is completely excluded.
No historic traffic patterns are taking into consideration for the ETA.
Currently blocked or closed roads or roads with traffic incident are not considered offline, i.e.
the road may pass through such road.
Only seasonal road closures are considered based on the departure time, if given.
Traffic information is only considered for online route calculation with the RoutingEngine.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of this class.OfflineRoutingEngine(SDKNativeEngine sdkEngine) Creates a new instance of OfflineRoutingEngine.OfflineRoutingEngine(SDKNativeEngine sdkEngine, OfflineRoutingEngineOptions options) Creates a new instance of OfflineRoutingEngine. -
Method Summary
Modifier and TypeMethodDescriptioncalculateRoute(List<Waypoint> waypoints, BicycleOptions bicycleOptions, CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0.calculateRoute(List<Waypoint> waypoints, BusOptions busOptions, CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0.calculateRoute(List<Waypoint> waypoints, CarOptions carOptions, CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0.calculateRoute(List<Waypoint> waypoints, EVCarOptions evCarOptions, CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0.calculateRoute(List<Waypoint> waypoints, EVTruckOptions evTruckOptions, CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0.calculateRoute(List<Waypoint> waypoints, PedestrianOptions pedestrianOptions, CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0.calculateRoute(List<Waypoint> waypoints, PrivateBusOptions privateBusOptions, CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0.calculateRoute(List<Waypoint> waypoints, RoutingOptions options, CalculateRouteCallback callback) Asynchronously calculates a route from one point to another, passing through the given waypoints in the given order.calculateRoute(List<Waypoint> waypoints, ScooterOptions scooterOptions, CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0.calculateRoute(List<Waypoint> waypoints, TaxiOptions taxiOptions, CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0.calculateRoute(List<Waypoint> waypoints, TruckOptions truckOptions, CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0.voiddispose()Cancels pending requests and closes the background worker thread.Gets the traffic data provider that provides internal traffic information considering in routing.importRoute(RouteHandle routeHandle, RefreshRouteOptions refreshRouteOptions, CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0.importRoute(RouteHandle routeHandle, RoutingOptions options, CalculateRouteCallback callback) Asynchronously recreates a route from theRouteHandleprovided, i.e.returnToRoute(Route route, Waypoint startingPoint, int lastTraveledSectionIndex, int traveledDistanceOnLastSectionInMeters, CalculateRouteCallback callback) Asynchronously calculates a new route that leads back to the original route.voidsetInternalOption(String key, String value) This method sets internal options that controls offline route calculation behavior.voidSets the traffic data provider that provides internal traffic information considering in routing.
-
Constructor Details
-
OfflineRoutingEngine
Creates a new instance of this class.
- Throws:
InstantiationErrorException-Indicates what went wrong when the instantiation was attempted.
-
OfflineRoutingEngine
Creates a new instance of OfflineRoutingEngine.
- Parameters:
sdkEngine-An SDKEngine instance.
- Throws:
InstantiationErrorException-Indicates what went wrong when the instantiation was attempted.
-
OfflineRoutingEngine
public OfflineRoutingEngine(@NonNull SDKNativeEngine sdkEngine, @NonNull OfflineRoutingEngineOptions options) throws InstantiationErrorException Creates a new instance of OfflineRoutingEngine.
- Parameters:
sdkEngine-An SDKEngine instance.
options-Options to configure offline routing engine.
- Throws:
InstantiationErrorException-Indicates what went wrong when the instantiation was attempted.
-
-
Method Details
-
importRoute
@Deprecated @NonNull public TaskHandle importRoute(@NonNull RouteHandle routeHandle, @NonNull RefreshRouteOptions refreshRouteOptions, @NonNull CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0. Use the
import_route()method with RoutingOptions parameter instead.Asynchronously recreates a route from the
RouteHandleprovided, i.e. refreshes a previously calculated route, with the specifiedRefreshRouteOptions.A route handle can be invalid when the map data changes that is used by the HERE sdk to recreate the route. This happens regularly. Therefore, the route handle is not meant to be persisted for a longer time.
- Parameters:
routeHandle-The route handle holding the route to be refreshed.
refreshRouteOptions-Options to import the route from handle.
callback-Callback object that will be invoked after refreshing the route. It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
importRoute
@NonNull public TaskHandle importRoute(@NonNull RouteHandle routeHandle, @NonNull RoutingOptions options, @NonNull CalculateRouteCallback callback) Asynchronously recreates a route from the
RouteHandleprovided, i.e. refreshes a previously calculated route, with the specifiedRefreshRouteOptions.A route handle can be invalid when the map data changes that is used by the HERE sdk to recreate the route. This happens regularly. Therefore, the route handle is not meant to be persisted for a longer time.
- Parameters:
routeHandle-The route handle holding the route to be refreshed.
options-Options to import the route from handle.
callback-Callback object that will be invoked after refreshing the route. It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
setInternalOption
This method sets internal options that controls offline route calculation behavior. Unsupported options will be logged as warnings. Undocumented options can change their meaning without going through deprecation process.
- Parameters:
key-Option name
value-New option value
-
getTrafficDataProvider
Gets the traffic data provider that provides internal traffic information considering in routing.
If the traffic data provider is
null, traffic is not considered in routing.- Returns:
The traffic data provider that gets internal traffic information considering in routing.
-
setTrafficDataProvider
Sets the traffic data provider that provides internal traffic information considering in routing.
If the traffic data provider is
null, traffic is not considered in routing.- Parameters:
value-The traffic data provider that gets internal traffic information considering in routing.
-
calculateRoute
@NonNull public TaskHandle calculateRoute(@NonNull List<Waypoint> waypoints, @NonNull RoutingOptions options, @NonNull CalculateRouteCallback callback) Asynchronously calculates a route from one point to another, passing through the given waypoints in the given order.
- Specified by:
calculateRoutein interfaceRoutingInterface- Parameters:
waypoints-The list of waypoints used to calculate the route. The first element marks the starting position, the last marks the destination. Waypoints in between are interpreted as intermediate.
An
RoutingError.INVALID_PARAMETERerror is generated when the waypoint list contains less than two elements or when the first and the last waypoints are not of typeWaypointType.STOPOVER.options-Options describing routing options.
callback-Callback object that will be invoked after route calculation. It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
calculateRoute
@Deprecated @NonNull public TaskHandle calculateRoute(@NonNull List<Waypoint> waypoints, @NonNull CarOptions carOptions, @NonNull CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0. Use the
calculate_route()methods with RoutingOptions parameter instead.Asynchronously calculates a car route from one point to another, passing through the given waypoints in the given order.
- Specified by:
calculateRoutein interfaceRoutingInterface- Parameters:
waypoints-The list of waypoints used to calculate the route. The first element marks the starting position, the last marks the destination. Waypoints in between are interpreted as intermediate.
An
RoutingError.INVALID_PARAMETERerror is generated when the waypoint list contains less than two elements or when the first and the last waypoints are not of typeWaypointType.STOPOVER.carOptions-Options specific for car route calculation, along with common route options.
callback-Callback object that will be invoked after route calculation. It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
calculateRoute
@Deprecated @NonNull public TaskHandle calculateRoute(@NonNull List<Waypoint> waypoints, @NonNull PedestrianOptions pedestrianOptions, @NonNull CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0. Use the
calculate_route()methods with RoutingOptions parameter instead.Asynchronously calculates a pedestrian route from one point to another, passing through the given waypoints in the given order.
- Specified by:
calculateRoutein interfaceRoutingInterface- Parameters:
waypoints-The list of waypoints used to calculate the route. The first element marks the starting position, the last marks the destination. Waypoints in between are interpreted as intermediate.
An
RoutingError.INVALID_PARAMETERerror is generated when the waypoint list contains less than two elements or when the first and the last waypoints are not of typeWaypointType.STOPOVER.pedestrianOptions-Options specific for pedestrian route calculation, along with common route options. Note that
OptimizationMode.SHORTESTis is not supported for pedestrians and converted toOptimizationMode.FASTESTautomatically.callback-Callback object that will be invoked after route calculation. It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
calculateRoute
@Deprecated @NonNull public TaskHandle calculateRoute(@NonNull List<Waypoint> waypoints, @NonNull TruckOptions truckOptions, @NonNull CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0. Use the
calculate_route()methods with RoutingOptions parameter instead.Asynchronously calculates a truck route from one point to another, passing through the given waypoints in the given order.
- Specified by:
calculateRoutein interfaceRoutingInterface- Parameters:
waypoints-The list of waypoints used to calculate the route. The first element marks the starting position, the last marks the destination. Waypoints in between are interpreted as intermediate.
An
RoutingError.INVALID_PARAMETERerror is generated when the waypoint list contains less than two elements or when the first and the last waypoints are not of typeWaypointType.STOPOVER.truckOptions-Options specific for truck route calculation, along with common route options.
callback-Callback object that will be invoked after route calculation. It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
calculateRoute
@Deprecated @NonNull public TaskHandle calculateRoute(@NonNull List<Waypoint> waypoints, @NonNull ScooterOptions scooterOptions, @NonNull CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0. Use the
calculate_route()methods with RoutingOptions parameter instead.Asynchronously calculates a scooter route from one point to another, passing through the given waypoints in the given order.
- Specified by:
calculateRoutein interfaceRoutingInterface- Parameters:
waypoints-The list of waypoints used to calculate the route. The first element marks the starting position, the last marks the destination. Waypoints in between are interpreted as intermediate.
An
RoutingError.INVALID_PARAMETERerror is generated when the waypoint list contains less than two elements or when the first and the last waypoints are not of typeWaypointType.STOPOVER.scooterOptions-Options specific for scooter route calculation, along with common route options. Note that
OptimizationMode.SHORTESTis is not supported for scooters and converted toOptimizationMode.FASTESTautomatically.callback-Callback object that will be invoked after route calculation. It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
calculateRoute
@Deprecated @NonNull public TaskHandle calculateRoute(@NonNull List<Waypoint> waypoints, @NonNull BicycleOptions bicycleOptions, @NonNull CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0. Use the
calculate_route()methods with RoutingOptions parameter instead.Asynchronously calculates a bicycle route from one point to another, passing through the given waypoints in the given order.
- Specified by:
calculateRoutein interfaceRoutingInterface- Parameters:
waypoints-The list of waypoints used to calculate the route. The first element marks the starting position, the last marks the destination. Waypoints in between are interpreted as intermediate.
An
RoutingError.INVALID_PARAMETERerror is generated when the waypoint list contains less than two elements or when the first and the last waypoints are not of typeWaypointType.STOPOVER.bicycleOptions-Options specific for bicycle route calculation, along with common route options. Note that
OptimizationMode.SHORTESTis is not supported for bicycles and converted toOptimizationMode.FASTESTautomatically.callback-Callback object that will be invoked after route calculation. It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
calculateRoute
@Deprecated @NonNull public TaskHandle calculateRoute(@NonNull List<Waypoint> waypoints, @NonNull TaxiOptions taxiOptions, @NonNull CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0. Use the
calculate_route()methods with RoutingOptions parameter instead.Asynchronously calculates a taxi route from one point to another, passing through the given waypoints in the given order.
- Specified by:
calculateRoutein interfaceRoutingInterface- Parameters:
waypoints-The list of waypoints used to calculate the route. The first element marks the starting position, the last marks the destination. Waypoints in between are interpreted as intermediate.
An
RoutingError.INVALID_PARAMETERerror is generated when the waypoint list contains less than two elements or when the first and the last waypoints are not of typeWaypointType.STOPOVER.taxiOptions-Options specific for taxi route calculation, along with common route options. Note that
OptimizationMode.SHORTESTis is not supported for taxis and converted toOptimizationMode.FASTESTautomatically.callback-Callback object that will be invoked after route calculation. It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
calculateRoute
@Deprecated @NonNull public TaskHandle calculateRoute(@NonNull List<Waypoint> waypoints, @NonNull EVCarOptions evCarOptions, @NonNull CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0. Use the
calculate_route()methods with RoutingOptions parameter instead.Asynchronously calculates an electric car route from one point to another, passing through the given waypoints in the given order.
- Specified by:
calculateRoutein interfaceRoutingInterface- Parameters:
waypoints-The list of waypoints used to calculate the route. The first element marks the starting position, the last marks the destination. Waypoints in between are interpreted as intermediate.
An
RoutingError.INVALID_PARAMETERerror is generated when the waypoint list contains less than two elements or when the first and the last waypoints are not of typeWaypointType.STOPOVER.evCarOptions-Options specific for an electric car route calculation, along with common route options.
callback-Callback object that will be invoked after route calculation. It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
calculateRoute
@Deprecated @NonNull public TaskHandle calculateRoute(@NonNull List<Waypoint> waypoints, @NonNull EVTruckOptions evTruckOptions, @NonNull CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0. Use the
calculate_route()methods with RoutingOptions parameter instead.Asynchronously calculates an electic truck route from one point to another, passing through the given waypoints in the given order.
- Specified by:
calculateRoutein interfaceRoutingInterface- Parameters:
waypoints-The list of waypoints used to calculate the route. The first element marks the starting position, the last marks the destination. Waypoints in between are interpreted as intermediate.
An
RoutingError.INVALID_PARAMETERerror is generated when the waypoint list contains less than two elements or when the first and the last waypoints are not of typeWaypointType.STOPOVER.evTruckOptions-Options specific for an electric truck route calculation, along with common route options.
callback-Callback object that will be invoked after route calculation. It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
calculateRoute
@Deprecated @NonNull public TaskHandle calculateRoute(@NonNull List<Waypoint> waypoints, @NonNull BusOptions busOptions, @NonNull CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0. Use the
calculate_route()methods with RoutingOptions parameter instead.Asynchronously calculates a bus route from one point to another, passing through the given waypoints in the given order.
- Specified by:
calculateRoutein interfaceRoutingInterface- Parameters:
waypoints-The list of waypoints used to calculate the route. The first element marks the starting position, the last marks the destination. Waypoints in between are interpreted as intermediate.
An
RoutingError.INVALID_PARAMETERerror is generated when the waypoint list contains less than two elements or when the first and the last waypoints are not of typeWaypointType.STOPOVER.busOptions-Options specific for a bus route calculation, along with common route options.
callback-Callback object that will be invoked after route calculation. It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
calculateRoute
@Deprecated @NonNull public TaskHandle calculateRoute(@NonNull List<Waypoint> waypoints, @NonNull PrivateBusOptions privateBusOptions, @NonNull CalculateRouteCallback callback) Deprecated.Will be removed in v4.28.0. Use the
calculate_route()methods with RoutingOptions parameter instead.Asynchronously calculates a private bus route from one point to another, passing through the given waypoints in the given order.
- Specified by:
calculateRoutein interfaceRoutingInterface- Parameters:
waypoints-The list of waypoints used to calculate the route. The first element marks the starting position, the last marks the destination. Waypoints in between are interpreted as intermediate.
An
RoutingError.INVALID_PARAMETERerror is generated when the waypoint list contains less than two elements or when the first and the last waypoints are not of typeWaypointType.STOPOVER.privateBusOptions-Options specific for a private bus route calculation, along with common route options.
callback-Callback object that will be invoked after route calculation. It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
returnToRoute
@NonNull public TaskHandle returnToRoute(@NonNull Route route, @NonNull Waypoint startingPoint, int lastTraveledSectionIndex, int traveledDistanceOnLastSectionInMeters, @NonNull 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, andRouteOptions.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
RouteDeviationevents 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.
- Specified by:
returnToRoutein interfaceRoutingInterface- Parameters:
route-A
Routecalculated using the online or offline route engine. For the offline case, It should not contain an indoorSectionas such routes will fail. For the online case, it should haveRouteHandle.startingPoint-The current location, for example, provided by a
RouteDeviationevent. The waypoint needs to be of typeWaypointType.STOPOVER. Otherwise, anRoutingError.INVALID_PARAMETERerror is generated.lastTraveledSectionIndex-Indicates the index of the last traveled route section. Traveled part of the route won't be reused.
traveledDistanceOnLastSectionInMeters-Offset in meter to the last visited position on the route section defined by the last traveled section index.
callback-Callback object that will be invoked after route calculation. It is always invoked on the main thread.
- Returns:
Handle that will be used to manipulate the execution of the task.
-
dispose
public void dispose()Cancels pending requests and closes the background worker thread. Note: This method should be called from main thread.
- Specified by:
disposein interfaceRoutingInterface
-