public class

ValhallaOnlineRoutingService

extends RoutingService
java.lang.Object
   ↳ com.carto.routing.RoutingService
     ↳ com.carto.routing.ValhallaOnlineRoutingService

Class Overview

An online routing service that uses MapBox Valhalla routing service.
As the class connects to an external (non-CARTO) service, this class is provided "as-is",
future changes from the service provider may not be compatible with the implementation.
Routing and route matching perform network requests and must be executed in non-UI background thread.
Be sure to read the Terms and Conditions of your Valhalla service provider to see if the
service is available for your application.
Note: this class is experimental and may change or even be removed in future SDK versions.

Summary

Public Constructors
ValhallaOnlineRoutingService(String apiKey)
Constructs a new ValhallaOnlineRoutingService instance given database file.
Public Methods
RoutingResult calculateRoute(RoutingRequest request)
Calculates routing result (path) based on routing request.
synchronized void delete()
String getCustomServiceURL()
Returns the custom backend service URL.
String getProfile()
Returns the current routing profile.
RouteMatchingResult matchRoute(RouteMatchingRequest request)
Matches specified points to the points on the road network.
void setCustomServiceURL(String serviceURL)
Sets the custom backend service URL.
void setProfile(String profile)
Sets the current routing profile.
[Expand]
Inherited Methods
From class com.carto.routing.RoutingService
From class java.lang.Object

Public Constructors

public ValhallaOnlineRoutingService (String apiKey)

Constructs a new ValhallaOnlineRoutingService instance given database file.

Parameters
apiKey The API key (access token) to use registered with MapBox.

Public Methods

public RoutingResult calculateRoute (RoutingRequest request)

Calculates routing result (path) based on routing request.

Parameters
request The routing request defining via points.
Returns
  • The result or null if routing failed.
Throws
IOException

public synchronized void delete ()

public String getCustomServiceURL ()

Returns the custom backend service URL.

Returns
  • The custom backend service URL. If this is not defined, an empty string is returned.

public String getProfile ()

Returns the current routing profile.

Returns
  • The current routing profile.

public RouteMatchingResult matchRoute (RouteMatchingRequest request)

Matches specified points to the points on the road network.

Parameters
request The matching request defining points.
Returns
  • The matching result or null if route matching failed.
Throws
IOException

public void setCustomServiceURL (String serviceURL)

Sets the custom backend service URL.
The custom URL should contain tag "{service}", it will be substituted by the SDK by the service type the SDK needs to perform ("route" or "trace_route").
The custom URL may also contain tag "{api_key}" which will be substituted with the set API key.

Parameters
serviceURL The custom backend service URL to use. If this is empty, then the default service is used.

public void setProfile (String profile)

Sets the current routing profile.

Parameters
profile The new routing profile. Routing profiles are dependent on specific routing service.