GraphHopper.com | Forum | GitHub | Maps | Blog

Using custom speed limits for OSM ways


#1

I would like to be able to use average speed data that I have gathered which assigns a speed for each OSM way. We are part of the way there in that we read the speeds in OSMReader.java put them in a speedsMap (see e.g. changes here made by my colleague: https://github.com/charanpald/graphhopper/commit/570088fbd11d4ff28f21c00e7c249dcfea2d2527). However the speeds aren’t being used for the routing.

My question sounds a bit similar to this one Custom OSM data speed limits but not quite. It looks like I would need to write a new Encoder class that maps from osm_id to int/double but I am not sure how to do this. Is there an example I can work from, and is this the missing piece?

Thank you for your help!
Charanpal


#2

If you set the speeds early in OSMReader, make sure you do this either with disabled setSpeed method in all encoders or after setSpeed is called there. Otherwise this method will overwrite it. Another possibility is to store this in a separate storage and use a Weighting that uses this separate storage.