Editing routing > speed_limits > car.json has no effect on route duration?

Hi all,

I created a local instance of ORS a few months back and after the fix for the “point not within radius” issue I’ve been happy as can be.

However, for awhile I’ve known the accuracy is a bit off in terms of route durations; on average it tends to overestimate the route. This can be an extremely large difference across routes which stretch long distances. Essentially, the issue for me is that if I query for directions using the “fastest” or “recommended” preferences then I know that the results have a good chance of being not representative of reality.

I thought I found the solution when I read through a thread where they suggested editing the car.json file found in:

openrouteservice > src > main > resources > resources > services > routing > speed_limits > car.json

It seems like all I’d have to do is change these speed limits to reflect the driving speeds/practices observed in Western Australia (as opposed to their European defaults) and I’d instantly have calculated distances/durations which are closer to reality. Then, I could continue to test/tweak different speed values until, on average, they are close enough to what I’d expect across some test routes.

I went ahead and changed this file and then (after remedying the recent build issues caused by the elevation provider’s service being down via disabling elevation calculations across all profiles) I had my new container up and running - confirmed to be referencing my own .pbf and .config files.

However, despite me going through the effort to change this car.json speed file, the returned values it’s providing me with are the exact same results generated via the previous container which I’d built months ago!

In the car.json file I increased almost every single value by anywhere from 10 - 40 km/h … I should expect the durations to have increased in at least some amount … right?

  • Have I edited the speed parameters in the right place?
  • Is there some parameter I need to change in the .config to enable building from these custom files?
  • Is it defaulting back to the normal values because of some caching?
  • Is it actually working but I just think this does something different than what it actually is changing?
  • Do I have to query with some new parameter (maximum_speed query value doesn’t change anything - but I’ve read this is because it’s been deprecated)?
  • Something obvious I’m missing (most likely scenario haha)?

I’m having a lot of success with this tool and I find it really awesome to use - I’d just really want to have a bit of luck in tweaking these speed values to represent how people are driving in Australia - but I have no idea what’s going on here!

I’d appreciate any help you can give me :smiley: and thanks in advance for any info/replies!!

I’ll reply with the contents of my app.config and cars.json files for your reference.

Cheers,
Troy

car.json …

{
default: 
{
	"motorway": 110,
	"motorway_link": 80,
	"motorroad": 100,
	"trunk": 110,
	"trunk_link": 80,
	"primary": 110,
	"primary_link": 80,
	"secondary": 100,
	"secondary_link": 80,
	"tertiary": 100,
	"tertiary_link": 80,
	"unclassified": 80,
	"residential": 60,
	"living_street": 55,
	"service": 45,
	"road": 55,
	"track": 50
},
surface:
{
	"asphalt": -1, 
	"concrete": -1,
	"concrete:plates": -1,
	"concrete:lanes": -1,
	"paved": -1,
	"cement": 80,
	"compacted": 85,
	"fine_gravel": 80,
	"paving_stones":50,
	"metal": 65,
	"bricks": 55,
	"grass": 50,
	"wood": 40,
	"sett": 55,
	"grass_paver": 55,
	"gravel": 55,
	"unpaved": 40,
	"ground": 65,
	"dirt": 55,
	"pebblestone": 40,
	"tartan": 40,
	"cobblestone": 40,
	"clay": 40,
	"earth": 30,
	"stone": 30,
	"rocky": 30,
	"sand": 30,
	"mud": 15,
	"unknown" : 45
},
tracktype:
{
	"grade1": 70,
	"grade2": 60,
	"grade3": 55,
	"grade4": 50,
	"grade5": 45
},
max_speeds: {
	"AT:urban": 50,
	"AT:rural": 100,
	"AT:trunk": 100,
	"AT:motorway": 130,
	"CH:urban": 50,
	"CH:rural": 80,
	"CH:trunk": 100,
	"CH:motorway": 120,
	"CZ:urban": 50,
	"CZ:rural": 90,
	"CZ:trunk": 80,
	"CZ:motorway": 80,
	"DK:urban": 50,
	"DK:rural": 80,
	"DK:motorway": 130,
	"DE:living_street": 7,
	"DE:urban": 50,
	"DE:rural": 100,
	"DE:motorway": 130,
	"FI:urban": 50,
	"FI:rural": 80,
	"FI:trunk": 100,
	"FI:motorway": 120,
	"FR:urban": 50,
	"FR:rural": 80,
	"FR:trunk": 110,
	"FR:motorway": 130,
	"GR:urban": 50,
	"GR:rural": 90,
	"GR:trunk": 110,
	"GR:motorway": 130,
	"HU:urban": 50,
	"HU:rural": 90,
	"HU:trunk": 110,
	"HU:motorway": 130,
	"IT:urban": 50,
	"IT:rural": 90,
	"IT:trunk": 110,
	"IT:motorway": 130,
	"JP:national": 60,
	"JP:motorway": 100,
	"PL:living_street": 20,
	"PL:urban": 50,
	"PL:rural": 90,
	"PL:motorway": 140,
	"RO:urban": 50,
	"RO:rural": 90,
	"RO:trunk": 100,
	"RO:motorway": 130,
	"RU:living_street": 20,
	"RU:rural": 90,
	"RU:urban": 60,
	"RU:motorway": 110,
	"SK:urban": 50,
	"SK:rural": 90,
	"SK:trunk": 90,
	"SK:motorway": 90,
	"SI:urban": 50,
	"SI:rural": 90,
	"SI:trunk": 110,
	"SI:motorway": 130,
	"ES:urban": 50,
	"ES:rural": 90,
	"ES:trunk": 100,
	"ES:motorway": 120,
	"SE:urban": 50,
	"SE:rural": 70,
	"SE:trunk": 90,
	"SE:motorway": 110,
	"GB:nsl_single": 95,
	"GB:nsl_dual": 112,
	"GB:motorway": 112,
	"UA:urban": 60,
	"UA:rural": 90,
	"UA:trunk": 110,
	"UA:motorway": 130,
	"UZ:living_street": 30,
	"UZ:urban": 70,
	"UZ:rural": 100,
	"UZ:motorway": 110
}

}

