本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
如何使用避让计算路径矩阵
CalculateRouteMatrix API 计算路线,并返回从每个起点到指定列表中每个目的地的行驶时间和距离。该 API 可用于为特定区域或道路要素设置避让选项,确保路线避开指定的区域或条件。如果替代路线不可行,则可以绕过避让偏好。
潜在用例
-
路线规划和优化:使用路径矩阵作为软件的输入,该软件需要优化出行路线,同时避开某些区域或道路特征。
示例
- 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}'
- 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}'
计算多个起点和目的地的路线矩阵
使用 OptimizeWaypoints