在此场景中,系统使用 Route Optimization API 生成包含路线多段线的路线令牌。
在 OptimizeToursRequest
消息中,设置 populateTransitionPolylines
(REST、gRPC),以便在 OptimizeToursResponse
中的 ShipmentRoute
的转换中生成 routePolyline
(REST、gRPC)和 routeToken
(REST、gRPC)字段。
请参阅设置为 populateTransitionPolylines=true 的请求示例
{ "populateTransitionPolylines": true, "model": { "shipments": [ { "pickups": [ { "arrivalLocation": { "latitude": 37.73881799999999, "longitude": -122.4161 } } ], "deliveries": [ { "arrivalLocation": { "latitude": 37.79581, "longitude": -122.4218856 } } ] } ], "vehicles": [ { "startLocation": { "latitude": 37.73881799999999, "longitude": -122.4161 }, "endLocation": { "latitude": 37.73881799999999, "longitude": -122.4161 }, "costPerKilometer": 1.0 } ], "globalStartTime": "2024-02-13T00:00:00.000Z", "globalEndTime": "2024-02-14T06:00:00.000Z" } }
请参阅使用 populateTransitionPolylines=true 的请求的响应示例
{ "routes": [ { "vehicleStartTime": "2024-02-13T00:00:00Z", "vehicleEndTime": "2024-02-13T00:39:02Z", "visits": [ { "isPickup": true, "startTime": "2024-02-13T00:00:00Z", "detour": "0s" }, { "startTime": "2024-02-13T00:19:43Z", "detour": "0s" } ], "transitions": [ { "travelDuration": "0s", "waitDuration": "0s", "totalDuration": "0s", "startTime": "2024-02-13T00:00:00Z", "routePolyline": {} }, { "travelDuration": "1183s", "travelDistanceMeters": 8591, "waitDuration": "0s", "totalDuration": "1183s", "startTime": "2024-02-13T00:00:00Z", "routePolyline": { "points": "}{ieFlkdjV?A@I?E@K?S@K?GB]@W?C?G@O?C@E?E@EB_AB_@?G?Q?KAQCm@?MAOAU?K?A?C?CAK?K?A?A?A?CAC?QAM?KASAE?C?CAEAC?ACGIO]s@ACAACCAECEAEEECIKSOYEIMWCGIMGKCIGMAAEI?ACGAC?C?AAE?C@a@?C?G@O@k@@O?]Bc@@k@@k@@c@Bq@@k@@]Bu@@e@@_@?OD{A@c@?I@]@O?C@i@BcAFq@?_@gAGeACk@G]Ew@S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?B?B@D@R?J@L?P@B?B?@?@?@?J@J?B?B?@?J@T@N?LBl@@P?J?P?FC^C~@AD?DAD?BAN?F?BAVC\\?FAJ?RAJ?DAH?@" }, "routeToken": "CvsBCqIBMp8BGoMBCisCFgtG1Hlkf4MAwCL3qQKkpALomZ4Ci7meAozjjAPP34kDmSPq3BeDoWEAEiQzanUe6iFiW5kIYp6_RksOUl0YSWqIhERXJcl7xeckmqblinUaCgALCSuQBwIAdR4qCTkbWSARAAocAzICAgE9aRDGPkU-QYY-SIWx4e-az6a28QEiF1RSUGladU8zQk15cmtlUVBvZnVyd0FzEAUaOwo5ChgKDQoCCAERAAAAAACAZkARCtejcD0ulEASACIZChdUUlBpWnQtVkJNeXJrZVFQb2Z1cndBcygBIhUA29kTa1qXXaY59KJpCuXOkxw-Vkw" } ], "metrics": { "performedShipmentCount": 1, "travelDuration": "2342s", "waitDuration": "0s", "delayDuration": "0s", "breakDuration": "0s", "visitDuration": "0s", "totalDuration": "2342s", "travelDistanceMeters": 17356 }, "routeCosts": { "model.vehicles.cost_per_kilometer": 17.356 }, "routeTotalCost": 17.356 } ], "metrics": { "aggregatedRouteMetrics": { "performedShipmentCount": 1, "travelDuration": "2342s", "waitDuration": "0s", "delayDuration": "0s", "breakDuration": "0s", "visitDuration": "0s", "totalDuration": "2342s", "travelDistanceMeters": 17356 }, "usedVehicleCount": 1, "earliestVehicleStartTime": "2024-02-13T00:00:00Z", "latestVehicleEndTime": "2024-02-13T00:39:02Z", "totalCost": 17.356, "costs": { "model.vehicles.cost_per_kilometer": 17.356 } } }
使用来自 OptimizeTourResponse
的路线令牌在 Navigation SDK 中启动导航会话。导航会话会尝试遵循 Route Optimization API 返回的路线。由于道路状况动态变化,使用给定令牌生成的路线可能会与原始路线不同。虽然路线令牌不会过期,但我们建议您在生成路线令牌后尽快使用该令牌,以最大限度地缩短实际路线与计划路线之间的距离。
使用 Navigator.setDestinations
方法将 Route Optimization API 生成的路线令牌传递给 Navigation SDK 时,您必须指定与 ShipmentRoute
转换的结束位置匹配的单个目的地。
如需详细了解路线令牌,请参阅 Android 版 Navigation SDK 和 iOS 版 Navigation SDK 的“规划路线”文档。
如需详细了解路线多段线编码,请参阅多段线。