DynamicRoutingEngine

public class DynamicRoutingEngine
extension DynamicRoutingEngine: NativeBase
extension DynamicRoutingEngine: Hashable

This class queries the HERE routing backend to find routes with less traffic and therefore an earlier remaining estimated time of arrival.

DynamicRoutingEngine polls the HERE routing backend periodically to find the best new route out of a given initial route. For initial route calculation it is recommended to use the RoutingEngine as it already requests traffic-optimized routes.

When a better route is found, it is recommended to follow these steps to set the new route:

  1. Stop the DynamicRoutingEngine.
  2. Update the currently active Navigatorinstance with the newly found route.
  3. Restart the DynamicRoutingEngine. This should be done outside of the onBetterRouteFound() callback.

For both DynamicRoutingEngine and RoutingEngine, the resulting routes are optimized based on speed flow changes such as traffic jams, street closures or road accidents. To get the best result, it is recommended to not specify the RouteOptions.departureTime as then the current time is used by default.

The poll interval is defined by DynamicRoutingEngineOptions.pollInterval and triggered by DynamicRoutingEngine.updateCurrentLocation(...).

  • Start exception

    Declaration

    Swift

    public typealias StartException = DynamicRoutingEngine.StartError
  • Creates a new instance of this class.

    Throws

    InstantiationError when the engine was not initialized properly.

    Declaration

    Swift

    public init(options: DynamicRoutingEngineOptions?) throws

    Parameters

    options

    The options defining the behavior of the DynamicRoutingEngine.

  • Creates a new instance of this class.

    Throws

    InstantiationError when the engine was not initialized properly.

    Declaration

    Swift

    public init(_ sdkEngine: SDKNativeEngine, options: DynamicRoutingEngineOptions?) throws

    Parameters

    sdkEngine

    Instance of an existing SDKEngine.

    options

    The options defining the behavior of the DynamicRoutingEngine.

  • Start error

    See more

    Declaration

    Swift

    public enum StartError : UInt32, CaseIterable, Codable
    extension DynamicRoutingEngine.StartError : Error
  • Starts polling the HERE backend services to find a better route, as defined by the DynamicRoutingEngineOptions.

    Note: The engine will be internally stopped, if it was started before. Therefore, it is not necessary to stop the engine before starting it again.

    Throws

    DynamicRoutingEngine.StartException when the passed parameter are invalid.

    Declaration

    Swift

    public func start(route: Route, delegate: DynamicRoutingDelegate) throws

    Parameters

    route

    The route to be refreshed. The route must contain a RouteHandle, therefore the route must have been requested with RouteOptions.enableRouteHandle set to true. The information to calculate new routes will be extracted from the provided route parameter. If more information from the original waypoints is important besides their location, consider to use one of the overloaded methods instead.

    delegate

    The listener to receive the events.

  • Starts polling the HERE backend services to find a better route, as defined by the DynamicRoutingEngineOptions.

    Note: The engine will be internally stopped, if it was started before. Therefore, it is not necessary to stop the engine before starting it again.

    Throws

    DynamicRoutingEngine.StartException when the passed parameter are invalid.

    Declaration

    Swift

    public func start(routeHandle: RouteHandle, waypoints: [Waypoint], refreshRouteOptions: RefreshRouteOptions, delegate: DynamicRoutingDelegate) throws

    Parameters

    routeHandle

    The route handle from the HERE routing backend.

    waypoints

    Allows to specify detailed information on the waypoints of the route. This parameter can be useful, when additional information needs to be specified besides the coordinates - as the coordinates can be retrieved from the contained RoutePlace that are already contained in the RouteHandle parameter.

    refreshRouteOptions

    The options for the route calculation.

    delegate

    The listener to receive the events.

  • Starts polling the HERE backend services to find a better route, as defined by the DynamicRoutingEngineOptions.

    Note: The engine will be internally stopped, if it was started before. Therefore, it is not necessary to stop the engine before starting it again.

    Throws

    DynamicRoutingEngine.StartException when the passed parameter are invalid.

    Declaration

    Swift

    public func start(routeHandle: RouteHandle, waypoints: [Waypoint], routingOptions: RoutingOptions, delegate: DynamicRoutingDelegate) throws

    Parameters

    routeHandle

    The route handle from the HERE routing backend.

    waypoints

    Allows to specify detailed information on the waypoints of the route. This parameter can be useful, when additional information needs to be specified besides the coordinates - as the coordinates can be retrieved from the contained RoutePlace that are already contained in the RouteHandle parameter.

    routingOptions

    The options for the route calculation.

    delegate

    The listener to receive the events.

  • Stops polling the HERE backend services.

    Note: The engine is not automatically stopped when the destination is reached. Therefore, it is recommended to stop the engine when the destination was reached.

    Declaration

    Swift

    public func stop()
  • Updates the current location. This location will be used as new starting point when the next DynamicRoutingEngineOptions.pollInterval is reached and a new route is requested. If an immediate route update is needed, consider to use the RoutingEngine instead. All subsequently calculated routes used for the ETA calculation will start from this location. The location needs to lie on the route or a RoutingError will be issued.

    Declaration

    Swift

    public func updateCurrentLocation(mapMatchedLocation: MapMatchedLocation, sectionIndex: Int32)

    Parameters

    mapMatchedLocation

    The last known location. It is recommended to use a NavigableLocation.mapMatchedLocation as the driver is expected to be on a road.

    sectionIndex

    The current section from RouteProgress.sectionIndex.