Package com.codename1.maps.routing
Road-following routes for the modern maps API.
A Polyline connects the coordinates you hand it with
straight segments, which is rarely what a navigation screen wants. This
package works out the geometry of the roads between two points so the line
on the map traces the drive a user would actually make.
Routing is the entry point and works with no
configuration -- it routes over OpenStreetMap data through the keyless
OsrmRouteService, mirroring how
MapView draws the keyless OpenFreeMap basemap:
MapView map = new MapView();
Routing.showRoute(map, origin, destination);
A RouteRequest adds waypoints and a
TravelMode; the resulting
Route carries the drawable geometry, the total
distance and duration, and the
RouteLeg/RouteStep
breakdown behind a turn-by-turn list.
The default service is backed by OSRM's public demo server, which is fine
for development but has no SLA. Production apps point it at their own
instance, or install a different backend entirely by implementing
RouteService and passing it to
Routing.setService(RouteService) -- app code that calls
Routing is unaffected either way.
-
ClassDescriptionThe keyless
RouteServiceCodename One uses by default: routing over the OpenStreetMap road network through the OSRM HTTP API.A road-following journey returned by aRouteService: the geometry that traces the actual roads, how long it is, how long it takes, and the legs and turn-by-turn steps that make it up.Receives the outcome of a routing request.The portion of aRoutebetween two consecutive stops.Describes the journey to route: where it starts, where it ends, anything it must pass through on the way, and how the traveller moves.A backend that turns aRouteRequestinto road-followingRoutes.One maneuver of aRouteLeg-- "turn left onto Elm Street and continue for 300 m" -- together with the piece of road geometry it covers.The entry point for road-following routes.How the traveller moves, which decides the road network and speeds aRouteServiceroutes over.