Modify CarFlagEncoder to allow type of road

Hello,

I am trying to modify CarFlagEncoder.java so that GraphHopper will use two pieces of road which it does not by default:


Am I right in saying that to allow access to this road it is as simple as removing: restrictedValues.add("private")

If anyone can please explain the best way to do this I would be very appreciative.

Thanks very much,

Joel

You could do that, but is intentionally not allowed to use a highway tagged as “private”.

1 Like

What @ratrun says is correct.
If you still want this you’ll have to extend the CarFlagEncoder:

class MyCarFE extends CarFlagEncoder {
    public MyCarFE(some args) {
        super(some args);
        restrictedValues.remove("private");
    }
}

GraphHopper graphHopper = ....;
graphHopper.setEncodingManager(new EncodingManager(new MyCarFE(some args)));

@karussell Thank you for this Peter. Could you please tell me how to allow access to bus lanes? This is the last thing I need to finish project.

Allowing buses is a bit more tricky. You’ll have to look up the tagging and add it to the restrictions set (in the correct order), to the barriers list(s) and also to the oneway restriction as it could be “oneway=yes and psv=opposite_lane”.