Class RoutePrefetcher

java.lang.Object
com.here.NativeBase
com.here.sdk.prefetcher.RoutePrefetcher

public final class RoutePrefetcher extends NativeBase

Supports downloading of map data - in advance - into the cache to optimize temporary offline use cases that rely on cached map data. This allows scenarios such as navigation to work in a specific area reliably even though the network might be offline at that time. Please note, this class puts data in the map cache, which has its own size constraints, and extensive usage may start evicting old cached data. 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.

  • Constructor Details

    • RoutePrefetcher

      public RoutePrefetcher(@NonNull SDKNativeEngine sdkEngine)

      Creates a RoutePrefetcher instance for a given SDKNativeEngine.

      Parameters:
      sdkEngine -

      Instance of an existing SDKEngine.

  • Method Details

    • prefetchAroundLocationWithRadius

      @Deprecated public void prefetchAroundLocationWithRadius(@NonNull GeoCoordinates currentLocation, @Nullable Double radiusInMeters)

      Prefetches map data within a user-defined circular area around a given location. The radius, specified in meters, must be between 1 km and 50 km. If null is passed as the radius, a default value of 2 km is used. It is recommended to call this method once before starting navigation to ensure a smooth experience.

      To control list of map content features for area prefetch, use LayerConfiguration.enabledFeatures.

      Parameters:
      currentLocation -

      The center of the circle to prefetch data within.

      radiusInMeters -

      The radius of the circle to prefetch data within.

    • prefetchAroundRouteOnIntervals

      public void prefetchAroundRouteOnIntervals(@NonNull NavigatorInterface navigator)

      Prefetches map data within a corridor along the route, that is currently set for the provided NavigatorInterface instance. If no route is set, no data will be prefetched. The route corridor defaults to a length of 10 km and a width of 5 km. To prefetch the whole route before navigation has been started see prefetchGeoCorridor(com.here.sdk.core.GeoCorridor, com.here.sdk.prefetcher.PrefetchStatusListener). Map data is prefetched only in discrete intervals. Prefetching starts 1 km before reaching the end of the current corridor. Prefetching happens based on the current map-matched location - as indicated by the RouteProgress event. This method should be called right after navigation has started. In case of default prefetch length first prefetching will start after traveling a distance of 9 km along the route.

      To control list of map content features for prefetch, use LayerConfiguration.enabledFeatures.

      Parameters:
      navigator -

      The NavigatorInterface to listen for Route Progress to prefetch data ahead.

    • stopPrefetchAroundRoute

      public void stopPrefetchAroundRoute()

      Stops listening NavigatorInterface passed to prefetchAroundRouteOnIntervals(com.here.sdk.navigation.NavigatorInterface) for route progress events and stops prefetching data along the current route.

    • prefetchGeoCorridor

      @NonNull public TaskHandle prefetchGeoCorridor(@NonNull GeoCorridor corridor, @NonNull PrefetchStatusListener callback)

      Prefetch tiles for a given geo-corridor. A geo-corridor can easily be created from a route with Route.getGeometry() so navigation on this route is possible in offline cases. Please note, tiles will be saved in mutable cache so when there is not enough space to accommodate new prefetched tiles MapLoaderError.NOT_ENOUGH_SPACE is returned. When updating mutable cache, all tiles will be unusable. Please re-download the geoCorridor again. Please also note, any route calculation may not possible on prefetched tiles.

      To control list of map content features for corridor prefetch, use LayerConfiguration.enabledFeatures.

      Parameters:
      corridor -

      indicates GeoCorridor that can be constructed from the route.

      callback -

      is invoked to report progress and the result of prefetch. After operation is finished, PrefetchStatusListener.onComplete(com.here.sdk.maploader.MapLoaderError) is invoked on the main thread. Progress is reported by invocation of PrefetchStatusListener.onProgress(int) on the main thread.

      Returns:

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

    • getPrefetchCorridorLengthMeters

      public int getPrefetchCorridorLengthMeters()

      Gets the length of the corridor along the route in front of the car which will be used to prefetch data.

      Upper limit for length is 50000 meters, when the requested length is greater than upper limit, then 50000 meters set. Lower limit for length is 1000 meters, when the requested length is less than lower limit, then 1000 meters set. The route corridor has a default length of 10 km and a width of 5 km.

      Returns:

      The length of the corridor along the route in front of the car which will be used to prefetch data.

    • setPrefetchCorridorLengthMeters

      public void setPrefetchCorridorLengthMeters(int value)

      Sets the length of the corridor along the route in front of the car which will be used to prefetch data.

      Upper limit for length is 50000 meters, when the requested length is greater than upper limit, then 50000 meters set. Lower limit for length is 1000 meters, when the requested length is less than lower limit, then 1000 meters set. The route corridor has a default length of 10 km and a width of 5 km.

      Parameters:
      value -

      The length of the corridor along the route in front of the car which will be used to prefetch data.