Add time to custom weighting

I want to add weather data to a custom weighting. My weather Data has also a time resolution. That’s why I need to make the weighting time dependent. Is that possible?

public double calcWeight(EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId) {

// Here I would need the approximated time from the start node, when this edge will be reached.
long time = ???

double precipitation= this.interpolation.getPrecipitation(edgeState, time);

double result = superWeighting.calcWeight(edgeState, reverse, prevOrNextEdgeId);

result += precipitation;

return result; 


Thank you for your answer! This is good solution, if you use the current precipitation data. I also want to include nowcast of the precipitation data. If the edge is far away from the start node, I would like to take an forecast of the precipitation data in the weighting. So is it possible to get the time in the weighting, when the edge would be reached in the route.

If you want to use a fixed time that is already possible via providing the weighting a certain parameter from the system or the URL. A real time dependent routing is only possible for the public transit part, not yet for the road routing. But you plan to do this in the next months, see e.g. this issue.

1 Like