GraphHopper.com | Forum | GitHub | Maps | Blog

Adding penalty time for certain nodes on resulting route


#1

Hi,

After calculating the shortest route, I’d like to add some penalty time for specific nodes. For example for every traffic signal I want to add 5 minutes to the total time. Maybe it’s even better to add all the penalty time into a separate tag in GHResponse. What’s the best way to do that?

I was thinking of extending Graphhopper and change the calcPaths method. Looping thorugh the resulting queryGraph. However somehow I can’t iterate through queryGraph. How can I get all nodes on the path and then add a penalty time for a specific node?

Thanks for any help!


#2

Hi,

first of all you need to store traffic lights in the graph. See this issue for more information. Once you can store them in the graph you could create PathDetails for traffic lights. Counting the PathDetails and adding time penalties should be straightforward. This won’t change your routing though. If you want to change your routing the approach will become a lot more complicated.

Best,
Robin