Traffic data into Graphhopper

This is somehow related to https://discuss.graphhopper.com/t/insert-traffic-data-into-graphhopper/846 and https://github.com/graphhopper/graphhopper/issues/242

I’m trying to apply custom speed restrictions into Graphhopper and it appeared that if I apply speed == 0 it applied (see issue 242) but subsequent route requests through that edge fail with

java.lang.IllegalStateException: Calculating time should not require to read speed from edge in wrong direction. Reverse:false, fwd:false, bad:false

and everything works fine if I use setAccess for edge.

So it seems like either setSpeed(0) is correct and there is a bug in routing through such edges or setSpeed(0) should be restricted.

Can someone point me into right direction here, please.

2 Likes

Do you have a minimal example which shows the issue?

I found the cause, changing edges speed doesn’t work with CH enabled, although it seems pretty obvious now it wasn’t obvious initially, maybe it should be stated somehow in docs.

So my next question is is it possible to update CH graph after edges weight changed? My use case require routing to be as fast as possible and I can pay with memory consumption here. If it’s possible but not implemented I can invest some time into it.

Thank You

Everytime you change the edge weights you have to do the CH preparation again. To speed up the next preparation it could use a previous calculated node order but this is not implemented yet.

Could you point me what to look at here? How to rebuild CH?
Any tips on how to implement it?

You have to clear the shortcuts ‘somehow’ and call this method again: https://github.com/graphhopper/graphhopper/blob/master/core/src/main/java/com/graphhopper/routing/ch/PrepareContractionHierarchies.java#L204

(Currently calling it twice is not possible)