[GraphHopper] Adding weight/time tables to algorithms' calculation

Peter K peathal at yahoo.de
Fri Dec 20 19:40:25 UTC 2013


Hi Ignas,

> I was wondering if there is a way to add some time-based weights to
> the streets during the calculation of fastest path? 
>
> For example, I'd have a timetable that would keep record of how long
> does it take on average to pass through street (from one edge to
> another one) depending on day time. 
> i.e. 1:00 - 2:00 PM it takes 30min to get from A to B
>       8:00 - 9:00 AM it takes 60min to get from A to B
>
> Also, I'd like to know if there's a way to "close" a node so that
> Graphhopper wouldn't use it during the calculation?

Both is easily possible with just simple Dijkstra and A* (not so with CH
enabled). Extend from your 'Weighting' of choice like CarFlagEncoder and do:

double calcWeight(EdgeIteratorBase eb) {
   if(excludeEdgeIds.contains(eb.getEdge()))
      return Double.MAX_VALUE;
  
   return timeMap.get(eb.getEdge());
}

in GraphHopper.java you need to overwrite createWeighting and return the
weighting for your own custom string.

Of course you need some knowledge about which edgeId is where. You can
get this information via the LocationIndex.

Regards,
Peter.



More information about the GraphHopper mailing list