Custom OSM data speed limits

An example of what I want to do: I want to simulate how travelling would be different if certain highways would allow for a maximum speed of 400km/h (imagining that our cars could travel that fast). For that reason I altered OSM data to set custom maximum speed.

β†’ Question 1: Can I change the vehicle profile to allow a much higher (maximum) car speed for certain roads?
β†’ Question 2: Does Graphhopper respect such OSM speed limits by default or do you set your own defaults for different road types?
(I have read that it defaults to values, but also that it respects OSM speed limits, so I am not sure what is true anymore.)

I found Country-specific speed limits, Slow down road speeds in cities and Car: Different max speed for inner and outer city in the forum, but neither of those solve my problem/experiment.

1 Like

Yes. You probably need to increase the number of bits used for storage of the speed (configurable) and the maximum value (not configurable). So create a sub class of the CarFlagEncoder call the super class with e.g. 10 bits for the speed (and keep e.g. a factor of 5km/h) and after this, set maxPossibleSpeed = 400;

Question 2: Does Graphhopper respect such OSM speed limits by default or do you set your own defaults for different road types?

Depending on the vehicle we have to consider a different behaviour. But e.g. for car we use these values, plus guess depending on some heuristics what the speed should be e.g. if highway=motorway we use 100km/h, see defaultSpeedMap, which you can also modify of course.

Hi:)

I have a question related to this.

what does this mean exactly? What value am I getting when using the encoder.getSpeed(edgeID) method? Is it the speed limit of the osm data or is it a guess?

To be more precisely on what I wanna do: I would like to derive the congestion of a road segment by comparing actual speed data at that segment with the particular speed limit. Hence, it would be really important to know the legal speed limit of a road segment.

According to other threads that I read, it is possible to implement a custom FlagEncoder which reads the data from the osm file. Therefore I would have to add a field like EncodingDoubleValue maxSpeedLimit and then add an accessor for it. What is not entirely clear to me is, how and when do I assign this field?

Any help would be really appreaciated!

The guess from the maximum speeds.

To fetch the legal value you have to store it separately. This can be done in the recent 0.8 release with adding the generic flag encoder.

Thank you very much.

Is there any documentation available for how one would do this?

1 Like

I know this is old, but I’m also in need of the legal speed limit for an specific edge. Im relatively new at programming and a complete noob with graphhopper (working on a project I didnt create that uses graphhopper) and would really appreciate any documentatio regarding how to β€œstore it separately. This can be done in the recent 0.8 release with adding the generic flag encoder.” since I wouldnt know how to even get started with this.

2 Likes