Implementing average driving speed for each road segment

Hi there,

I have a roads data set (in osm.pbf format) with the average driving speed for each road segment. What would be the best way to specify that GraphHopper should use these speeds for routing and not default speeds per road type? The average driving speed for each road segment is stored as “maxspeed” in a “other_tags” field in my osm.pbf file.


You should adjust one of the existing or write your own FlagEncoder that does this. The most important methods are getAccess(ReaderWay) where you specify whether or not an OSM way should be considered accessible for your vehicles and handleWayTags where you should read your maxspeed tag and set the speed and access flags (take a look at AbstractFlagEncoder to see how this works).

Thank you for this @easbar. Let me try this.

If I adjust the CarFlagEncoder, would the following work?

  1. In the getAccess(ReaderWay) method as shown below, would I supplement “highway” with “other_tags” or would you recommend I add an additional If statement for “other_tags”?

  1. In the handleWayTags would I specify maxspeed in the place of speed?

I am trying to extend CarFlagEncoder to use “maxspeed” in my "other_tags field/tag.

However, I am getting this error. It seems “other_tags” is being accessed, but not “maxspeed” in “other_tags”. I have not changed anything by the getAccess(ReaderWay) and handleWayTags methods yet.

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