Time and distance per leg

I need to get the time and distance for each leg of the trip, not just the total time and distance. Is that possible?

We currently return only this information per total route and per instruction. Is this sufficient in your case or what do you define as ‘leg’?

Another option would be to use type=gpx and use the created time stamps for every point.

Per leg = per part of the route (start - via point - via point - finish). I don’t need the instructions, but I do need the separate times/distances.

This would be currently only possible via the information available in the instructions. E.g. add the time and distance of every instruction until you observe the sign==5 (VIA_REACHED) then you have the information of the first leg, then do it again and for the last leg do it again until sign==4 (FINISH) is observed.

We need this feature as well.
Calculating the distance and time over the instructions is not very efficient. It needs more traffic if you usually not need the instructions and it needs more calculation on the client side.

Is this feature planed for the future?

Yes, see https://github.com/graphhopper/graphhopper/issues/439

Update: see also this blog post that describes how to fetch this information per leg: https://www.graphhopper.com/blog/2019/11/28/routing-api-using-path-details/

1 Like
Powered by Discourse