我需要跟踪路线,但只能从de Origen到de Destiny。
我有这个:
json_file<-"http://router.project-osrm.org/trip/v1/driving/-5.81336,43.495596;-5.81779973,43.51087296?overview=full&geometries=geojson"
json_data <- fromJSON(paste(readLines(json_file), collapse=""))
使用此代码我得到了这个结果:
{"code":"Ok","waypoints":[{"waypoint_index":0,"trips_index":0,"hint":"F6RAiRykQInJAAAArQAAAAAAAABZDQAAZAAAAFcAAAAAAAAAqwYAACviAADrSqf_ubCXApBLp_-ssJcCAABvACcs_IU=","location":[-5.813525,43.495609],"name":""},{"waypoint_index":1,"trips_index":0,"hint":"tpSvhv___38AAAAACgAAACEAAAAIAAAAAAAAAAoAAAAhAAAACAAAACviAAD-Oaf_PeyXAjg6p_9Z7JcCAwDvEics_IU=","location":[-5.817858,43.510845],"name":""}],"trips":[{"legs":[{"steps":[],"weight":517.8,"distance":3963.8,"summary":"","duration":433.7},{"steps":[],"weight":467.3,"distance":3623.2,"summary":"","duration":388.5}],"weight_name":"routability","geometry":{"coordinates":[[-5.813525,43.495609],[-5.813582,43.495234],[-5.813609,43.494994],[-5.813515,43.495006],[-5.813433,43.49508],[-5.813291,43.495068],[-5.813241,43.4952],[-5.813137,43.495599],[-5.813091,43.495895],[-5.813057,43.496398],[-5.813064,43.49676],[-5.813024,43.496912],[-5.812932,43.497002],[-5.812826,43.497055],[-5.812571,43.497091],[-5.812744,43.497122],[-5.81297,43.497121],[-5.813119,43.497147],[-5.81323,43.497313],[-5.81356,43.497976],[-5.81358,43.498268],[-5.813498,43.498445],[-5.813315,43.49857],[-5.812972,43.498857],[-5.812853,43.499002],[-5.81257,43.49935],[-5.812047,43.49966],[-5.811642,43.500021],[-5.811659,43.500239],[-5.81214,43.500289],[-5.812929,43.500538],[-5.813255,43.500644],[-5.813942,43.500936],[-5.814285,43.501285],[-5.814217,43.501845],[-5.814491,43.502493],[-5.814459,43.502818],[-5.814216,43.503453],[-5.814236,43.503972],[-5.814054,43.504372],[-5.813916,43.504709],[-5.813797,43.50515],[-5.813461,43.505269],[-5.813208,43.505471],[-5.812643,43.505454],[-5.812002,43.505655],[-5.811721,43.506035],[-5.810903,43.506505],[-5.810416,43.506565],[-5.809732,43.506925],[-5.809527,43.507274],[-5.809496,43.507554],[-5.809587,43.507991],[-5.810063,43.508416],[-5.810038,43.508534],[-5.809603,43.508995],[-5.809469,43.509323],[-5.810065,43.509416],[-5.810389,43.509503],[-5.811039,43.509819],[-5.8113,43.509928],[-5.812149,43.51029],[-5.814227,43.511002],[-5.814932,43.511346],[-5.815475,43.511669],[-5.815704,43.511887],[-5.815855,43.512146],[-5.815963,43.512352],[-5.816116,43.512559],[-5.816259,43.512772],[-5.816385,43.513091],[-5.816413,43.513201],[-5.816475,43.513334],[-5.817,43.513943],[-5.817601,43.514557],[-5.817723,43.51465],[-5.818087,43.514912],[-5.818106,43.515006],[-5.818155,43.515095],[-5.818265,43.515198],[-5.818363,43.515251],[-5.81848,43.515289],[-5.818677,43.515308],[-5.818903,43.515265],[-5.81907,43.515172],[-5.819174,43.515051],[-5.819212,43.514863],[-5.819155,43.514716],[-5.819016,43.514588],[-5.818865,43.514521],[-5.818737,43.514506],[-5.818719,43.514492],[-5.818668,43.514456],[-5.818621,43.514413],[-5.818562,43.514341],[-5.818525,43.514219],[-5.818546,43.514107],[-5.818695,43.513693],[-5.818817,43.513358],[-5.818938,43.512981],[-5.819012,43.512652],[-5.81902,43.512404],[-5.818985,43.512079],[-5.818939,43.511861],[-5.818843,43.511606],[-5.818779,43.511463],[-5.818616,43.511103],[-5.818512,43.510873],[-5.818513,43.510776],[-5.818565,43.510686],[-5.818576,43.510587],[-5.818563,43.510529],[-5.818536,43.510476],[-5.818508,43.51044],[-5.818475,43.510407],[-5.818413,43.510364],[-5.818342,43.510331],[-5.81826,43.510308],[-5.818135,43.510297],[-5.817993,43.510317],[-5.817919,43.510343],[-5.817855,43.510378],[-5.817766,43.510459],[-5.817721,43.510549],[-5.817719,43.510661],[-5.817773,43.51077],[-5.817858,43.510845],[-5.817858,43.510845],[-5.817969,43.510897],[-5.818077,43.51092],[-5.818098,43.510922],[-5.818223,43.510919],[-5.818309,43.510956],[-5.818413,43.511015],[-5.818499,43.511119],[-5.818699,43.511572],[-5.818827,43.511918],[-5.818856,43.512063],[-5.818894,43.5123],[-5.818899,43.512461],[-5.818895,43.512552],[-5.818828,43.512929],[-5.818717,43.51327],[-5.818618,43.513548],[-5.818432,43.514073],[-5.818406,43.514197],[-5.818406,43.514309],[-5.8184,43.514417],[-5.81835,43.514563],[-5.818237,43.514621],[-5.818146,43.514716],[-5.817723,43.51465],[-5.817601,43.514557],[-5.817,43.513943],[-5.816475,43.513334],[-5.816413,43.513201],[-5.816385,43.513091],[-5.816259,43.512772],[-5.816116,43.512559],[-5.815963,43.512352],[-5.815855,43.512146],[-5.815704,43.511887],[-5.815475,43.511669],[-5.814932,43.511346],[-5.814227,43.511002],[-5.812149,43.51029],[-5.8113,43.509928],[-5.811039,43.509819],[-5.810389,43.509503],[-5.810065,43.509416],[-5.809469,43.509323],[-5.809603,43.508995],[-5.810038,43.508534],[-5.810063,43.508416],[-5.809587,43.507991],[-5.809496,43.507554],[-5.809527,43.507274],[-5.809732,43.506925],[-5.810416,43.506565],[-5.810903,43.506505],[-5.811721,43.506035],[-5.812002,43.505655],[-5.812643,43.505454],[-5.813208,43.505471],[-5.813461,43.505269],[-5.813797,43.50515],[-5.813916,43.504709],[-5.814054,43.504372],[-5.814236,43.503972],[-5.814216,43.503453],[-5.814459,43.502818],[-5.814491,43.502493],[-5.814217,43.501845],[-5.814285,43.501285],[-5.813942,43.500936],[-5.813255,43.500644],[-5.812929,43.500538],[-5.81214,43.500289],[-5.811659,43.500239],[-5.811642,43.500021],[-5.812047,43.49966],[-5.81257,43.49935],[-5.812853,43.499002],[-5.812972,43.498857],[-5.813315,43.49857],[-5.813498,43.498445],[-5.81358,43.498268],[-5.81356,43.497976],[-5.81323,43.497313],[-5.813119,43.497147],[-5.81297,43.497121],[-5.812744,43.497122],[-5.812571,43.497091],[-5.812826,43.497055],[-5.812932,43.497002],[-5.813024,43.496912],[-5.813064,43.49676],[-5.813057,43.496398],[-5.813091,43.495895],[-5.813137,43.495599],[-5.813241,43.4952],[-5.813291,43.495068],[-5.813433,43.49508],[-5.813447,43.495174],[-5.813522,43.495217],[-5.813549,43.495233],[-5.813582,43.495234],[-5.813525,43.495609]],"type":"LineString"},"weight":985.1,"distance":7587,"duration":822.2}]}
此结果是Origin-Destiny-Origin的坐标。我只需要Origin-Destiny。我该如何解决这个问题?
答案 0 :(得分:0)
您正在拨打错误的服务,请改为使用route
:
http://router.project-osrm.org/route/v1/driving/-5.81336,43.495596;-5.81779973,43.51087296?overview=full&geometries=geojson