Matrix
The matrix query of the Data API. Every request is a POST to https://data.mountaya.com/graphql with a publishable key and a session token: see Authentication.
/graphqlCompute a time-distance matrix between locations for a given activity. Returns duration and/or distance grids between all source-destination pairs.
Arguments
inputMatrixInput!
The origins and destinations to measure between, the activity, and which metrics to compute.
activityActivitySlug!
One of: HIKING_AND_TRAIL, PROFESSIONAL_TRAIL, RUNNING, ROAD_CYCLING, GRAVEL_BIKE, MOUNTAIN_BIKE, BACKCOUNTRY_SKIING, SKI_TOURING, CROSS_COUNTRY_SKIING, SNOWSHOE_WALKING
Activity to use for routing. BACKCOUNTRY_SKIING has no routing, and GRAVEL_BIKE and MOUNTAIN_BIKE are unavailable: all three are VALIDATION_FAILED at ["input", "activity"].
See ActivitySlug.
locations[[Float!]!]!
Locations as [longitude, latitude] coordinate pairs (WGS 84), 2 to 50 (fewer or more is VALIDATION_FAILED at ["input", "locations"]). Each is exactly two numbers, a longitude between -180 and 180 and a latitude between -90 and 90, and one that is not is VALIDATION_FAILED at ["input", "locations", i]. No two locations may lie more than 20 km apart in a straight line, and a matrix two of whose locations do is VALIDATION_FAILED at ["input", "locations"]: past that span the routing engine cannot search between them. A location the routing engine cannot place on the network answers its pairs null rather than failing, and so does a location on ways no other location connects to, an enclosed site for one: its pairs with the rest of the network are null, as no route joins them, and the pairs between two locations on the same enclosed site are answered. A matrix of many locations over a dense network, whose search the engine cannot hold at once, is computed one source at a time and answered exactly as the whole matrix would have been, recorded as one request with the elements asked for, null cells included; one holding such an enclosed location takes a few seconds more, and under load the engine is waited for within the request's time budget. Any failure of the engine within those bounds is INTERNAL_ERROR, never the caller's to fix: a ceiling of its own set below them, or a source whose own search it cannot hold either. Example: [[6.8694, 45.9237], [6.9271, 45.9822], [6.7997, 45.8906]] (Chamonix, Argentière, Les Houches).
sources[Int!]
Indices of locations to use as sources. When omitted, all locations are used. At most 50 (more is VALIDATION_FAILED at ["input", "sources"]). Each must be the index of one of the locations, and one that is not is VALIDATION_FAILED at ["input", "sources", i]. A repeated index is accepted. Example: [0] to compute only from the first location to all others.
destinations[Int!]
Indices of locations to use as destinations. When omitted, all locations are used. At most 50 (more is VALIDATION_FAILED at ["input", "destinations"]). Each must be the index of one of the locations, and one that is not is VALIDATION_FAILED at ["input", "destinations", i]. A repeated index is accepted. Example: [0] to compute only from all locations to the first one.
metrics[MatrixMetric!]!
One of: DISTANCE, DURATION
Metrics to compute. At least one metric is required (an empty list is VALIDATION_FAILED at ["input", "metrics"]).
See MatrixMetric.
Returns
matrixMatrixResult!
Result of a matrix computation.
durations[[Float]!]
Duration grid in seconds, one row per source and one column per destination. These are the routing engine's own estimates: they take no speed and do not use the terrain-aware model behind duration on directions, suggestions and analyzeGeometry, so they are not comparable with it. Null inner values indicate unreachable pairs. Only present when DURATION metric is requested.
distances[[Float]!]
Distance grid in meters, one row per source and one column per destination: the routing engine's own figures, with no geometry returned to measure them against. Null inner values indicate unreachable pairs. Only present when DISTANCE metric is requested.
Errors A field the API refuses is answered 200, its entry in errors beside the data that resolved. See Errors.
curl https://data.mountaya.com/graphql \
-H "X-API-Key: pk_your_publishable_key" \
-H "X-Session-Token: sess_your_session_token" \
-H "Content-Type: application/json" \
-d '{
"query": "query Matrix($input: MatrixInput!) { matrix(input: $input) { distances durations } }",
"variables": {
"input": {
"activity": "HIKING_AND_TRAIL",
"locations": [[6.8712, 45.9231], [6.9271, 45.9822]],
"metrics": ["DURATION", "DISTANCE"]
}
}
}'