SDK for Android Developer's Guide

Fleet Telematics Custom Routes

Fleet Telematics Custom Routes (FTCR) API provides functionality to calculate a route, show it on map and perform simple turn-by-turn navigation using HERE map data and customers' private map data. FTCR API is similar to common routing and navigation, but it offers limited functionality compare to them. For more information about use cases that can be covered by FTCR, check Fleet Telematics Custom Routes API Developer's Guide.

FTCR Classes

Class Description
FTCRRouter Route calculation executor for Fleet Telematics Custom Route.
FTCRRoutePlan Contains all information needed to calculate the ftcr route.
FTCRRouteOptions Contains options for ftcr route calculation.
FTCRRoute Represents a distinct Fleet Telematics custom path connecting two or more waypoints.
FTCRNavigationManager A navigation manager class that provides guidance advice and information along the FTCR routes.
FTCRMapRoute Represents a FTCRRoute that can be displayed on a Map.
FTCRLaneInformation Represents information about lane information on the FTCRManeuver.
FTCRManeuver Represents information about maneuver on the FTCRRoute.
FTCRRouteWarning Describes warning for FTCRRoute.
FTCRVoiceGuidanceOptions Allows to configure voice prompts for FTCR guidance.

FTCR route calculation

Steps to calculate FTCRRoute are the same as for common routing. Use classes from ftcr package: FTCRRouter, FTCRRoutePlan and FTCRRouteOptions to calculate a route. Note, that route calculation only works in online mode. See example to calculate FTCR route below:

void calculateRoute() {
  // waypoints setup
  final RouteWaypoint start = new RouteWaypoint(new GeoCoordinate(52.514184, 13.316419));
  RouteWaypoint destination = new RouteWaypoint(new GeoCoordinate(52.512272, 13.383096));
  List<RouteWaypoint> waypoints = Arrays.asList(start, destination);

  // fleet telematics options
  FTCRRouteOptions routeOptions = new FTCRRouteOptions();
  routeOptions.setUseTraffic(true)
      // Other transport modes such as TRUCK, PEDESTRIAN, SCOOTER, BICYCLE
      // and BUS are also supported.
      .setTransportMode(FTCRRouteOptions.TransportMode.CAR)
      .setRouteType(FTCRRouteOptions.Type.FASTEST)
      // see API reference to check all possible routing options
      .addAvoidArea(new GeoBoundingBox(new GeoCoordinate(52.521842, 13.375375),
          new GeoCoordinate(52.518212, 13.380335)));

  FTCRRouter router = new FTCRRouter();
  FTCRRoutePlan ftcrRoutePlan = new FTCRRoutePlan(waypoints, routeOptions);
  // set overlay name if needed
  ftcrRoutePlan.setOverlay("OVERLAYNAME");
  router.calculateRoute(ftcrRoutePlan, new FTCRRouter.Listener() {
    @Override
    public void onCalculateRouteFinished(@NonNull List<FTCRRoute> routes,
                       @NonNull FTCRRouter.ErrorResponse error) {
      if (error.getErrorCode() == RoutingError.NONE && !routes.isEmpty()) {
        startNavigation(routes.get(0));
      }
    }
  });
}

FTCR turn-by-turn guidance

FTCRNavigationManager allows developer to perform simple turn-by-turn guidance along the route. It is possible to simulate the route as well as navigate route using custom LocationDataSource in PositioningManager. Note, FTCR navigation has limited functionality compare to NavigationManager: map matcher is only based on route geometry from the online server response, re-routing is only available in online mode and some navigation events like speed warning are not suported. See example to start FTCR navigation below:

FTCRNavigationManager.FTCRNavigationManagerListener navListener
    = new FTCRNavigationManager.FTCRNavigationManagerListener() {
  @Override
  public void onStopoverReached(int index) { }
  @Override
  public void onDestinationReached() { }
  @Override
  public void onRerouteBegin() { }
  @Override
  public void onLaneInformation(@NonNull List<FTCRLaneInformation> lanes) { }
  @Override
  public void onCurrentManeuverChanged(@Nullable FTCRManeuver currentManeuver,
                     @Nullable FTCRManeuver nextManeuver) { }

  @Override
  public void onRerouteEnd(@Nullable FTCRRoute newRoute,
      @NonNull FTCRRouter.ErrorResponse error) {
    // We must remove old route from the map and add new one, SDK does not do that
    // automatically
    if (error.getErrorCode() == RoutingError.NONE) {
      map.removeMapObject(currentRoute);
      currentRoute = new FTCRMapRoute(newRoute);
      map.addMapObject(currentRoute);
    }
  }
};

void startNavigation(FTCRRoute route) {
  // add route to the map
  currentRoute = new FTCRMapRoute(route);
  map.addMapObject(currentRoute);
  // set first route coordinate as map center
  map.setCenter(route.getGeometry().get(0), Map.Animation.NONE, 15.0f, 0f, 0f);
  // show indicator on the map
  mapFragment.getPositionIndicator().setVisible(true);

  ftcrNavigationManager.setMap(map);
  ftcrNavigationManager.setMapTrackingTilt(FTCRNavigationManager.TrackingTilt.TILT3D);
  ftcrNavigationManager.setMapTrackingMode(FTCRNavigationManager.TrackingMode.FOLLOW);
  ftcrNavigationManager.addNavigationListener(navListener);
  // also supports simulation and navigation using PositionSimulator
  ftcrNavigationManager.start(route);
}