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: Introduce RoadClass, RoadEnvironment, CarMaxSpeed, Surface, Toll and more EncodedValues by karussell · Pull Request #1548 · graphhopper/graphhopper · GitHub
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…
It’ll be good there is a good tutorial. I have no choice. I am looking into the source codes to add new profile.