Routing
The routing queries: directions between waypoints, suggestions shaped to a target distance, isochrones for reachable area, and matrix for travel-time and distance grids. Every routing query takes an activity that selects a routing profile tuned to its terrain and movement style.
Each activity routes on a profile tuned to its terrain and movement style. The GraphQL ActivitySlug enum uses the uppercase value; the Tile and REST APIs use the lowercase, underscore-free wire form.
All coordinates are [longitude, latitude] in WGS 84. Distances are in meters, durations in seconds, elevations in meters above sea level, and gradients in degrees.
directions
Compute a route between an ordered list of waypoints for a given activity. Returns one or more routes with distance, duration, elevation, geometry, and a surface and way type analysis.
Input
directions(input: DirectionsInput!)
activityActivitySlug!
Activity to use for routing. Selects the routing profile and default speed.
waypoints[[Float!]!]!
Ordered list of waypoints as [longitude, latitude] pairs. At least two are required.
speedFloat
Travel speed in km/h. Overrides the activity's default speed and adjusts the estimated duration.
Example
Response
DirectionsResult.routes is a list of DirectionsRoute. Each route carries:
distanceFloat!
Total route distance in meters.
durationFloat!
Estimated route duration in seconds.
elevationElevationSummary!
Altitude bounds, total ascent and descent, and the gradient range in degrees.
geometryGeoJSON!
Route path as a GeoJSON LineString. Coordinates are [longitude, latitude, altitude].
analysisGeometryAnalysis!
Surface, way type, and slope segments along the route. See analysis.
summaryString!
Human-readable one-line summary, for example 15.2 km, ~4h12m, +720m / -430m elevation, 62% unpaved.
Run this query live: open it in the playground and try it against the schema.
suggestions
Generate route candidates that match a target distance for a given activity. Each candidate uses a different seed, producing a different route shape, so a client can offer the user several options ranked by proximity to the target.
Input
suggestions(input: SuggestionsInput!)
activityActivitySlug!
Activity to use for routing.
start[Float!]!
Starting point as [longitude, latitude].
distanceFloat!
Target total distance for the route in meters.
candidatesInt!
Number of candidates to generate (1 to 10). Each uses a different random seed.
ascentFloat
Target elevation gain in meters. When set, candidates are also ranked by proximity to this value.
end[Float!]
End point as [longitude, latitude]. Omit to loop back to start; provide a different point for a point-to-point route shaped to the target distance.
pointsInt
default: 5
Number of shaping points (2 to 10). Higher values produce rounder loops. Only applies to loop routes.
speedFloat
Travel speed in km/h, overriding the activity default.
seedsSuggestionSeeds
Pin specific seeds into the result (include) and avoid others in the fresh candidate pool (exclude). Useful to reproduce or vary previously returned routes. A seed in both lists is a validation error.
Example
Response
SuggestionsResult.routes is a list of SuggestionRoute, sorted by proximity to the target distance. Each carries the same distance, duration, elevation, geometry, analysis, and summary as a directions route, plus:
seedInt!
The seed used to generate this candidate. Pass it back in seeds.include to reproduce the route or seeds.exclude to filter it out of fresh candidates. Reproducing a route also requires the same start, end, distance, and points.
isochrones
Compute reachability polygons from one or more origins for a given activity. Each range value yields one isochrone, so several ranges produce concentric polygons.
Input
isochrones(input: IsochronesInput!)
activityActivitySlug!
Activity to use for routing.
locations[[Float!]!]!
Origin points as [longitude, latitude] pairs.
range[Float!]!
Range values, in seconds for TIME or meters for DISTANCE. Multiple values produce concentric isochrones.
rangeTypeIsochronesRangeType!
Whether range is expressed in TIME (seconds) or DISTANCE (meters).
Example
Response
IsochronesResult.isochrones is a list of Isochrone, one per range value:
valueFloat!
Range value in seconds or meters, matching the input range type.
areaFloat
Area of the polygon in square meters.
reachfactorFloat
Ratio of the isochrone area to the theoretical area (0 to 1).
center[Float!]!
Center point as [longitude, latitude].
geometryGeoJSON!
Polygon geometry of the isochrone.
matrix
Compute a grid of travel durations and/or distances between locations for a given activity. Limit the grid to specific origins or destinations with the sources and destinations index lists.
Input
matrix(input: MatrixInput!)
activityActivitySlug!
Activity to use for routing.
locations[[Float!]!]!
Locations as [longitude, latitude] pairs.
metrics[MatrixMetric!]!
Metrics to compute. At least one of DISTANCE (meters) or DURATION (seconds).
sources[Int!]
Indices of locations to use as sources. When omitted, all locations are used.
destinations[Int!]
Indices of locations to use as destinations. When omitted, all locations are used.
Example
Response
MatrixResult carries a grid per requested metric. Each grid is a row-per-source array of values, with inner null entries marking unreachable pairs:
durations[[Float]!]
Duration grid in seconds. Present only when the DURATION metric was requested.
distances[[Float]!]
Distance grid in meters. Present only when the DISTANCE metric was requested.