Multi-modal routing

Is it possible to have a muti-modal routing in Graphhopper? (example: To choose some modes of transportation, let’s say bike and car, and run a combo routing) Where can i access or start to implement something like this?

Thanks for reply,

TK

Yes, you could implement this based on GraphHopper, but it is not made out-of-the-box. You’ll have to disable CH and use different traversal keys for different transportation modes in the Algorithm. I have not done it myself, but know a big company running this in production, hopefully at some point they’ll be able to open source it.

1 Like

Can you elaborate a little on different traversal keys for different transportation modes? Or where can i find some information to better understand the source code (i already read the technical documentation)?

This is probably not that trivial, still I’ll try to explain and we should document this, so please keep asking if something is unclear and I’ll try my best :slight_smile:

Every edge has an ID independent of the direction and to make it still possible that a route contains P-turns or U-turns (one edgeId would occur twice which cannot be) we introduced traversal keys which for our use case is basically edgeId*2 and +1 depending on the direction. This way the same edgeId can occur twice in a path exploration as the traversal keys are different. See the edge based traversal unit tests for an example: https://github.com/graphhopper/graphhopper/blob/master/core/src/test/java/com/graphhopper/routing/EdgeBasedRoutingAlgorithmTest.java

Now for your use case you’ll need to define where a switch of a vehicle is possible, after that switch every edge can be explored from a bike or a car additionally to e.g. the two directions. E.g. to create unique traversal keys multiply the edgeId by 4, then +1 depending on the direction and +2 depending on the vehicle. See https://github.com/graphhopper/graphhopper/blob/master/core/src/main/java/com/graphhopper/util/GHUtility.java#L521