I want to reduce the speed for certain road types. My approach is to write my own CarFlagEncoder and overwrite the speed values in the defaultSpeedMap. My custom FlagEncoder looks like this:
public class Car30FlagEncoder extends CarFlagEncoder {
public Car30FlagEncoder() {
super();
defaultSpeedMap.put("primary", 30);
defaultSpeedMap.put("primary_link", 30);
defaultSpeedMap.put("secondary", 30);
defaultSpeedMap.put("secondary_link", 30);
defaultSpeedMap.put("tertiary", 30);
defaultSpeedMap.put("tertiary_link", 30);
}
public String toString() {
return "car30";
}
However, overwriting the defaultSpeedMap does not have any effect. If I do a routing (along a primary road) once with the standard CarFlagEncoder and once with my Car30FlagEncoder both routes exhibit exactly the same travel time. What am I missing? The road has the OSM tag maxspeed (with a value >30 km/h) set. Does maxspeed overwrite the values from defaultSpeedMap?
Using the custom profiles these changes will be much simpler and without touching the Java code. This feature is already available in 2.x but the format for them will significantly change so that it might make more sense to use 3.x (which is not yet released but will be in a few weeks)
However, overwriting the defaultSpeedMap does not have any effect.
Did you recompile the code and removed your graph storage folder?
Does maxspeed overwrite the values from defaultSpeedMap?
Did you recompile the code and removed your graph storage folder?
Yes.
Does maxspeed overwrite the values from defaultSpeedMap?
Yes.
Ok. Then I guess that’s essentially the problem.
Just to be sure. Can I achieve the following behavior with custom profiles: For a specific road type, say secondary, I can adjust the vehicle speed so that vehicle_speed = min(maxspeed, my_custom_value)?