Interface RouteService
- All Known Implementing Classes:
OsrmRouteService
A backend that turns a RouteRequest into road-following Routes.
Codename One ships OsrmRouteService, which needs no API key, and
Routing uses it unless you install another. Implement this interface to
route through a different provider (Google Directions, Mapbox Directions,
GraphHopper, your own server) and install it with
Routing.setService(RouteService) -- application code that calls
Routing keeps working unchanged.
-
Method Summary
Modifier and TypeMethodDescriptionvoidfindRoutes(RouteRequest request, RouteCallback callback) Routesrequestand reports the outcome tocallback.getId()A short identifier for this backend, for example"osrm".booleanWhether this service can route right now.
-
Method Details
-
getId
String getId()A short identifier for this backend, for example"osrm". Used in log messages and to tell services apart. -
isAvailable
boolean isAvailable()Whether this service can route right now. A service that needs an API key returns false until one is configured, letting callers fail fast with a clear message instead of a network error. -
findRoutes
Routes
requestand reports the outcome tocallback.The call returns immediately; the work happens off the event dispatch thread and the callback is invoked back on it. Implementations must invoke exactly one callback method for every request, including when the request is rejected outright.
callbackis required -- an asynchronous call with nowhere to report its result is a mistake, not a fire-and-forget mode, so implementations reject anullone withIllegalArgumentExceptionrather than returning quietly and leaving the caller to wonder.
-