Class OsmRouting

java.lang.Object
com.codename1.backend.osm.OsmRouting
All Implemented Interfaces:
HttpServer.Handler

public final class OsmRouting extends Object implements HttpServer.Handler

Answers turn-by-turn routes in the shape of OSRM's HTTP API, so the client's OsrmRouteService -- or any other OSRM client -- can point at this backend instead of a separate routing server.

Mounted at a prefix, it answers GET {prefix}/route/v1/{profile}/{lon},{lat};{lon},{lat}[;...] with the profiles driving, walking and cycling (car, foot and bike are accepted too). The query parameters understood are steps (true/false), overview (full, simplified or false; simplified is answered as full), geometries (polyline or polyline6) and alternatives, which is accepted and always answered with one route.

A failure is an HTTP 400 whose JSON body carries OSRM's code: InvalidUrl, InvalidQuery, InvalidOptions, TooBig, NoSegment (a waypoint too far from any road) or NoRoute.

OsmExtract extract = OsmExtract.load("/data/region.osm.pbf");
Backend.builder()
        .handler(new OsmRouting(extract, "/osrm"))
        .handler(new OsmGeocoding(extract, "/geocode"))
        .start();