Package com.massifmaps.routing
Class ValhallaOnlineRoutingService
java.lang.Object
com.massifmaps.routing.RoutingService
com.massifmaps.routing.ValhallaOnlineRoutingService
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.
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 Summary
ConstructorsConstructorDescriptionValhallaOnlineRoutingService(String apiKey) Constructs a new ValhallaOnlineRoutingService instance given database file. -
Method Summary
Modifier and TypeMethodDescriptioncalculateRoute(RoutingRequest request) Calculates routing result (path) based on routing request.Returns the custom backend service URL.Returns the current set of HTTP headers used.Returns the current routing profile.intReturns the current timeout value.matchRoute(RouteMatchingRequest request) Matches specified points to the points on the road network.voidsetCustomServiceURL(String serviceURL) Sets the custom backend service URL.voidsetHTTPHeaders(StringMap headers) Sets HTTP headers for all requests.voidsetProfile(String profile) Sets the current routing profile.voidsetTimeout(int timeout) Sets the current timeout value.
-
Constructor Details
-
ValhallaOnlineRoutingService
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
Returns the custom backend service URL.- Returns:
- The custom backend service URL. If this is not defined, an empty string is returned.
-
setCustomServiceURL
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
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
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
Description copied from class:RoutingServiceReturns the current routing profile.- Overrides:
getProfilein classRoutingService- Returns:
- The current routing profile.
-
setProfile
Description copied from class:RoutingServiceSets the current routing profile.- Overrides:
setProfilein classRoutingService- Parameters:
profile- The new routing profile. Routing profiles are dependent on specific routing service.
-
matchRoute
Description copied from class:RoutingServiceMatches specified points to the points on the road network.- Overrides:
matchRoutein classRoutingService- Parameters:
request- The matching request defining points.- Returns:
- The matching result or null if route matching failed.
- Throws:
IOException
-
calculateRoute
Description copied from class:RoutingServiceCalculates routing result (path) based on routing request.- Overrides:
calculateRoutein classRoutingService- Parameters:
request- The routing request defining via points.- Returns:
- The result or null if routing failed.
- Throws:
IOException
-