如何使用 OSRM 的匹配服务
How to use OSRM's match service
如 header 中所述:如何使用匹配调用?
我试过了
http://router.project-osrm.org/match/v1/driving/8.610048,46.99917;8.530232,47.051?overview=full&radiuses=49;49
我不确定 radiuses
的列表是否正确。
我无法让它工作。我还尝试了 [49;49]
或 {49;49}
该命令适用于 route
:
http://router.project-osrm.org/route/v1/driving/8.610048,46.99917;8.530232,47.051?overview=full
背景见
编辑:如果你看一下例子here,它似乎不需要timestamps
/match/v1/{profile}/{coordinates}?steps={true|false}&geometries={polyline|polyline6|geojson}&overview={simplified|full|false}&annotations={true|false}
来自docs:
Large jumps in the timestamps (> 60s) or improbable transitions lead to trace splits if a complete matching could not be found.
我认为这是您的请求的问题。给定的两个点相距超过 60s,OSRM 无法匹配成功。 radiuses
指定正确。
以下查询对我有用:
http://router.project-osrm.org/match/v1/driving/8.610048,46.99917;8.620048,46.99917?overview=full&radiuses=49;49
这个returns:
{"tracepoints":[{"location":[8.610971,46.998963],"name":"Alte Kantonstrasse","hint":"GKUFgJEhBwAAAAAAHQAAAAAAAAC5AAAAAAAAAB0AAAAAAAAAuQAAAPsCAACbZIMAsyXNAgBhgwCCJs0CAAAPABki8hY=","matchings_index":0,"waypoint_index":0,"alternatives_count":0},{"location":[8.620295,46.999681],"name":"Schönenbuchstrasse","hint":"nIEFAJ7IFIA3AAAAZAAAAAAAAADYAAAANwAAAGQAAAAAAAAA2AAAAPsCAAAHiYMAgSjNAhCIgwCCJs0CAAAPABki8hY=","matchings_index":0,"waypoint_index":1,"alternatives_count":5}],"matchings":[{"distance":922.3,"duration":114.1,"weight":114.1,"weight_name":"routability","geometry":"onz}Gqyps@Wg@S_@aCaFMUYo@c@w@OKOCWmAWs@aBiDsAsCMYH[HY\_@h@ObBW^w@BQAUKu@ASF[ZaABOFYpAyIf@mD","confidence":0.000982,"legs":[{"distance":922.3,"duration":114.1,"weight":114.1,"summary":"","steps":[]}]}],"code":"Ok"}
所以给定的两个输入点8.610048,46.99917
和8.620048,46.99917
匹配到8.610971,46.998963
和8.620295,46.999681
.
据我所知,如果你想实现类似 that 的东西,你需要为 OSRM 提供更多输入点,这些输入点之间的间隔小于 60s。
有关 route
和 match
服务之间差异的解释,另请参阅 here。
如 header 中所述:如何使用匹配调用?
我试过了
http://router.project-osrm.org/match/v1/driving/8.610048,46.99917;8.530232,47.051?overview=full&radiuses=49;49
我不确定 radiuses
的列表是否正确。
我无法让它工作。我还尝试了 [49;49]
或 {49;49}
该命令适用于 route
:
http://router.project-osrm.org/route/v1/driving/8.610048,46.99917;8.530232,47.051?overview=full
背景见
编辑:如果你看一下例子here,它似乎不需要timestamps
/match/v1/{profile}/{coordinates}?steps={true|false}&geometries={polyline|polyline6|geojson}&overview={simplified|full|false}&annotations={true|false}
来自docs:
Large jumps in the timestamps (> 60s) or improbable transitions lead to trace splits if a complete matching could not be found.
我认为这是您的请求的问题。给定的两个点相距超过 60s,OSRM 无法匹配成功。 radiuses
指定正确。
以下查询对我有用:
http://router.project-osrm.org/match/v1/driving/8.610048,46.99917;8.620048,46.99917?overview=full&radiuses=49;49
这个returns:
{"tracepoints":[{"location":[8.610971,46.998963],"name":"Alte Kantonstrasse","hint":"GKUFgJEhBwAAAAAAHQAAAAAAAAC5AAAAAAAAAB0AAAAAAAAAuQAAAPsCAACbZIMAsyXNAgBhgwCCJs0CAAAPABki8hY=","matchings_index":0,"waypoint_index":0,"alternatives_count":0},{"location":[8.620295,46.999681],"name":"Schönenbuchstrasse","hint":"nIEFAJ7IFIA3AAAAZAAAAAAAAADYAAAANwAAAGQAAAAAAAAA2AAAAPsCAAAHiYMAgSjNAhCIgwCCJs0CAAAPABki8hY=","matchings_index":0,"waypoint_index":1,"alternatives_count":5}],"matchings":[{"distance":922.3,"duration":114.1,"weight":114.1,"weight_name":"routability","geometry":"onz}Gqyps@Wg@S_@aCaFMUYo@c@w@OKOCWmAWs@aBiDsAsCMYH[HY\_@h@ObBW^w@BQAUKu@ASF[ZaABOFYpAyIf@mD","confidence":0.000982,"legs":[{"distance":922.3,"duration":114.1,"weight":114.1,"summary":"","steps":[]}]}],"code":"Ok"}
所以给定的两个输入点8.610048,46.99917
和8.620048,46.99917
匹配到8.610971,46.998963
和8.620295,46.999681
.
据我所知,如果你想实现类似 that 的东西,你需要为 OSRM 提供更多输入点,这些输入点之间的间隔小于 60s。
有关 route
和 match
服务之间差异的解释,另请参阅 here。