

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# CalculateRouteMatrix を使用する方法について説明します。
<a name="calculate-route-matrix-how-to"></a>

このセクションでは、`CalculateRouteMatrix` を使用して複数の出発地と目的地の効率的なルートを見つける方法について説明します。

**Topics**
+ [

# 複数の出発地と目的地の距離と時間のルートマトリックスを計算する方法
](calculate-route-matrix-distance.md)
+ [

# 回避を使用してルートマトリックスを計算する方法
](calculate-route-matrix-with-avoidance.md)

# 複数の出発地と目的地の距離と時間のルートマトリックスを計算する方法
<a name="calculate-route-matrix-distance"></a>

CalculateRouteMatrix API は、ルートを計算し、出発地と目的地の組み合わせごとに移動時間と移動距離を提供します。この機能は、複数の位置でのルートの計画と最適化を必要とするアプリケーションに役立ちます。

レスポンスには、各送信元と送信先のペアの`Distance`メートル単位と秒`Duration`単位が含まれます。

## 想定されるユースケース
<a name="calculate-route-matrix-potential-use"></a>
+ **ルート計画を最適化する:** ルートマトリックスをルート最適化ソフトウェアの入力として使用して、サービス効率を高め、移動時間を短縮します。

## 例
<a name="calculate-route-matrix-examples"></a>

### CalculateRouteMatrix で無制限のルーティング境界を使用する
<a name="calculate-route-matrix-unbounded"></a>

------
#### [ Sample request ]

```
{
    "Origins": [
        {
            "Position": [-123.11679620827039, 49.28147612192166]
        },
        {
            "Position": [-123.11179620827039, 49.3014761219]
        }
    ],
    "Destinations": [
        {
            "Position": [-123.112317039, 49.28897192166]
        }
    ],
    "DepartureTime": "2024-05-28T21:27:56Z",
    "RoutingBoundary": {
        "Unbounded": true
    }
}
```

------
#### [ Sample response ]

```
{
    "ErrorCount": 0,
    "RouteMatrix": [
        [
            {
                "Distance": 1907,
                "Duration": 343
            }
        ],
        [
            {
                "Distance": 5629,
                "Duration": 954
            }
        ]
    ],
    "RoutingBoundary": {
        "Unbounded": true
    }
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/route-matrix?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origins": [
        {
            "Position": [-123.11679620827039, 49.28147612192166]
        },
        {
            "Position": [-123.11179620827039, 49.3014761219]
        }
    ],
    "Destinations": [
        {
            "Position": [-123.112317039, 49.28897192166]
        }
    ],
    "DepartureTime": "2024-05-28T21:27:56Z",
    "RoutingBoundary": {
        "Unbounded": true
    }
}'
```

------
#### [ AWS CLI ]

```
aws geo-routes calculate-route-matrix --key ${YourKey} \
--origins '[{"Position": [-123.11679620827039, 49.28147612192166]}, {"Position": [-123.11179620827039, 49.3014761219]}]' \
--destinations '[{"Position": [-123.11179620827039, 49.28897192166]}]' \
--departure-time "2024-05-28T21:27:56Z" \
--routing-boundary '{"Unbounded": true}'
```

------

### CalculateRouteMatrix でジオメトリベースのルーティング境界を使用する
<a name="calculate-route-matrix-geometry"></a>

------
#### [ Sample request ]

```
{
    "Origins": [
        {
            "Position": [-123.11679620827039, 49.28147612192166]
        },
        {
            "Position": [-123.11179620827039, 49.3014761219]
        }
    ],
    "Destinations": [
        {
            "Position": [-123.112317039, 49.28897192166]
        }
    ],
    "DepartureTime": "2024-05-28T21:27:56Z",
    "RoutingBoundary": {
        "Geometry": {
            "AutoCircle": {
                "Margin": 10000,
                "MaxRadius": 30000
            }
        }
    }
}
```

------
#### [ Sample response ]

```
{
    "ErrorCount": 0,
    "RouteMatrix": [
        [
            {
                "Distance": 1907,
                "Duration": 344
            }
        ],
        [
            {
                "Distance": 5629,
                "Duration": 950
            }
        ]
    ],
    "RoutingBoundary": {
        "Geometry": {
            "Circle": {
                "Center": [
                    -123.1142962082704,
                    49.29147612191083
                ],
                "Radius": 11127
            }
        },
        "Unbounded": false
    }
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/route-matrix?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origins": [
        {
            "Position": [-123.11679620827039, 49.28147612192166]
        },
        {
            "Position": [-123.11179620827039, 49.3014761219]
        }
    ],
    "Destinations": [
        {
            "Position": [-123.112317039, 49.28897192166]
        }
    ],
    "DepartureTime": "2024-05-28T21:27:56Z",
    "RoutingBoundary": {
        "Geometry": {
            "AutoCircle": {
                "Margin": 10000,
                "MaxRadius": 30000
            }
        }
    }
}'
```

------
#### [ AWS CLI ]

