Class ValhallaOnlineRoutingService

java.lang.Object
com.massifmaps.routing.RoutingService
com.massifmaps.routing.ValhallaOnlineRoutingService

public class ValhallaOnlineRoutingService extends RoutingService
An online routing service that uses MapBox Valhalla routing service.
As the class connects to an external (non-Massif) 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.
  • Constructor Details

    • ValhallaOnlineRoutingService

      public ValhallaOnlineRoutingService(String apiKey)
      Constructs a new ValhallaOnlineRoutingService instance given database file.
      Parameters:
      apiKey - The API key (access token) to use registered with MapBox.
    • ValhallaOnlineRoutingService

      public ValhallaOnlineRoutingService()
  • Method Details

    • getCustomServiceURL

      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.
    • setCustomServiceURL

      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.
    • getTimeout

      public int getTimeout()
      Returns the current timeout value.
      Returns:
      The current timeout value in seconds. If negative, then default platform-specific timeout is used.
    • setTimeout

      public void setTimeout(int timeout)
      Sets the current timeout value.
      Parameters:
      timeout - The new timeout value in seconds. If negative, then default platform-specific timeout is used.
    • getHTTPHeaders

      public StringMap getHTTPHeaders()
      Returns the current set of HTTP headers used. Initially this set is empty and can be changed with setHTTPHeaders.
      Returns:
      The current set of custom HTTP headers.
    • setHTTPHeaders

      public void setHTTPHeaders(StringMap headers)
      Sets HTTP headers for all requests. Calling this method will invalidate the datasource and
      all layers using this data source will be refreshed.
      Parameters:
      headers - A map of HTTP headers that will be used in subsequent requests.
    • getProfile

      public String getProfile()
      Description copied from class: RoutingService
      Returns the current routing profile.
      Overrides:
      getProfile in class RoutingService
      Returns:
      The current routing profile.
    • setProfile

      public void setProfile(String profile)
      Description copied from class: RoutingService
      Sets the current routing profile.
      Overrides:
      setProfile in class RoutingService
      Parameters:
      profile - The new routing profile. Routing profiles are dependent on specific routing service.
    • matchRoute

      public RouteMatchingResult matchRoute(RouteMatchingRequest request) throws IOException
      Description copied from class: RoutingService
      Matches specified points to the points on the road network.
      Overrides:
      matchRoute in class RoutingService
      Parameters:
      request - The matching request defining points.
      Returns:
      The matching result or null if route matching failed.
      Throws:
      IOException
    • calculateRoute

      public RoutingResult calculateRoute(RoutingRequest request) throws IOException
      Description copied from class: RoutingService
      Calculates routing result (path) based on routing request.
      Overrides:
      calculateRoute in class RoutingService
      Parameters:
      request - The routing request defining via points.
      Returns:
      The result or null if routing failed.
      Throws:
      IOException