public class OfflineRoutingEngine : RoutingProtocol
extension OfflineRoutingEngine: NativeBase
extension OfflineRoutingEngine: Hashable

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.noRouteFound 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 routes (EVCarOptions and EVTruckOptions) are not yet supported. As of now, only car, truck, pedestrian, bus, taxi, scooter and bicycle routes are supported. Other transport modes are not officially supported yet and will fail with RoutingError.invalidParameter.

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.

  • Creates a new instance of this class.

    Throws

    InstantiationError Indicates what went wrong when the instantiation was attempted.

    Declaration

    Swift

    public init() throws
  • Creates a new instance of OfflineRoutingEngine.

    Throws

    InstantiationError Indicates what went wrong when the instantiation was attempted.

    Declaration

    Swift

    public init(_ sdkEngine: SDKNativeEngine) throws

    Parameters

    sdkEngine

    An SDKEngine instance.

  • Creates a new instance of OfflineRoutingEngine.

    Throws

    InstantiationError Indicates what went wrong when the instantiation was attempted.

    Declaration

    Swift

    public init(_ sdkEngine: SDKNativeEngine, options: OfflineRoutingEngineOptions) throws

    Parameters

    sdkEngine

    An SDKEngine instance.

    options

    Options to configure offline routing engine.

  • The traffic data provider that gets internal traffic information considering in routing. If the traffic data provider is nil, traffic is not considered in routing.

    Declaration

    Swift

    public var trafficDataProvider: TrafficDataProvider? { get set }
  • Asynchronously calculates a route from one point to another, passing through the given waypoints in the given order. Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.

    Declaration

    Swift

    @discardableResult
    public func calculateRoute(with waypoints: [Waypoint], options: RoutingOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandle

    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.

    options

    Options describing routing options.

    completion

    Callback object that will be invoked after route calculation. It is always invoked on the main thread.

    Return Value

    Handle that will be used to manipulate the execution of the task.

  • Asynchronously calculates a car route from one point to another, passing through the given waypoints in the given order.

    Declaration

    Swift

    @discardableResult
    public func calculateRoute(with waypoints: [Waypoint], carOptions: CarOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandle

    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.

    carOptions

    Options specific for car route calculation, along with common route options.

    completion

    Callback object that will be invoked after route calculation. It is always invoked on the main thread.

    Return Value

    Handle that will be used to manipulate the execution of the task.

  • Asynchronously calculates a pedestrian route from one point to another, passing through the given waypoints in the given order.

    Declaration

    Swift

    @discardableResult
    public func calculateRoute(with waypoints: [Waypoint], pedestrianOptions: PedestrianOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandle

    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.

    pedestrianOptions

    Options specific for pedestrian route calculation, along with common route options. Note that OptimizationMode.shortest is is not supported for pedestrians and converted to OptimizationMode.fastest automatically.

    completion

    Callback object that will be invoked after route calculation. It is always invoked on the main thread.

    Return Value

    Handle that will be used to manipulate the execution of the task.

  • Asynchronously calculates a truck route from one point to another, passing through the given waypoints in the given order.

    Declaration

    Swift

    @discardableResult
    public func calculateRoute(with waypoints: [Waypoint], truckOptions: TruckOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandle

    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.

    truckOptions

    Options specific for truck route calculation, along with common route options.

    completion

    Callback object that will be invoked after route calculation. It is always invoked on the main thread.

    Return Value

    Handle that will be used to manipulate the execution of the task.

  • Asynchronously calculates a scooter route from one point to another, passing through the given waypoints in the given order.

    Declaration

    Swift

    @discardableResult
    public func calculateRoute(with waypoints: [Waypoint], scooterOptions: ScooterOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandle

    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.

    scooterOptions

    Options specific for scooter route calculation, along with common route options. Note that OptimizationMode.shortest is is not supported for scooters and converted to OptimizationMode.fastest automatically.

    completion

    Callback object that will be invoked after route calculation. It is always invoked on the main thread.

    Return Value

    Handle that will be used to manipulate the execution of the task.

  • Asynchronously calculates a bicycle route from one point to another, passing through the given waypoints in the given order.

    Declaration

    Swift

    @discardableResult
    public func calculateRoute(with waypoints: [Waypoint], bicycleOptions: BicycleOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandle

    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.

    bicycleOptions

    Options specific for bicycle route calculation, along with common route options. Note that OptimizationMode.shortest is is not supported for bicycles and converted to OptimizationMode.fastest automatically.

    completion

    Callback object that will be invoked after route calculation. It is always invoked on the main thread.

    Return Value

    Handle that will be used to manipulate the execution of the task.

  • Asynchronously calculates a taxi route from one point to another, passing through the given waypoints in the given order.

    Declaration

    Swift

    @discardableResult
    public func calculateRoute(with waypoints: [Waypoint], taxiOptions: TaxiOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandle

    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.

    taxiOptions

    Options specific for taxi route calculation, along with common route options. Note that OptimizationMode.shortest is is not supported for taxis and converted to OptimizationMode.fastest automatically.

    completion

    Callback object that will be invoked after route calculation. It is always invoked on the main thread.

    Return Value

    Handle that will be used to manipulate the execution of the task.

  • Asynchronously calculates an electric car route from one point to another, passing through the given waypoints in the given order.

    Declaration

    Swift

    @discardableResult
    public func calculateRoute(with waypoints: [Waypoint], evCarOptions: EVCarOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandle

    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.

    evCarOptions

    Options specific for an electric car route calculation, along with common route options.

    completion

    Callback object that will be invoked after route calculation. It is always invoked on the main thread.

    Return Value

    Handle that will be used to manipulate the execution of the task.

  • Asynchronously calculates an electic truck route from one point to another, passing through the given waypoints in the given order.

    Declaration

    Swift

    @discardableResult
    public func calculateRoute(with waypoints: [Waypoint], evTruckOptions: EVTruckOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandle

    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.

    evTruckOptions

    Options specific for an electric truck route calculation, along with common route options.

    completion

    Callback object that will be invoked after route calculation. It is always invoked on the main thread.

    Return Value

    Handle that will be used to manipulate the execution of the task.

  • Asynchronously calculates a bus route from one point to another, passing through the given waypoints in the given order.

    Declaration

    Swift

    @discardableResult
    public func calculateRoute(with waypoints: [Waypoint], busOptions: BusOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandle

    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.

    busOptions

    Options specific for a bus route calculation, along with common route options.

    completion

    Callback object that will be invoked after route calculation. It is always invoked on the main thread.

    Return Value

    Handle that will be used to manipulate the execution of the task.

  • Asynchronously calculates a private bus route from one point to another, passing through the given waypoints in the given order.

    Declaration

    Swift

    @discardableResult
    public func calculateRoute(with waypoints: [Waypoint], privateBusOptions: PrivateBusOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandle

    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.

    privateBusOptions

    Options specific for a private bus route calculation, along with common route options.

    completion

    Callback object that will be invoked after route calculation. It is always invoked on the main thread.

    Return Value

    Handle that will be used to manipulate the execution of the task.

  • Asynchronously calculates a new route that leads back to the original route. The part of the original route which was already travelled 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.

    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.

    Declaration

    Swift

    @discardableResult
    public func returnToRoute(_ route: Route, startingPoint: Waypoint, lastTraveledSectionIndex: Int32, traveledDistanceOnLastSectionInMeters: Int32, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandle

    Parameters

    route

    A 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.

    startingPoint

    The current location, for example, provided by a RouteDeviation event. The waypoint needs to be of type WaypointType.stopover. Otherwise, an RoutingError.invalidParameter error 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.

    completion

    Callback object that will be invoked after route calculation. It is always invoked on the main thread.

    Return Value

    Handle that will be used to manipulate the execution of the task.

  • Asynchronously recreates a route from the RouteHandle provided, i.e. refreshes a previously calculated route, with the specified RefreshRouteOptions.

    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.

    Declaration

    Swift

    @discardableResult
    public func importRoute(routeHandle: RouteHandle, refreshRouteOptions: RefreshRouteOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandle

    Parameters

    routeHandle

    The route handle holding the route to be refreshed.

    refreshRouteOptions

    Options to import the route from handle.

    completion

    Callback object that will be invoked after refreshing the route. It is always invoked on the main thread.

    Return Value

    Handle that will be used to manipulate the execution of the task.

  • Asynchronously recreates a route from the RouteHandle provided, i.e. refreshes a previously calculated route, with the specified RefreshRouteOptions.

    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. Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.

    Declaration

    Swift

    @discardableResult
    public func importRoute(routeHandle: RouteHandle, options: RoutingOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandle

    Parameters

    routeHandle

    The route handle holding the route to be refreshed.

    options

    Options to import the route from handle.

    completion

    Callback object that will be invoked after refreshing the route. It is always invoked on the main thread.

    Return Value

    Handle that will be used to manipulate the execution of the task.