I want to get the length and osm-way-id for each edge in my route. I got the osm-way-id from encoded values, however, the ‘max_length’ in the encoded values did nothing.
The length of an edge is definitely not zero, otherwise it won’t be a route of 2 km. Is this max-length (in encoded values) the length of the each edge or it is something else? How I can get the length of each edge of my route?
You can use the distance path detail instead, which will give you the length per edge (note that OSM ways can consist of multiple edges). For distance (or time) path details there is no separate encoded value required.
The max_length encoded value is for length-restricted roads (roads with a rather rare sign that indicates a maximum length of the vehicle)
I can now match the osm-ids with edges (for same osm-id for multiple edges). However, is there a way to get all the edges of the graph and corresponding osm-ids and length at once before searching for routes for all my OD pairs? It will save me a lot of post-processing for each of the routes separately.
I tried the following. Please let me know if this is the right way…
However, when I try to match with the individual edge lengths of the route (that I got from distance details), it does not match for some edges. for example:
Also, would you please suggest me how to add the corresponding osm-ids here.
You can fetch the osmIDs via allEdges.get(osmIDEnc) and you get osmIDEnc via
IntEncodedValue osmIDEnc = encodingManager.getIntEncodedValue(OSMWayID.KEY)
it does not match for some edges
This shouldn’t be the case. Make sure that the first and last edge are complete (i.e. the start and end are on junctions) when you compare the distances.
And now, the previous working part is not working anymore and gives me error of “GraphHopper storage not initialized”. What wrong did I do and why this one is not working anymore?
while (allEdges.next()) {
int alledgeId = allEdges.getEdge();
double edge_len = allEdges.getDistance();
double osm_ids = allEdges.get(osmIDEnc);