Distance Time Matrix

Matrix Response

Contains the distances and times between specified locations.

Overview #

The matrix response is the object returned after a matrix request is submitted to the API. The response contains named elements for each of the source-destination pairs computed.

Applicable models #

  • Matrix matrix-vyv95n7wchpl

Endpoint #


Matrix Response Element #

Schema definition #

message Element{
  required string fromId = 1;
  required string toId = 2;
  required float distance = 3;
  required float duration = 4;
}

Fields #

fromId
The location id for the source of the element.
toId
The location id for the destination of the element.
distance
The distance between source and destination in the units specified in the matrix request.
duration
The duration between source and destination in the units specified in the matrix request.

Matrix Response #

Schema definition #

message MatrixResponse{
  repeated Element elements = 1;
}

Fields #

elements
A list of elements corresponding to the distances and durations between the requested source and destination locations.

Examples #

The following illustrates a valid response corresponding to a 3x3 matrix request between The Oval Bar Dublin, Kehoes Pub and The Confession Box (the same 3x3 matrix in the request examples). You’ll notice that only 6 elements are returned as the distances and times between locations to themselves are zero (and are thus omitted in the response).

elements {
  fromId: "The Oval Bar Dublin"
  toId: "The Confession Box"
  distance: 1.49974537
  duration: 0.0618333332
}
elements {
  fromId: "The Oval Bar Dublin"
  toId: "Kehoes Pub"
  distance: 3.18078804
  duration: 0.133638889
}
elements {
  fromId: "The Confession Box"
  toId: "The Oval Bar Dublin"
  distance: 1.48606718
  duration: 0.0595
}
elements {
  fromId: "The Confession Box"
  toId: "Kehoes Pub"
  distance: 3.03498483
  duration: 0.126638889
}
elements {
  fromId: "Kehoes Pub"
  toId: "The Oval Bar Dublin"
  distance: 2.14612246
  duration: 0.0943055525
}
elements {
  fromId: "Kehoes Pub"
  toId: "The Confession Box"
  distance: 2.80850101
  duration: 0.110138886
}


Last updated 19 December 2023