Install custom flag encoder for graphhopper.sh

I use ./graphhopper web berlin.osm.pbf to start a local graphhopper web server. I want to use a custom flag encoder, which I created and called HorseEncoder.java. What are the steps to get graphhopper to recognize the line graph.flag_encoders: horse in the config.yml?

You have to create your own FlagEncoderFactory that could extend from DefaultFlagEncoderFactory. Then set this in the GraphHopper class. General docs for a new flag encoder are here: https://github.com/graphhopper/graphhopper/blob/master/docs/core/create-new-flagencoder.md

Ok, and to implement the avoidance of highways by tag value (e.g. avoid highway=motorway) I guess I would have to follow the example of the bike encoder, which has a field avoidHighwayTags. That is, I would need methods handleWayTags -> handlePriority -> collect and the weightToPrioMap?

EDIT: In other words, I would have to implement my own priorityWayEncoder, right?

It is easier to have a look into the removed AvoidWeighting of this PR: https://github.com/graphhopper/graphhopper/pull/1548/commits/e6e28d891f9601157914fbb01926378683e0c09b

1 Like

I was wondering whether overriding getAccess(ReaderWay way) and using

if (avoidHighwayTags.contains(highwayValue)) {
			return EncodingManager.Access.CAN_SKIP;
}

wouldn’t also do the trick…

EDIT: not sure what CAN_SKIP does, but looks like the routing engine will avoid those highways types altogether…