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.

Note:
There is no 100% guarantee that provided route shape can be imported into the route object. In some cases, the resulting route can be different from the original route shape or not be created at all. In order to get a successful route, provided route shape must meet the following criteria:
  • contain no more than 1000 geo-coordinates;
  • geo points should be located on the unblocked, navigatable road links;
  • geo points should be matched to the expected road links in the route.
  • avoid using geo points that are located in areas that have complex road networks (complex junctions, overpasses, merging highways, interchanges etc).
  • high density does not mean better route quality. If there are no preferences about roads on some part of the route, corresponding geo points can be removed as they can be approximated automatically by the SDK and as the result, overall performance will be better.

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