# 使用路線矩陣規劃路線

• `DeparturePositions`— 要計算路線的起始位置集。定義為陣列```[longitude, latitude]```

• `DestinationPositions`— 要計算路線的結束位置集。定義為陣列```[longitude, latitude]```

API

``````POST /routes/v0/calculators/ExampleCalculator/calculate/route-matrix
Content-type: application/json
{
"DeparturePositions": [
[-122.7565,49.0021],
[-122.2014,47.6101]
],
"DestinationPositions": [
[-122.3394, 47.6159],
[-122.4813,48.7511]
]
}``````
AWS CLI

``````aws location \
calculate-route-matrix \
--calculator-name ExampleCalculator \
--departure-positions "[[-122.7565,49.0021],[-122.2014,47.6101]]" \
--destination-positions "[[-122.3394,47.6159],[-122.4813,48.7511]]"``````

• `DistanceUnit`— 指定用於距離結果的單位系統。

``````POST /routes/v0/calculators/ExampleCalculator/calculate/route-matrix
Content-type: application/json
{
"DeparturePositions": [
[-122.7565,49.0021],
[-122.2014,47.6101]
],
"DestinationPositions": [
[-122.3394, 47.6159],
[-122.4813,48.7511]
],
"DistanceUnit": "Miles"
}``````

## 出發和目的地位置的限制

route (路由長度 如路線的總行程時間超過 400 分鐘，路線將不會完成。 出發地和目的地點周圍偏離超過 10 公里的路線將不計算。

## 回應範例

Example request
``````POST /routes/v0/calculators/ExampleCalculator/calculate/route-matrix
Content-type: application/json
{
"DeparturePositions": [
[-122.7565,49.0021],
[-122.2014,47.6101]
],
"DestinationPositions": [
[-122.3394, 47.6159],
[-122.4813,48.7511]
]
}``````
Example response
``````{
"RouteMatrix": [
[
{
"Distance": 178.764,
"DurationSeconds": 7565
},
{
"Distance": 39.795,
"DurationSeconds": 1955
}
],
[
{
"Distance": 15.31,
"DurationSeconds": 1217
},
{
"Distance": 142.506,
"DurationSeconds": 6279
}
]
],
"Summary": {
"DataSource": "Here",
"RouteCount": 4,
"ErrorCount": 0,
"DistanceUnit": "Kilometers"
}
}``````