app.config …

{
"ors": {
"info": {
  "base_url": "https://openrouteservice.org/",
  "support_mail": "support@openrouteservice.org",
  "author_tag": "openrouteservice",
  "content_licence": "LGPL 3.0"
},
"services": {
  "matrix": {
    "enabled": true,
    "maximum_routes": 100,
    "maximum_routes_flexible": 25,
    "maximum_search_radius": 5000,
    "maximum_visited_nodes": 100000,
    "allow_resolve_locations": true,
    "attribution": "openrouteservice.org, OpenStreetMap contributors"
  },
  "isochrones": {
    "enabled": true,
    "maximum_range_distance": [
      { "profiles": "any", "value": 50000 },
      { "profiles": "driving-car, driving-hgv", "value": 100000 }
    ],
    "maximum_range_time": [
      { "profiles": "any", "value": 18000 },
      { "profiles": "driving-car, driving-hgv", "value": 3600 }
    ],
    "fastisochrones": {
      "maximum_range_distance": [
        { "profiles": "any", "value": 50000 },
        { "profiles": "driving-car, driving-hgv", "value": 500000 }
      ],
      "maximum_range_time": [
        { "profiles": "any", "value": 18000 },
        { "profiles": "driving-car, driving-hgv", "value": 10800 }
      ],
      "profiles": {
        "default_params": {
          "enabled": false,
          "threads": 12,
          "weightings": "recommended",
          "maxcellnodes": 5000
        },
        "profile-vehicles-hgv": {
          "enabled": true,
          "threads": 12,
          "weightings": "recommended, shortest",
          "maxcellnodes": 5000
        }
      }
    },
    "maximum_intervals": 10,
    "maximum_locations": 2,
    "allow_compute_area": true
  },























  "routing": {
    "enabled": true,
    "mode": "normal",
    "routing_description": "This is a routing file from openrouteservice",
    "routing_name": "openrouteservice routing",
    "sources": ["data/osm_file.pbf"],
    "init_threads": 2,
    "attribution": "openrouteservice.org, OpenStreetMap contributors",
    "elevation_preprocessed": false,
    "profiles": {
      "active": [
        "car"
      ],
      "default_params": {
        "encoder_flags_size": 8,
        "graphs_root_path": "graphs",
        "elevation_provider": "gmted",
        "elevation_cache_path": "cgiar_provider",
        "elevation_cache_clear": false,
        "instructions": true,
        "elevation": false,
        "maximum_distance": 5000000,
        "maximum_distance_dynamic_weights": 5000000,
        "maximum_distance_avoid_areas": 5000000,
        "maximum_waypoints": 50,
        "maximum_snapping_radius": 25000,
        "maximum_avoid_polygon_area": 200000000,
        "maximum_avoid_polygon_extent": 20000,
        "maximum_distance_alternative_routes": 5000000,
        "maximum_alternative_routes": 3,
        "maximum_distance_round_trip_routes": 5000000,
        "maximum_speed_lower_bound": 110,

        "location_index_resolution": 250,
        "location_index_search_iterations": 50,

        "preparation": {
          "min_network_size": 200,
          "min_one_way_network_size": 200,

          "methods": {
            "lm": {
              "enabled": true,
              "threads": 1,
              "weightings": "recommended,shortest",
              "landmarks": 16
            }
          }
        },
        "execution": {
          "methods": {
            "lm": {
              "disabling_allowed": true,
              "active_landmarks": 8
            }
          }
        }
      },
      "profile-car": {
        "profiles": "driving-car",
        "parameters": {
          "encoder_flags_size": 8,
          "encoder_options": "turn_costs=true|block_fords=false|use_acceleration=false",
          "maximum_distance": 5000000,
          "elevation": false,
          "maximum_snapping_radius": 25000,
          "preparation": {
            "min_network_size": 200,
            "min_one_way_network_size": 200,

            "methods": {
              "ch": {
                "enabled": true,
                "threads": 1,
                "weightings": "fastest"
              },
              "lm": {
                "enabled": false,
                "threads": 1,
                "weightings": "fastest,shortest",
                "landmarks": 16
              },
              "core": {
                  "enabled": true,
                  "threads": 1,
                  "weightings": "fastest,shortest",
                  "landmarks": 64,
                  "lmsets": "highways;allow_all"
              }
            }
          },
          "execution": {
            "methods": {
              "ch": {
                "disabling_allowed": true
              },
              "lm": {
                "disabling_allowed": true,
                "active_landmarks": 6
              },
              "core": {
                "disabling_allowed": true,
                "active_landmarks": 6
              }
            }
          },
          "ext_storages": {
            "WayCategory": {},
            "HeavyVehicle": {},
            "WaySurfaceType": {},
            "RoadAccessRestrictions": {
              "use_for_warnings": true
            }
          }
        }
      },
      "profile-hgv": {
        "profiles": "driving-hgv",
        "parameters": {
          "encoder_flags_size": 8,
          "encoder_options": "turn_costs=true|block_fords=false|use_acceleration=false",
          "maximum_distance": 100000,
          "elevation": false,
          "preparation": {
            "min_network_size": 200,
            "min_one_way_network_size": 200,

            "methods": {
              "ch": {
                "enabled": true,
                "threads": 1,
                "weightings": "recommended"
              },
              "lm": {
                "enabled": true,
                "threads": 1,
                "weightings": "recommended,shortest",
                "landmarks": 16
              },
              "core": {
                "enabled": true,
                "threads": 1,
                "weightings": "recommended,shortest",
                "landmarks": 64,
                "lmsets": "highways;allow_all"
              }
            }
          },
          "execution": {
            "methods": {
              "ch": {
                "disabling_allowed": true
              },
              "lm": {
                "disabling_allowed": true,
                "active_landmarks": 6
              },
              "core": {
                "disabling_allowed": true,
                "active_landmarks": 6
              }

            }
          },
          "ext_storages": {
            "WayCategory": {},
            "HeavyVehicle": {
              "restrictions": true
            },
            "WaySurfaceType": {}
          }
        }
      },
      "profile-bike-regular": {
        "profiles": "cycling-regular",
        "parameters": {
          "encoder_options": "consider_elevation=true|turn_costs=true|block_fords=false",
          "elevation": false,
          "ext_storages": {
            "WayCategory": {},
            "WaySurfaceType": {},
            "HillIndex": {},
            "TrailDifficulty": {}
          }
        }
      },
      "profile-bike-mountain": {
        "profiles": "cycling-mountain",
        "parameters": {
          "encoder_options": "consider_elevation=true|turn_costs=true|block_fords=false",
          "elevation": false,
          "ext_storages": {
            "WayCategory": {},
            "WaySurfaceType": {},
            "HillIndex": {},
            "TrailDifficulty": {}
          }
        }
      },
      "profile-bike-road": {
        "profiles": "cycling-road",
        "parameters": {
          "encoder_options": "consider_elevation=true|turn_costs=true|block_fords=false",
          "elevation": false,
          "ext_storages": {
            "WayCategory": {},
            "WaySurfaceType": {},
            "HillIndex": {},
            "TrailDifficulty": {}
          }
        }
      },
      "profile-bike-electric": {
        "profiles": "cycling-electric",
        "parameters": {
          "encoder_options": "consider_elevation=true|turn_costs=true|block_fords=false",
          "elevation": false,
          "ext_storages": {
            "WayCategory": {},
            "WaySurfaceType": {},
            "HillIndex": {},
            "TrailDifficulty": {}
          }
        }
      },
      "profile-walking": {
        "profiles": "foot-walking",
        "parameters": {
          "encoder_options": "block_fords=false",
          "elevation": false,
          "ext_storages": {
            "WayCategory": {},
            "WaySurfaceType": {},
            "HillIndex": {},
            "TrailDifficulty": {}
          }
        }
      },
      "profile-hiking": {
        "profiles": "foot-hiking",
        "parameters": {
          "encoder_options": "block_fords=false",
          "elevation": false,
          "ext_storages": {
            "WayCategory": {},
            "WaySurfaceType": {},
            "HillIndex": {},
            "TrailDifficulty": {}
          }
        }
      },

      "profile-wheelchair": {
        "profiles": "wheelchair",
        "parameters": {
          "encoder_options": "block_fords=true",
          "elevation": false,
          "maximum_snapping_radius": 50,
          "ext_storages": {
            "WayCategory": {},
            "WaySurfaceType": {},
            "Wheelchair": {
              "KerbsOnCrossings": "true"
            },
            "OsmId": {}
          }
        }
      }
    }
  }
},
"logging": {
  "enabled": true,
  "level_file": "DEBUG_LOGGING.json",
  "location": "/var/log/ors",
  "stdout": true
},
"system_message": [
    {
        "active": false,
        "text": "This message would be sent with every routing bike fastest request",
        "condition": {
            "request_service": "routing",
            "request_profile": "cycling-regular,cycling-mountain,cycling-road,cycling-electric",
            "request_preference": "fastest"
        }
    },
    {
        "active": false,
        "text": "This message would be sent with every request for geojson response",
        "condition": {
            "api_format": "geojson"
        }
    },
    {
        "active": false,
        "text": "This message would be sent with every request on API v1 from January 2020 until June 2050",
        "condition": {
            "api_version": 1,
            "time_after": "2020-01-01T00:00:00Z",
            "time_before": "2050-06-01T00:00:00Z"
        }
    },
    {
        "active": false,
        "text": "This message would be sent with every request"
    }
]

}
}

I just did a bit more reading and found on #1165 that the maxspeed tag provided on OSM is used as first priority and that the surface and road type defaults are only used if the maxspeed isn’t provided (second priority).

Annnnd, this explains pretty well why I’m not seeing changes in the route durations/distances.

I think I need to do a bit more investigation then on why source-A to destination-B is pinned by Google Maps as being something like a 5 hour drive, but then the output I’d get could be something like 8 hours… I’d need to figure out if they’re picking the same route, and if not why not.

I do distinctly remember running a few examples of Google Maps vs ORS and seeing that the distances were really close on matching routes (as you’d expect), but the duration estimates were always overestimated by sometimes 30%+.

Is there anyway I can play around with the internal speed factor in CarFlagEncoder.java?

I’ve seen it’s set to 5, but I don’t know what the 5 means - as in what moving it to 4 or 6 would actually do? Is there any documentation surrounding that?

This thread doesn’t make too much sense now because I answered the main part to my own question …

However, I have stumbled across some new evidence which I can’t explain; worthy of its own thread maybe?

  • From: 117.871796 -32.337402
  • To: 118.1875 -32.15744

The route calculated by ORS follows …

The route calculated by Google Maps follows …

As you can see, the routes are pretty much exactly the same, but Google Maps has the distance = 46km and the duration = 34 mins … Compare this to the results from ORS and we see something interesting …

ors_calcs

ORS matches the distance, as we’d expect, but the duration is waaaay off - just under twice the amount of time across the exact same route?

Investigating further, I looked on OverpassTurbo, recycling a query I found on the forum, to try and find what the issue was … I thought maybe the maxspeed had been input incorrectly, and that’s what was blowing out the duration estimate? However …

Overpass Turbo shows absolutely no roads on the map at all?? So, now I’m seriously confused how a route could’ve even been calculated along roads which don’t exist in ORS?

Granted this .pbf I’m using was subset from geofabrik Australia a couple months back - but I doubt someone would have deleted a clear main road since that point?

Any ideas what’s going on here? I’m happy to start another thread if necessary?

Cheers,
Troy

Hi Troy,

thank you for the detailed documentation, it’s very easy to follow :smiley:
I think everything fit’s into this thread.
Regarding your overpass query:
you only request ways with the tag “maxspeed”, so if there is no “maxspeed” tag on the roads they won’t be returned.
Replace it with “highway” and you should see the roads.

Not sure if this works in your local installation, but try to run the requests you are testing with the attributes parameter: attributes: ["avgspeed"].
It will return the speed segments between different points of the route.
You should be able to identify which parts of the route slow it down and can then inspect the OSM Data better.


Sometimes the reason for the time differens is an unpaved or similar segment which reduces the speed to a low value.

But for the route it is taking it should be using the secondary value so 100 km/h
which doesn’t fit with the 63 minutes for 46 km.

Best regards