SDK for Android Developer's Guide

Import Route

Import Route is a feature which provides an opportunity to create a custom route object from the route shape, particularly from a list of geo-coordinates (lat, lon).

Your application users will be able to import custom routes from external vendors into the SDK and provide route guidance for these routes. As an example, a route is calculated based on a list of geo-coordinates from GPX file previously saved on the device. In any case, the route will be calculated based on our current map data.

Route calculation is based on the given list of points and navigation mode. The navigation mode is used for route calculation between points and for route recalculation during guidance.

A Route Calculation Example

  1. First create a new list with the desired points.
    // Create a list of points
    ArrayList<GeoCoordinate> points = new ArrayList<>();
    points.add(new GeoCoordinate(52.4992, 13.3956));
    points.add(new GeoCoordinate(52.4999, 13.3952));
    points.add(new GeoCoordinate(52.5007, 13.3948));
    points.add(new GeoCoordinate(52.5015, 13.3945));
    points.add(new GeoCoordinate(52.5023, 13.3947));
    points.add(new GeoCoordinate(52.5031, 13.3953));
    points.add(new GeoCoordinate(52.5030, 13.3961));
    points.add(new GeoCoordinate(52.5027, 13.3972));
    points.add(new GeoCoordinate(52.5025, 13.3980));
    points.add(new GeoCoordinate(52.5020, 13.3980));
    points.add(new GeoCoordinate(52.5014, 13.3977));
    
  2. Create a new RouteOptions object.
    // Create the RouteOptions and set its transport mode & routing type
    RouteOptions routeOptions = new RouteOptions();
    routeOptions.setTransportMode(RouteOptions.TransportMode.CAR);
    routeOptions.setRouteType(RouteOptions.Type.FASTEST);
    
  3. Create a CoreRouter.Listener and then calculate the route by calling CoreRouter.calculateRoute(List<GeoCoordinate>, RouteOptions, Listener).
    // Calculate route
    CoreRouter coreRouter = new CoreRouter();
    coreRouter.calculateRoute(points, routeOptions, new CoreRouter.Listener() {
      @Override
      public void onCalculateRouteFinished(List<RouteResult> list, RoutingError routingError) {
        if (routingError == RoutingError.NONE) {
          RouteResult result = list.get(0);
          Route resultRoute = result.getRoute();
        }
      }
      @Override
      public void onProgress(int i) {
      }
    });
    
Figure 1. Imported route