RoutingEngine
public class RoutingEngine : RoutingProtocol
extension RoutingEngine: NativeBase
extension RoutingEngine: Hashable
Use the RoutingEngine to calculate a route from A to B with a number of waypoints in between.
Route calculation is done asynchronously and requires an online connection. The resulting route contains various information such as the polyline, route length in meters, estimated time to traverse along the route and maneuver data.
Note: The engine does not support an unlimited number of waypoints.
The limit is defined by the HERE backend services and may change. For now,
the maximum number of waypoints should be below 200. This value may change
and it is not guaranteed to be stable. If you need to support very large lists
of waypoints, consider to import a route (see importRoute() method) or use
the OfflineRoutingEngine which supports an unlimited number of waypoints.
The OfflineRoutingEngine is only available for Navigate licence.
-
Creates a new instance of this class.
Throws
InstantiationErrorIndicates what went wrong when the instantiation was attempted.Declaration
Swift
public init() throws -
Creates a new instance of RoutingEngine.
Throws
InstantiationErrorIndicates what went wrong when the instantiation was attempted.Declaration
Swift
public init(_ sdkEngine: SDKNativeEngine) throwsParameters
sdkEngineAn SDKEngine instance.
-
Creates a new instance of RoutingEngine.
Throws
InstantiationErrorIndicates what went wrong when the instantiation was attempted.Declaration
Swift
public init(connectionSettings: RoutingConnectionSettings) throwsParameters
connectionSettingsSettings for the route calculation.
-
Creates a new instance of RoutingEngine.
Throws
InstantiationErrorIndicates what went wrong when the instantiation was attempted.Declaration
Swift
public init(_ sdkEngine: SDKNativeEngine, connectionSettings: RoutingConnectionSettings) throwsParameters
sdkEngineAn SDKEngine instance.
connectionSettingsSettings for the route calculation.
-
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) -> TaskHandleParameters
waypointsThe 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.
optionsOptions describing routing options.
completionCallback 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) -> TaskHandleParameters
waypointsThe 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.
carOptionsOptions specific for car route calculation, along with common route options.
completionCallback 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) -> TaskHandleParameters
waypointsThe 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.
pedestrianOptionsOptions specific for pedestrian route calculation, along with common route options. Note that
OptimizationMode.shortestis is not supported for pedestrians and converted toOptimizationMode.fastestautomatically.completionCallback 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) -> TaskHandleParameters
waypointsThe 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.
truckOptionsOptions specific for truck route calculation, along with common route options.
completionCallback 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) -> TaskHandleParameters
waypointsThe 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.
scooterOptionsOptions specific for scooter route calculation, along with common route options. Note that
OptimizationMode.shortestis is not supported for scooters and converted toOptimizationMode.fastestautomatically.completionCallback 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) -> TaskHandleParameters
waypointsThe 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.
bicycleOptionsOptions specific for bicycle route calculation, along with common route options. Note that
OptimizationMode.shortestis is not supported for bicycles and converted toOptimizationMode.fastestautomatically.completionCallback 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) -> TaskHandleParameters
waypointsThe 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.
taxiOptionsOptions specific for taxi route calculation, along with common route options. Note that
OptimizationMode.shortestis is not supported for taxis and converted toOptimizationMode.fastestautomatically.completionCallback 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) -> TaskHandleParameters
waypointsThe 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.
evCarOptionsOptions specific for an electric car route calculation, along with common route options.
completionCallback 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) -> TaskHandleParameters
waypointsThe 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.
evTruckOptionsOptions specific for an electric truck route calculation, along with common route options.
completionCallback 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) -> TaskHandleParameters
waypointsThe 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.
busOptionsOptions specific for a bus route calculation, along with common route options.
completionCallback 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) -> TaskHandleParameters
waypointsThe 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.
privateBusOptionsOptions specific for a private bus route calculation, along with common route options.
completionCallback 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.
-
returnToRoute(_:startingPoint: lastTraveledSectionIndex: traveledDistanceOnLastSectionInMeters: completion: ) 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.
Declaration
Swift
@discardableResult public func returnToRoute(_ route: Route, startingPoint: Waypoint, lastTraveledSectionIndex: Int32, traveledDistanceOnLastSectionInMeters: Int32, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
routeA
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.startingPointThe current location, for example, provided by a
RouteDeviationevent. The waypoint needs to be of typeWaypointType.stopover. Otherwise, anRoutingError.invalidParametererror 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.
completionCallback 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 refreshes a previously calculated route from the provided
RouteHandle, updating the starting point and route metadata based onRefreshRouteOptions. The route shape from the new starting point to the destination remains unchanged, and only metadata such as arrival time and traffic delays are updated. If you only want to refresh the contained traffic information or retrieve updated ETA duration, consider usingRoutingEngine.calculateTrafficOnRoute(Route, Int32, Int32, Double, CalculateTrafficOnRouteCompletionHandler)instead.Calling this method will trigger a new “HERE Routing” transaction, for example, if you are using the Base Plan.
Declaration
Swift
@discardableResult public func refreshRoute(routeHandle: RouteHandle, startingPoint: Waypoint, refreshRouteOptions: RefreshRouteOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
routeHandleThe route handle holding the route to be refreshed.
startingPointUpdates the starting point of the route. It should be of type
WaypointType.stopover. Otherwise, anRoutingError.invalidParametererror is generated. Moreover, it should be very close to the original route specified with theRouteHandle. Since the new starting point is expected to be along the original route, the original route geometry is used to reach the remaining waypoints. The new route will not include theWaypointitems that lie behind the new starting point (i.e. the path that was already travelled). Plus,Route.lengthInMetersandRoute.durationvalues are from the new starting point to the destination. If the new waypoint is too far off the original route, the route refresh may fail and anRoutingError.couldNotMatchOriginerror is triggered. In that case, an application may decide to calculate a new route from scratch.refreshRouteOptionsOptions to refresh the route.
completionCallback 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.
-
refreshRoute(routeHandle:startingPoint: lastTraveledSectionIndex: traveledDistanceOnLastSectionInMeters: refreshRouteOptions: completion: ) Asynchronously refreshes a previously calculated route from the provided
RouteHandle, updating the starting point and route metadata based onRefreshRouteOptions. The route shape from the new starting point to the destination remains unchanged, and only metadata such as arrival time and traffic delays are updated. If you only want to refresh the contained traffic information, consider to useRoutingEngine.calculateTrafficOnRoute(Route, Int32, Int32, Double, CalculateTrafficOnRouteCompletionHandler)instead.Calling this method will trigger a new “HERE Routing” transaction, for example, if you are using the Base Plan.
Declaration
Swift
@discardableResult public func refreshRoute(routeHandle: RouteHandle, startingPoint: Waypoint?, lastTraveledSectionIndex: Int32?, traveledDistanceOnLastSectionInMeters: Int32?, refreshRouteOptions: RefreshRouteOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
routeHandleThe route handle holding the route to be refreshed.
startingPointUpdates the starting point of the route. It should be of type
WaypointType.stopover. Otherwise, anRoutingError.invalidParametererror is generated. Moreover, it should be very close to the original route specified with theRouteHandle. Since the new starting point is expected to be along the original route, the original route geometry is used to reach the remaining waypoints. The new route will not include theWaypointitems that lie behind the new starting point (i.e. the path that was already travelled). Plus,Route.lengthInMetersandRoute.durationvalues are from the new starting point to the destination. If the new waypoint is too far off the original route, the route refresh may fail and anRoutingError.couldNotMatchOriginerror is triggered. In that case, an application may decide to calculate a new route from scratch.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.
refreshRouteOptionsOptions to refresh the route.
completionCallback 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.
-
refreshRoute(routeHandle:startingPoint: lastTraveledSectionIndex: traveledDistanceOnLastSectionInMeters: options: completion: ) Asynchronously refreshes a previously calculated route from the provided
RouteHandle, updating the starting point and route metadata based onRoutingOptions. The route shape from the new starting point to the destination remains unchanged, and only metadata such as arrival time and traffic delays are updated. If you only want to refresh the contained traffic information, consider to useRoutingEngine.calculateTrafficOnRoute(Route, Int32, Int32, Double, CalculateTrafficOnRouteCompletionHandler)instead.Calling this method will trigger a new “HERE Routing” transaction, for example, if you are using the Base Plan. 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 refreshRoute(routeHandle: RouteHandle, startingPoint: Waypoint?, lastTraveledSectionIndex: Int32?, traveledDistanceOnLastSectionInMeters: Int32?, options: RoutingOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
routeHandleThe route handle holding the route to be refreshed.
startingPointUpdates the starting point of the route. It should be of type
WaypointType.stopover. Otherwise, anRoutingError.invalidParametererror is generated. Moreover, it should be very close to the original route specified with theRouteHandle. Since the new starting point is expected to be along the original route, the original route geometry is used to reach the remaining waypoints. The new route will not include theWaypointitems that lie behind the new starting point (i.e. the path that was already traveled). Plus,Route.lengthInMetersandRoute.durationvalues are from the new starting point to the destination. If the new waypoint is too far off the original route, the route refresh may fail and anRoutingError.couldNotMatchOriginerror is triggered. In that case, an application may decide to calculate a new route from scratch.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.
optionsThe options define the vehicle and route options to calculate the route.
completionCallback 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 refreshes a previously calculated route from the provided
RouteHandle, updating the starting point and route metadata based onRoutingOptions. The route shape from the new starting point to the destination remains unchanged, and only metadata such as arrival time and traffic delays are updated. If you only want to refresh the contained traffic information, consider to useRoutingEngine.calculateTrafficOnRoute(Route, Int32, Int32, Double, CalculateTrafficOnRouteCompletionHandler)instead.Calling this method will trigger a new “HERE Routing” transaction, for example, if you are using the Base Plan. 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 refreshRoute(routeHandle: RouteHandle, startingPoint: Waypoint, options: RoutingOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
routeHandleThe route handle holding the route to be refreshed.
startingPointUpdates the starting point of the route. It should be of type
WaypointType.stopover. Otherwise, anRoutingError.invalidParametererror is generated. Moreover, it should be very close to the original route specified with theRouteHandle. Since the new starting point is expected to be along the original route, the original route geometry is used to reach the remaining waypoints. The new route will not include theWaypointitems that lie behind the new starting point (i.e. the path that was already traveled). Plus,Route.lengthInMetersandRoute.durationvalues are from the new starting point to the destination. If the new waypoint is too far off the original route, the route refresh may fail and anRoutingError.couldNotMatchOriginerror is triggered. In that case, an application may decide to calculate a new route from scratch.optionsThe options define the vehicle and route options to calculate the route.
completionCallback 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
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 backend to recreate the route. This happens regularly. Therefore, the route handle is not meant to be persisted for a longer time. Instead, a possible use case can be to plan a route with another HERE service. For example, a HERE REST API that allows to calculate a route on a desktop. Then this route can be transferred via the handle to a mobile device for further use with the HERE SDK.
Declaration
Swift
@discardableResult public func importRoute(routeHandle: RouteHandle, refreshRouteOptions: RefreshRouteOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
routeHandleThe route handle holding the route to be refreshed.
refreshRouteOptionsThe options define the vehicle and route options to calculate the route. Note An [sdk.routing.RoutingError.INVALID_PARAMETER] is generated when the [sdk.routing.EVCarOptions.ensure_reachability] option is set to
true.completionCallback 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 creates a car route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], carOptions: CarOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.carOptionsOptions specific for car route calculation, along with common route options.
completionCallback 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 creates a pedestrian route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], routeStops: [RouteStop], pedestrianOptions: PedestrianOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.routeStopsThe list of RouteStop’s which contains index of location from locations list used for route stop and duration in seconds spent on stop.
pedestrianOptionsOptions specific for pedestrian route calculation, along with common route options. Note that
OptimizationMode.shortestis not supported for pedestrians and converted toOptimizationMode.fastestautomatically.completionCallback 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 creates a bicycle route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], routeStops: [RouteStop], bicycleOptions: BicycleOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.routeStopsThe list of RouteStop’s which contains index of location from locations list used for route stop and duration in seconds spent on stop.
bicycleOptionsOptions specific for bicycle route calculation, along with common route options.
completionCallback 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 creates a scooter route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], routeStops: [RouteStop], scooterOptions: ScooterOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.routeStopsThe list of RouteStop’s which contains index of location from locations list used for route stop and duration in seconds spent on stop.
scooterOptionsOptions specific for scooter route calculation, along with common route options. Note that
OptimizationMode.shortestis not supported for scooters and converted toOptimizationMode.fastestautomatically.completionCallback 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 creates a pedestrian route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], pedestrianOptions: PedestrianOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.pedestrianOptionsOptions specific for pedestrian route calculation, along with common route options. Note that
OptimizationMode.shortestis not supported for pedestrians and converted toOptimizationMode.fastestautomatically.completionCallback 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 creates a bicycle route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], bicycleOptions: BicycleOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.bicycleOptionsOptions specific for bicycle route calculation, along with common route options.
completionCallback 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 creates a scooter route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], scooterOptions: ScooterOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.scooterOptionsOptions specific for scooter route calculation, along with common route options. Note that
OptimizationMode.shortestis not supported for scooters and converted toOptimizationMode.fastestautomatically.completionCallback 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 creates a truck route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], truckOptions: TruckOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.truckOptionsOptions specific for truck route calculation, along with common route options.
completionCallback 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 creates a taxi route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], taxiOptions: TaxiOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.taxiOptionsOptions specific for taxi route calculation, along with common route options. Note that
OptimizationMode.shortestis not supported for taxis and converted toOptimizationMode.fastestautomatically.completionCallback 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 creates a bus route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], busOptions: BusOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.busOptionsOptions specific for bus route calculation, along with common route options.
completionCallback 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 creates a private bus route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or anyway geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], privateBusOptions: PrivateBusOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.privateBusOptionsOptions specific for private bus route calculation, along with common route options.
completionCallback 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 creates an electric car route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], evCarOptions: EVCarOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.evCarOptionsOptions specific for an electric car route calculation, along with common route options. Note An [sdk.routing.RoutingError.INVALID_PARAMETER] is generated when the [sdk.routing.EVCarOptions.ensure_reachability] option is set to
true.completionCallback 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 creates an electric truck route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], evTruckOptions: EVTruckOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.evTruckOptionsOptions specific for an electric truck route calculation, along with common route options.
completionCallback 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 creates a car route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], routeStops: [RouteStop], carOptions: CarOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.routeStopsThe list of RouteStop’s which contains index of location from locations list used for route stop and duration in seconds spent on stop.
carOptionsOptions specific for car route calculation, along with common route options.
completionCallback 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 creates a truck route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], routeStops: [RouteStop], truckOptions: TruckOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.routeStopsThe list of RouteStop’s which contains index of location from locations list used for route stop and duration in seconds spent on stop.
truckOptionsOptions specific for truck route calculation, along with common route options.
completionCallback 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 creates a taxi route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], routeStops: [RouteStop], taxiOptions: TaxiOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.routeStopsThe list of RouteStop’s which contains index of location from locations list used for route stop and duration in seconds spent on stop.
taxiOptionsOptions specific for taxi route calculation, along with common route options. Note that
OptimizationMode.shortestis not supported for taxis and converted toOptimizationMode.fastestautomatically.completionCallback 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 creates a bus route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], routeStops: [RouteStop], busOptions: BusOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.routeStopsThe list of RouteStop’s which contains index of location from locations list used for route stop and duration in seconds spent on stop.
busOptionsOptions specific for bus route calculation, along with common route options.
completionCallback 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 creates a private bus route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or anyway geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], routeStops: [RouteStop], privateBusOptions: PrivateBusOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.routeStopsThe list of RouteStop’s which contains index of location from locations list used for route stop and duration in seconds spent on stop.
privateBusOptionsOptions specific for private bus route calculation, along with common route options.
completionCallback 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 creates an electric car route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], routeStops: [RouteStop], evCarOptions: EVCarOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.routeStopsThe list of RouteStop’s which contains index of location from locations list used for route stop and duration in seconds spent on stop.
evCarOptionsOptions specific for an electric car route calculation, along with common route options. Note An [sdk.routing.RoutingError.INVALID_PARAMETER] is generated when the [sdk.routing.EVCarOptions.ensure_reachability] option is set to
true.completionCallback 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 creates an electric truck route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices.Declaration
Swift
@discardableResult public func importRoute(with locations: [Location], routeStops: [RouteStop], evTruckOptions: EVTruckOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.routeStopsThe list of RouteStop’s which contains index of location from locations list used for route stop and duration in seconds spent on stop.
evTruckOptionsOptions specific for an electric truck route calculation, along with common route options.
completionCallback 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 creates a route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices. 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(with locations: [Location], options: RoutingOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.optionsThe options define the vehicle and route options to calculate the route.
completionCallback 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 creates a route from a sequence of geographic coordinates very close to each other. The route shape will be kept as close as possible to the one provided. For best results please use 1Hz GPS data, or geographic coordinates that have a spacing of a few meters one from the other. For example, such a list of geographic coordinates can be extracted from a GPX trace or a route object from a 3rd party library. Very sparse data may be rejected by the service with an error.
Note: Any restrictions applied to a transport type or provided options will be discarded and reported as violations in
Section.sectionNotices. 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(with locations: [Location], routeStops: [RouteStop], options: RoutingOptions, completion: @escaping CalculateRouteCompletionHandler) -> TaskHandleParameters
locationsThe list of locations used to calculate the route. Note that only the
Location.coordinatesof a location are used to import the route.routeStopsThe list of RouteStop’s which contains index of location from locations list used for route stop and duration in seconds spent on stop.
optionsThe options define the vehicle and route options to calculate the route.
completionCallback 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
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. 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) -> TaskHandleParameters
routeHandleThe route handle holding the route to be refreshed.
optionsThe options define the vehicle and route options to calculate the route.
completionCallback 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.
-
calculateTrafficOnRoute(route:lastTraveledSectionIndex: traveledDistanceOnLastSectionInMeters: completion: ) Asynchronously calculates the traffic along a route starting from the index of the last traveled route section and an offset (in meters) from the last visited position on the section. Call this when only the contained traffic information or the latest ETA duration is needed. This can be called periodically to retrieve updated ETA values during navigation.
Note: Calling this method will trigger a new “HERE Traffic” transaction, for example, if you are using the Base Plan.
Declaration
Swift
public func calculateTrafficOnRoute(route: Route, lastTraveledSectionIndex: Int32, traveledDistanceOnLastSectionInMeters: Int32, completion: @escaping CalculateTrafficOnRouteCompletionHandler) -> TaskHandleParameters
routeA
Routecalculated using the online routing engine. ItsRouteHandleand the original route calculation options will be used to compute the traffic on the route. The original route remains untouched.lastTraveledSectionIndexIndicates the index of the last traveled route section. Traveled part of the route won’t be reused.
traveledDistanceOnLastSectionInMetersOffset, in meters, to the last visited position on the route section defined by the last traveled section index.
completionCallback object that will be invoked after route traffic has been calculated. It is always invoked on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
calculateTrafficOnRoute(route:lastTraveledSectionIndex: traveledDistanceOnLastSectionInMeters: currentChargeInKilowattHours: completion: ) Asynchronously calculates the traffic along an EV car route starting from the index of the last traveled route section and an offset in meters from the last visited position on the section. The field
TrafficOnSpan.consumptionInKilowattHourswill contain the power consumption in kilowatt-hours (kWh) necessary to traverse the span, andRoutePlace.chargeInKilowattHours, insideTrafficOnSection.departurePlaceandTrafficOnSection.arrivalPlace, the estimated battery charge in kilowatt-hours (kWh) when leaving/arriving to a section. Note: Only EV cars are supported.Declaration
Swift
public func calculateTrafficOnRoute(route: Route, lastTraveledSectionIndex: Int32, traveledDistanceOnLastSectionInMeters: Int32, currentChargeInKilowattHours: Double, completion: @escaping CalculateTrafficOnRouteCompletionHandler) -> TaskHandleParameters
routeA
Routecalculated using the online routing engine. ItsRouteHandleand the original route calculation options, along with EV related information likeBatterySpecifications, will be used to compute the traffic on the route. The original route remains untouched.lastTraveledSectionIndexIndicates the index of the last traveled route section. Traveled part of the route won’t be reused.
traveledDistanceOnLastSectionInMetersOffset, in meters, to the last visited position on the route section defined by the last traveled section index.
currentChargeInKilowattHoursCharge level of the vehicle’s battery at the current location (in kWh). It must be non-negative and less than or equal to the value of
BatterySpecifications.totalCapacityInKilowattHours, otherwise theBatterySpecificationsinstance is considered invalid. SetsBatterySpecifications.initialChargeInKilowattHoursto the given value.completionCallback object that will be invoked after route traffic has been calculated. It is always invoked on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
Sets a custom option for routing backend queries. The custom option is applied to all the queries that
RoutingEngineperforms. For a complete list of available parameter names and their valid values, refer to HERE Routing API v8. Note: It’s easy to set a wrong option that makes queries invalid, so make sure you read and understand the backend documentation.Declaration
Swift
public func setCustomOption(name: String, value: String?) -> RoutingError?Parameters
nameAn option name. If the engine already has an option with the same name, the option will be overwritten. The option name must be a non-empty string.
valueAn option value. If the value is
nil, the option will be removed. The option value must be a non-empty string.Return Value
An optional error of setting the option. It’s
nilif the option has been set successfully. It’sRoutingError.INVALID_PARAMETERif the input name and/or value haven’t passed internal validation.