我正在尝试使用 OSRM 来获取按它们之间的距离排序的位置列表。为此,我正在使用 Trip 服务(https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#trip-service)。
给定编码的折线:
omq~Fji_vOg@sHQcnAjCtrAkCs|AvHpcBwCeeB
我收到以下信息:
"waypoints": [
{
"waypoint_index": 0,
"trips_index": 0,
"hint": "RzfEg1U3xIPaAAAAJgAAAAAAAAAAAAAANgAAAAoAAAAAAAAAAAAAAHM6AACFecb6__B-AoR5xvoQ8X4CAACPBd_PZ4A=",
"name": "",
"location": [
-87.656059,
41.873663
]
},
{
"waypoint_index": 2,
"trips_index": 0,
"hint": "OTfEg5M4xINDAwAAnwEAAAAAAAAAAAAA0AAAAGgAAAAAAAAAAAAAAHM6AACJf8b6xvF-Aoh_xvrY8X4CAADPEN_PZ4A=",
"name": "",
"location": [
-87.654519,
41.873862
]
},
{
"waypoint_index": 5,
"trips_index": 0,
"hint": "WuVchFzlXIQ6AwAAbwUAAAAAAAAAAAAAzgAAAFwBAAAAAAAAAAAAAHM6AAD3sMb6EPN-Avywxvoy8n4CAACfBd_PZ4A=",
"name": "",
"location": [
-87.641865,
41.874192
]
},
{
"waypoint_index": 1,
"trips_index": 0,
"hint": "PDfEg343xIOuAQAAggQAAAAAAAAAAAAAawAAACEBAAAAAAAAAAAAAHM6AACsfMb6su9-Aq58xvp2734CAADPEN_PZ4A=",
"name": "",
"location": [
-87.655252,
41.87333
]
},
{
"waypoint_index": 3,
"trips_index": 0,
"hint": "VuVchFjlXITqAQAA0QEAAAAAAAC1BAAAegAAAHUAAAAAAAAALQEAAHM6AACYtsb6L_J-AjK3xvoy8n4CAABvFt_PZ4A=",
"name": "",
"location": [
-87.640424,
41.873967
]
},
{
"waypoint_index": 6,
"trips_index": 0,
"hint": "6WJUhBgEhoTTBAAAdgQAAAAAAAAAAAAANAEAAB4BAAAAAAAAAAAAAHM6AAAJesb6H-x-Alh4xvoa7H4CAAB_Ft_PZ4A=",
"name": "",
"location": [
-87.655927,
41.872415
]
},
{
"waypoint_index": 4,
"trips_index": 0,
"hint": "TOVchFDlXIRTAgAAhQEAACoAAADuAAAAlAAAAGIAAAAKAAAAPAAAAHM6AAAtuMb6FvB-Aja4xvoS734CAQCPBd_PZ4A=",
"name": "",
"location": [
-87.640019,
41.87343
]
}
]
如果我正确理解文档,waypoint_index 应该按距离提供位置的顺序。如果是这样,考虑到结果,它似乎不起作用。在这里检查:
通缉
Group 1
lat: 41.87368, lon: -87.65606
lat: 41.87388, lon: -87.65452
lat: 41.87327, lon: -87.65525
lat: 41.87241, lon: -87.65636
Group 2
lat: 41.87317, lon: -87.64001
lat: 41.87397, lon: -87.64186
lat: 41.87397, lon: -87.64027
实际的
Group 1
lat: 41.873663, lon: -87.656059
lat: 41.87333, lon: -87.655252
lat: 41.873862, lon: -87.654519
Group 2
lat: 41.873967, lon: -87.640424
lat: 41.87343, lon: -87.640019
lat: 41.874192, lon: -87.641865
Group 1
lat: 41.872415, lon: -87.655927
如您所见,Actualwaypoint_index
下提供的订单 确实排除了其假定组 (1) 中的最后一项。我认为这可能与往返选项有关,是这样吗?如果是这样,我可以在旅行服务上设置一个选项来为我提供我需要的结果吗?
或者,是否有其他服务会接收位置列表并按它们之间的距离排序返回它们?鉴于我无法提供开始/结束。
我只想发送一个位置列表并按邻近度排序接收它们,而不是使用往返(如果这是破坏先前请求的原因)。
谢谢!