Class DynamicRoutingEngine

java.lang.Object
com.here.NativeBase
com.here.sdk.trafficawarenavigation.DynamicRoutingEngine

public final class DynamicRoutingEngine extends NativeBase

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 updateCurrentLocation(com.here.sdk.navigation.MapMatchedLocation, int).

  • Constructor Details

  • Method Details

    • start

      public void start(@NonNull Route route, @NonNull DynamicRoutingListener listener) throws DynamicRoutingEngine.StartException

      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.

      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.

      listener -

      The listener to receive the events.

      Throws:
      DynamicRoutingEngine.StartException -

      when the passed parameter are invalid.

    • start

      @Deprecated public void start(@NonNull RouteHandle routeHandle, @NonNull List<Waypoint> waypoints, @NonNull RefreshRouteOptions refreshRouteOptions, @NonNull DynamicRoutingListener listener) throws DynamicRoutingEngine.StartException
      Deprecated.

      Will be removed in v4.28.0. Use the start() method with RoutingOptions parameter instead.

      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.

      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.

      listener -

      The listener to receive the events.

      Throws:
      DynamicRoutingEngine.StartException -

      when the passed parameter are invalid.

    • start

      public void start(@NonNull RouteHandle routeHandle, @NonNull List<Waypoint> waypoints, @NonNull RoutingOptions routingOptions, @NonNull DynamicRoutingListener listener) throws DynamicRoutingEngine.StartException

      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.

      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.

      listener -

      The listener to receive the events.

      Throws:
      DynamicRoutingEngine.StartException -

      when the passed parameter are invalid.

    • stop

      public void stop()

      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.

    • updateCurrentLocation

      public void updateCurrentLocation(@NonNull MapMatchedLocation mapMatchedLocation, int sectionIndex)

      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.

      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.