如何查找出发地和目的地的路线 - Amazon Location Service

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

如何查找出发地和目的地的路线

CalculateRoutes API 可帮助您找到出发地和目的地之间的最佳路线,以及司机休息的最佳机会。它支持卡车、行人、汽车和踏板车等出行模式。它还支持多达 25 个航点(中途停留),包括起点和目的地,但仅有一些限制。

潜在用例

  • 查找 point-to-point路线:根据各种出行模式和其他选项,确定两个地点之间的最佳路线。

示例

Sample request
{ "Origin": [ -123.118105, 49.282423 ], "Destination": [ -123.020098, 49.232872 ] }
Sample response
{ "LegGeometryFormat": "FlexiblePolyline", "Notices": [], "Routes": [ { "Legs": [ { "Geometry": { "Polyline": "Redacted" }, "TravelMode": "Car", "Type": "Vehicle", "VehicleLegDetails": { "AfterTravelSteps": [], "Arrival": { "Place": { "ChargingStation": false, "OriginalPosition": [ -123.020098, 49.232872 ], "Position": [ -123.0203051, 49.2328499 ] } }, "Departure": { "Place": { "ChargingStation": false, "OriginalPosition": [ -123.1181051, 49.282423 ], "Position": [ -123.1180883, 49.2824349 ] } }, "TravelSteps": [ { "Distance": 1288, "Duration": 102, "Type": "Depart" }, { "Distance": 262, "Duration": 24, "Type": "Ramp" }, { "Distance": 1356, "Duration": 134, "Type": "Turn" }, { "Distance": 7092, "Duration": 568, "Type": "Keep" }, { "Distance": 65, "Duration": 26, "Type": "Turn" }, { "Distance": 50, "Duration": 18, "Type": "Turn" }, { "Distance": 0, "Duration": 0, "Type": "Arrive" } ] } } ] } ] }
cURL
curl --request POST \ --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/routes?key=Your_key' \ --header 'Content-Type: application/json' \ --data '{ "Origin": [ -123.118105, 49.282423 ], "Destination": [ -123.020098, 49.232872 ] }'
AWS CLI
aws geo-routes calculate-routes --key ${YourKey} \ --origin -123.118105 49.282423 \ --destination -123.020098 49.232872