Avoid ferries with Java Code

Hello guys,

I already saw this announcement:

I tried it with this example:

Even though I set “avoid=ferry”, Graphhopper still uses the ferry in the given example.
Did I do something wrong? Is there also a way to avoid ferries in Java Code and not by GET request?

Help would be much appreciated.
Best regards

Welcome to the GraphHopper community :slight_smile:

For those flexible queries you currently need to add “&ch.disable=true” additionally to “&avoid=ferry”. Does this help?

Hello karussell,

thanks for your reply. I already did that, didn’t I? I set “avoid=ferry&ch.disable=true” in my example above, but it still didn’t work.

Best regards

Ah, sorry. I missed that. The problem here is that it is only “avoid ferry” and not “exclude ferry”. I.e. if the detour without the ferry would be too long it still uses the ferry. Excluding ferries is currently only possible for a dedicated setup. For more details about this please contact us per Email.

Thank you for your help. I am using a dedicated setup. I tried excluding ferries by writing my own Encoder:

public class NoFerryCarFlagEncoder extends CarFlagEncoder {
     public NoFerryCarFlagEncoder(int speedBits, int speedFactor, int maxTurnCosts) {
          super(speedBits, speedFactor, maxTurnCosts);
     public EncodingManager.Access getAccess(ReaderWay way) {
          if (way.hasTag("route", ferries))
	     return EncodingManager.Access.CAN_SKIP;

          return super.getAccess(way);

But I’m not sure if this is the proper way to do it. At least it seemed to work and the routing service didn’t use the ferry.

Best regards

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.