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:
- Stop the
DynamicRoutingEngine. - Update the currently active
Navigatorinstance with the newly found route. - Restart the
DynamicRoutingEngine. This should be done outside of theonBetterRouteFound()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
InstantiationErrorwhen the engine was not initialized properly.Declaration
Swift
public init(options: DynamicRoutingEngineOptions?) throwsParameters
optionsThe options defining the behavior of the
DynamicRoutingEngine. -
Creates a new instance of this class.
Throws
InstantiationErrorwhen the engine was not initialized properly.Declaration
Swift
public init(_ sdkEngine: SDKNativeEngine, options: DynamicRoutingEngineOptions?) throwsParameters
sdkEngineInstance of an existing SDKEngine.
optionsThe options defining the behavior of the
DynamicRoutingEngine. -
Start error
See moreDeclaration
Swift
public enum StartError : UInt32, CaseIterable, Codableextension 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.StartExceptionwhen the passed parameter are invalid.Declaration
Swift
public func start(route: Route, delegate: DynamicRoutingDelegate) throwsParameters
routeThe route to be refreshed. The route must contain a
RouteHandle, therefore the route must have been requested withRouteOptions.enableRouteHandleset totrue. 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.delegateThe 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.StartExceptionwhen the passed parameter are invalid.Declaration
Swift
public func start(routeHandle: RouteHandle, waypoints: [Waypoint], refreshRouteOptions: RefreshRouteOptions, delegate: DynamicRoutingDelegate) throwsParameters
routeHandleThe route handle from the HERE routing backend.
waypointsAllows 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
RoutePlacethat are already contained in theRouteHandleparameter.refreshRouteOptionsThe options for the route calculation.
delegateThe 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.StartExceptionwhen the passed parameter are invalid.Declaration
Swift
public func start(routeHandle: RouteHandle, waypoints: [Waypoint], routingOptions: RoutingOptions, delegate: DynamicRoutingDelegate) throwsParameters
routeHandleThe route handle from the HERE routing backend.
waypointsAllows 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
RoutePlacethat are already contained in theRouteHandleparameter.routingOptionsThe options for the route calculation.
delegateThe 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.pollIntervalis 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 aRoutingErrorwill be issued.Declaration
Swift
public func updateCurrentLocation(mapMatchedLocation: MapMatchedLocation, sectionIndex: Int32)Parameters
mapMatchedLocationThe last known location. It is recommended to use a
NavigableLocation.mapMatchedLocationas the driver is expected to be on a road.sectionIndexThe current section from
RouteProgress.sectionIndex.