```
aws geo-routes calculate-route-matrix --key ${YourKey} \
--origins '[{"Position": [-123.11679620827039, 49.28147612192166]}, {"Position": [-123.11179620827039, 49.3014761219]}]' \
--destinations '[{"Position": [-123.11179620827039, 49.28897192166]}]' \
--departure-time "2024-05-28T21:27:56Z" \
--routing-boundary '{"Geometry": {"AutoCircle": {"Margin": 10000, "MaxRadius": 30000}}}'
```

------

# 回避を使用してルートマトリックスを計算する方法
<a name="calculate-route-matrix-with-avoidance"></a>

CalculateRouteMatrix API は、ルートを計算し、指定したリスト内の各出発地から各目的地までの移動時間と距離を返します。レスポンスには、メートル`Distance`単位と秒`Duration`単位が含まれます。この API を使用すると、指定したゾーンまたは条件をルートが回避するように、特定のエリアまたは道路の特徴の回避オプションを設定できます。代替ルートが不可能な場合は、回避設定をバイパスできます。

## 想定されるユースケース
<a name="calculate-route-matrix-potential-use"></a>
+ **ルートの計画と最適化:** 特定のエリアや道路の特徴を回避しながら、最適化された移動ルートを必要とするソフトウェアの入力としてルートマトリックスを使用します。

## 例
<a name="calculate-route-matrix-examples"></a>

### CalculateRouteMatrix で回避エリアを使用する
<a name="calculate-route-matrix-avoidance-area"></a>

------
#### [ Sample request ]

```
{
    "Origins": [
        {
            "Position": [-123.11679620827039, 49.28147612192166]
        }
    ],
    "Destinations": [
        {
            "Position": [-123.112317039, 49.28897192166]
        }
    ],
    "Avoid": {
        "Areas": [
            {
                "Geometry": {
                    "BoundingBox": [
                         -123.116561,
                         49.281517,
                         -123.110165,
                         49.285689
                    ]
                }
            }
        ]
    },
    "RoutingBoundary": {
        "Unbounded": true
    }
}
```

------
#### [ Sample response ]

```
{
    "ErrorCount": 0,
    "RouteMatrix": [
        [
            {
                "Distance": 1855,
                "Duration": 295
            }
        ]
    ],
    "RoutingBoundary": {
        "Unbounded": true
    }
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/route-matrix?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origins": [
        {
            "Position": [-123.11679620827039, 49.28147612192166]
        }
    ],
    "Destinations": [
        {
            "Position": [-123.112317039, 49.28897192166]
        }
    ],
    "Avoid": {
        "Areas": [
            {
                "Geometry": {
                    "BoundingBox": [
                         -123.116561,
                         49.281517,
                         -123.110165,
                         49.285689
                    ]
                }
            }
        ]
    },
    "RoutingBoundary": {
        "Unbounded": true
    }
}'
```

------
#### [ AWS CLI ]

```
aws geo-routes calculate-route-matrix --key ${YourKey} \
--origins '[{"Position": [-123.11679620827039, 49.28147612192166]}]' \
--destinations '[{"Position": [-123.112317039, 49.28897192166]}]' \
--avoid '{"Areas": [{"Geometry": {"BoundingBox": [-123.116561, 49.281517, -123.110165, 49.285689]}}]}' \
--routing-boundary '{"Unbounded": true}'
```

------

### CalculateRouteMatrix で有料道路、高速道路、フェリーを回避する
<a name="calculate-route-matrix-avoidance-features"></a>

------
#### [ Sample request ]

```
{
    "Origins": [
        {
            "Position": [-123.11679620827039, 49.28147612192166]
        }
    ],
    "Destinations": [
        {
            "Position": [-123.112317039, 49.28897192166]
        }
    ],
    "Avoid": {
        "TollRoads": true,
        "ControlledAccessHighways": true,
        "Ferries": true    
    },
    "RoutingBoundary": {
        "Unbounded": true
    }
}
```

------
#### [ Sample response ]

```
{
    "ErrorCount": 0,
    "RouteMatrix": [
        [
            {
                "Distance": 1855,
                "Duration": 295
            }
        ]
    ],
    "RoutingBoundary": {
        "Unbounded": true
    }
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/route-matrix?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origins": [
        {
            "Position": [-123.11679620827039, 49.28147612192166]
        }
    ],
    "Destinations": [
        {
            "Position": [-123.112317039, 49.28897192166]
        }
    ],
    "Avoid": {
        "TollRoads": true,
        "ControlledAccessHighways": true,
        "Ferries": true    
    },
    "RoutingBoundary": {
        "Unbounded": true
    }
}'
```

------
#### [ AWS CLI ]

```
aws geo-routes calculate-route-matrix --key ${YourKey} \
--origins '[{"Position": [-123.11679620827039, 49.28147612192166]}]' \
--destinations '[{"Position": [-123.112317039, 49.28897192166]}]' \
--avoid '{"TollRoads": true, "ControlledAccessHighways": true, "Ferries": true}' \
--routing-boundary '{"Unbounded": true}'
```

------