OLS Client Routing API

It provides customizable route calculations for a variety of vehicle types as well as pedestrian modes.

For the full RoutingApi specification, see RoutingApi.

The following pages describe the per-request configuration and metrics.

Example

Scala
Java
val client = BaseClient()
val routingApi = client.of[RoutingApi]
val result = routingApi
  .calculateRoutes(
    "truck",
    "51.611571,11.351608",
    "51.611571,11.351608",
    Seq("51.611571,11.351608"),
    None,
    Option("fast"),
    Option(0),
    None,
    None,
    None,
    None,
    Seq("polyline"),
    Seq("length,speedLimit")
  )
  .executeToEntity()

result
  .andThen {
    case Success(response: RouterRouteResponse) =>
      // do something with the routes
      response.getRoutes.forEach(route => println(route.getId))
    case Failure(ex) =>
      ex.printStackTrace()
  }

Await.result(result, Duration.Inf)
BaseClient client = BaseClientJava.instance();
RoutingApi routingApi = new RoutingApi(client);
RouterRouteResponse response =
    routingApi
        .calculateRoutes()
        .withTransportMode("truck")
        .withOrigin("51.611571,11.351608")
        .withDestination("51.611571,11.351608")
        .withVia(Collections.singletonList("51.611571,11.351608"))
        .withRoutingMode(Optional.of("fast"))
        .withAlternatives(Optional.of(0))
        .withReturn(Collections.singletonList("polyline"))
        .withSpans(Collections.singletonList("length,speedLimit"))
        .build()
        .executeToEntity()
        .toCompletableFuture()
        .join();

// do something with the routes
response.getRoutes().forEach(routerRoute -> System.out.println(routerRoute.getId()));

Examples of responses can be found in the Developer Guide

results matching ""

    No results matching ""