Skip to content

Encoded values: max_speed, average_speed, and country default speed limits? #3248

@Vectorial1024

Description

@Vectorial1024

Describe the bug
Consider this to be somewhere between a question and a bug report.

This spins off from #3244.

While reviewing GraphHopper behavior, and after fixing the country classification problem, I noticed that roads in Hong Kong contain seemingly inconsistent max speed / average speed, as demonstrated below.

Perhaps I don't understand GraphHopper well enough to see what is the intended/actual behavior.

To Reproduce

  1. checkout master branch of GraphHopper
  2. use the Hong Kong OSM extract https://download.geofabrik.de/asia/china/hong-kong.html
  3. enable country-specific speed limits, default settings
  4. start the GraphHopper server, default settings
  5. locate a major road in Hong Kong with no provided maxspeed (e.g. Tai Po Road; see screenshots below)
  6. enable "Show Routing Graph"
  7. look at one of the highway=primary in the area
  8. notice that max_speed=50.0 and also car_average_speed=66.0
  9. hmmm...?

Expected behavior
It seems this should be max_speed=50.0 and also car_average_speed=45.0 (see Additional Context for justification).

System Information

Using the master branch. Supposedly this should also be seen in the live web version, but we can't look at the Routing Graph there.

Screenshots & Logs

Locate the relevant major road:

Image

After enabling "Show Routing Graph":

Image

Additional Context

As per Hong Kong regulations documented on the Default Speed Limits page, all roads shall have an implicit 50 km/h speed limit unless otherwise specified.

The relevant roads are correctly classified as "HKG" thanks to #3246. In addition, the relevant roads do not have any OSM-provided maxspeed=* value. Therefore, they should have the implicit 50 km/h speed limit.

In this case, the GraphHopper encoded value max_speed=50.0 is correct.

As far as I have experimented with GraphHopper before and have followed the major GraphHopper update news, currently GraphHopper will use the *_average_speed to compare between different paths during CH processing.

Look at CarAverageSpeedParser.java. GH will first try to use the OSM-provided maxspeed=* value, but if that value is not available, then it will use the "default" highway-derived "maxspeed" value. Then, GH will use that value and does *= 0.9 to generate an initial road speed (see applyMaxSpeed()). The urban/rural processing will further massage this value, but that should hopefully be out of scope.

Because the relevant roads are highway=primary, according to the table, GH will first take the "default value" of 65, and then do *= 0.9 to yield 58.5. This is quite close to the actual encoded car_average_speed=66.0, so I am guessing my understanding is correct.

afaik GraphHopper will use car_max_speed for actual pathfinding, which means it will believe the relevant road has a speed of 66 km/h. However, this will exceed the implicit speed limit of 50 km/h, and would result in hypothetical unlawful speeding.


It seems to me that GraphHopper should read the default speed limits ("65"), and then check the country-specific default speed limits (max 50 km/h), and then finally generate a reasonable speed for the road (probably 45 km/h; possibly even lower because the example is located in urban area).

Highways with lower hierarchy (e.g. =unclassified) can continue to use the GraphHopper default speeds, but highways with higher hierarchy (e.g. =primary) should really verify their allowed speed with country-specific default speed limits.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions