Adjusting defaultSpeedMap in custom CarFlagEncoder has no effect

Hi,

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?

I am using

  • version 2.3
  • contraction hierarchies
  • weighting fastest
  • ASTAR_BI

Best, Johannes

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?

Yes.

Thanks for the quick reply.

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)?

Best, Johannes

For a specific road type, say secondary, I can adjust the vehicle speed

Yes, in the new format (either JSON or YAML) this would be:

speed:
 - if: road_class == SECONDARY
   limit_to: 80 # without this value it picks the default from the Java code

In master branch there is an editor with auto completion to help you create these scripts.

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