我正在尝试使用OSRM来获取按它们之间的距离排序的位置列表。为此,我正在使用旅行服务(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
正如您所看到的,waypoint_index
在实际下提供的订单会排除其假定组(1)中的最后一项。 我认为这可能与往返选项有关,是这种情况吗?如果是这样,我可以在旅行服务上设置一个选项,为我提供我需要的结果吗?
或者,是否有其他服务会收到位置列表并按照它们之间的距离返回它们?鉴于我无法提供开始/结束。
我想发送一个位置列表,然后按接近顺序接收它们,而不是使用往返行程(如果这违反了之前的要求)。
谢谢!