Hello, I am using orsdirections api to find a route(cycling-road) with given coordinates and I am getting back a json which works fine if i apply it as a geojson layer in my leaflet map. The coordinates which I manually provide are the coordinates used to find the route. The route seems good but the problem is I want to get back all the nodes with network type node_network which I can use to highlight the nodes that comes in between the coordinates throughout the route that I have originally provided. For example : I want a route between node A and node E. So, if node B and D lies in between the route then I want to get back those nodes so that I can highlight them. Is there a way to get back info about those nodes in the json? Or is there a better solution for this problem. Any help is appreciated.
I am a bit confused by your question.
When you request a route, you’ll either get back
- a json (for the GET-request or the POST-request to
- a geojson (for a POST-request to
Let’s assume you requested a route with with coordinates A, B, and C as an example.
You’ll get back a route that goes through coordinates A, A1…An, B, B1…Bm, C where A1 through An and B1 through Bm are intermediate coordinates from the route generation.
If you requested a json, it’ll include an encoded polyline. You can decode it (see here) and you’ll get a list of all coordinates A, A1…An, B, B1…Bm, C.
If you requested a geojson, it’ll probably be a linestring consisting of coordinates A, A1…An, B, B1…Bm, C.
You can extract any info you need from either of these two lists of coordinates.
Hello, Thank you for your quick response. I did get the geojson as response and the linestring has all the coordinates in it. But my question is can I get a separate list of bicycle nodes(with rcn_ref) that falls within the route. Or is there any other way to get those cycle nodes in that route?
no, it is not possible to get the nodes with a
rcn_ref via ors services.
Hello @amandus @jschnell
I have a base cycling route (brown line) and I want to follow that route while creating routes with the coordinates ( in the picture node 95, 96, 97). I want to select the route via 96 if I select 95 and 97. I have seen that it’s possible in another Belgian website (Fietsrouteplanner langs knooppunten | Vlaanderen Fietsland).
I’m still a bit confused.
The example you showed from the vlaanderen-fietsland route planner has preset routes between a certain set of nodes and will only yield routes that use these routes and start, end and go via one of these nodes.
You can restrict route planning in your application the same way, but you would have to implement it for yourself.
If you want to use the ors for that, you’d have to insert at least some of the coordinates on your brown cycling roads into a request that you then actually pass to ors.
If you describe what you’re trying to do a bit clearer, there might be other ideas.
Basically I want a fixed bicycle route all over my map (Belgium) with all the fixed bicycle nodes. When I select two or more than two nodes, I want to select the nodes that lies between those selected nodes along the route as well. Then, I want to display the route and calculate the distance and time from my starting node to rest of the nodes. Is there a way how I can select those nodes in between?
I assume you have the fixed bicycle route and nodes already precalculated.
Then what you are asking for is a route on this reduced road graph. You can do this on your side using the distances between connected nodes, using e.g. Dijkstra’s algorithm. You’ll then get an order of nodes to be traversed from start to finish.
You could feed this order back into an ors query, but since the ors includes tho whole graph, you might not get a route using your fixed bicycle routes.