traceRoute

fun traceRoute(request: MapMatchRequest): MapMatchRouteResponse

Map-match a GPS trace onto the road network and return a route along the matched path.

This is Valhalla's trace_route action. Supply the trace either as MapMatchRequest.shape or as a MapMatchRequest.encodedPolyline — note that the polyline must be encoded with six digits of precision rather than the usual five.

Everything runs against the tiles already on the device, so this works with no network.

Return

The matched trip.

Parameters

request

The trace to match, the costing model, and how to match it.

See also

MapMatchRequest

Throws

if the Valhalla engine returns an error response, which includes the case where the trace cannot be matched to the road network.

if the response JSON cannot be parsed.

if the request asks for a format other than JSON. OSRM map-match responses report their routes under matchings, a shape osrm-openapi does not model, and GPX is not JSON at all; reach both through traceRouteRaw. PBF is binary and cannot cross the bridge, so it comes back as an error.