Skip to content
GuidesPlaygroundDashboard

Calculate a route between two points

routing().route(RoutingRouteParamsparams, RequestOptionsrequestOptions = RequestOptions.none()) : RouteResult
POST/api/v1/route

Calculate a route between two points

ParametersExpand Collapse
params: RoutingRouteParams
routeRequest: RouteRequest
ReturnsExpand Collapse
class RouteResult:
geometry: GeoJsonGeometry
coordinates: Coordinates

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
List<Double>
List<List<Double>>
List<List<List<Double>>>
List<List<List<List<Double>>>>
type: Type
One of the following:
POINT("Point")
LINE_STRING("LineString")
POLYGON("Polygon")
MULTI_POINT("MultiPoint")
MULTI_LINE_STRING("MultiLineString")
MULTI_POLYGON("MultiPolygon")
properties: Properties
distance: Optional<Double>

Total distance in meters

duration: Optional<Double>

Estimated duration in seconds

mode: Optional<String>

Travel mode used

type: Type

Calculate a route between two points

package com.plazafyi.example

import com.plazafyi.client.PlazaClient
import com.plazafyi.client.okhttp.PlazaOkHttpClient
import com.plazafyi.models.GeoJsonGeometry
import com.plazafyi.models.routing.RouteRequest
import com.plazafyi.models.routing.RouteResult
import com.plazafyi.models.routing.RoutingRouteParams

fun main() {
    val client: PlazaClient = PlazaOkHttpClient.fromEnv()

    val params: RouteRequest = RouteRequest.builder()
        .destination(GeoJsonGeometry.builder()
            .coordinatesOfDoubles(listOf(0.0))
            .type(GeoJsonGeometry.Type.POINT)
            .build())
        .origin(GeoJsonGeometry.builder()
            .coordinatesOfDoubles(listOf(0.0))
            .type(GeoJsonGeometry.Type.POINT)
            .build())
        .build()
    val routeResult: RouteResult = client.routing().route(params)
}
Returns Examples