# Region Mode

Summary of Capabilities & Limitations for this mode:
+ Custom options
+ Time Awareness (including Live Traffic), using a snapshot of time at departure
+ Matrix Sizes up to 10,000 x 10,000
- Region limited to max. 400km diameter

Given a list of origins and a list of destinations, the service computes the shortest travel times or distances between every pair of origin and destination. These results make up the entries of the routing matrix.

This section refers to calculating matrices with custom options using a limited sized region. If you want to avoid the region size limitation, see Flexible Mode.

By restricting the calculation to a specific region of at most 400 km diameter, it is possible to specify different options to take into account during calculation. The service applies live and historical traffic information unless explicitly disabled by setting departureTime to the special value any.

Below is an example of a simple 3 x 3 matrix in Berlin, Germany with these origins and destinations:

1. Alexanderplatz at (52.52103, 13.41268)
2. Brandenburg Gate at (52.51628, 13.37771)
3. Tempelhof Field at (52.47342, 13.40357)

To calculate a car distance matrix, you can use the request below. Since the request does not specify a destinations array, the origins are taken as destinations and the resulting matrix is a 3 x 3 matrix. The region definition is a bounding box around the points with a small margin added to be able to properly route in the vicinity of the points. By default, the service calculates a travel times matrix, but since we want to get distances in the response instead of times, the request specifies the matrixAttributes property with the value distances.

{
"origins": [
{"lat": 52.52103, "lng": 13.41268},
{"lat": 52.51628, "lng": 13.37771},
{"lat": 52.47342, "lng": 13.40357}
],
"regionDefinition": {
"type": "boundingBox",
"north": 52.53,
"south": 52.46,
"west": 13.35,
"east": 13.42
},
"matrixAttributes": ["distances"]
}


Visualized, it looks like this: The markers are the origins/destinations and the bounding box is the blue rectangle.

The full procedure of submitting a matrix request is described in the Send a Request section. The response looks like this:

{
"matrixId": "0b7f828f-49c8-43e4-9727-063eafbf7d7a",
"matrix": {
"numOrigins": 3,
"numDestinations": 3,
"distances": [0, 2907, 6446, 3258, 0, 5954, 6669, 5966, 0]
},
"regionDefinition": {
"type": "boundingBox",
"north": 52.53,
"south": 52.46,
"west": 13.35,
"east": 13.42
}
}


The response corresponds to this matrix with entries in meters:

orig\dest 1 2 3
1 0 2908 11262
2 3506 0 10207
3 11333 9414 0

## AutoCircle Region Definition

Instead of defining a bounding box around the origins, you can request for a circle to be automatically derived. The request below is for the same as the one above, but using the AutoCircle feature. Since the margin field is not provided, the service uses a default value of 10 kilometers.

{
"origins": [
{"lat": 52.52103, "lng": 13.41268},
{"lat": 52.51628, "lng": 13.37771},
{"lat": 52.47342, "lng": 13.40357}
],
"regionDefinition": {
"type": "autoCircle"
},
"matrixAttributes": ["distances"]
}


The derived circle is returned in the matrix response:

{
"matrixId": "05fef3ee-dd1a-450f-a5fe-15c95b7ee8a0",
"matrix": {
"numOrigins": 3,
"numDestinations": 3,
"distances": [0, 2907, 6446, 3258, 0, 5954, 6669, 5966, 0 ]
},
"regionDefinition": {
"type": "circle",
"center": {"lat": 52.497225, "lng": 13.395195},
}
}


Here is the region visualized:

You can decrease the size of the region by providing a smaller margin:

{
"origins": [
{"lat": 52.52103, "lng": 13.41268},
{"lat": 52.51628, "lng": 13.37771},
{"lat": 52.47342, "lng": 13.40357}
],
"regionDefinition": {
"type": "autoCircle",
"margin": 1000
},
"matrixAttributes": ["distances"]
}


This is the corresponding matrix response:

{
"matrixId": "b76f08be-9cc2-4a4e-9b27-deb766df9e90",
"matrix": {
"numOrigins": 3,
"numDestinations": 3,
"distances": [0, 2907, 6446, 3258, 0, 5954, 6669, 5966, 0 ]
},
"regionDefinition": {
"type": "circle",
"center": {"lat": 52.497225, "lng": 13.395195},