Car routing behaviour anomaly

We recently upgraded from GH 7 to GH 9.1 in our Java project and I stumbled upon a car routing anomaly.

Tl;DR: Our GH7 setup essentially behaves like your hosted instance, while our GH9.1 setup produces problematic car routes on a particular group of OD relations, even though I tried to closely follow the available migration guides. Can you help me understand what I am observing and help me in fixing this probably incorrect behaviour?

Now in more detail.

Basic OD - Relation near Greifswald, Germany:

  • Start: 54.044958,13.406233
  • Goal: 54.091079,13.432414

Routing this on your hosted GH instance (which I assume runs a relatively recent version) returns this:

This is reasonable.

In our local setup with GH 7 I get the following (relevant config section under graphhopper key below), which looks essentially the same:

Config:

profiles:
  - name: car
    vehicle: car
    weighting: fastest
    turn_costs: true

profiles_ch:
  - profile: car

prepare.min_network_size: 200

##### Network Details #####
graph.flag_encoders: car|turn_costs=true

##### Path Details ######
graph.encoded_values: surface

##### Storage #####
import.osm.ignored_highways: footway,cycleway,path,pedestrian,steps
graph.dataaccess: RAM_STORE

Now on GH 9.1 we get this (again config under graphhopper key below), which is problematic:

Config:

profiles:
  - name: car
    turn_costs:
      vehicle_types: [ motorcar, motor_vehicle ]
      u_turn_costs: 60
    custom_model_files: [ car.json ]

profiles_ch:
  - profile: car

prepare.min_network_size: 200

##### Encoded Values ######
graph.encoded_values: surface, car_access, car_average_speed

##### Storage #####
import.osm.ignored_highways: footway,cycleway,path,pedestrian,steps
graph.dataaccess: RAM_STORE

where car.json references the built-in custom model, namely

{
  "distance_influence": 90,
  "priority": [
    { "if": "!car_access", "multiply_by": "0" }
  ],
  "speed": [
    { "if": "true", "limit_to": "car_average_speed" }
  ]
}

There are two issues with the new route.

  1. it is generally illegal, since the straight vertical section with the bridge crossing the B109 is only accessible to bikes and pedestrians. GH cannot do much about this, because the underlying OSM data simply misses the necessary annotations/barriers /tags, whatever …
  2. the straight stretch contains a relatively long section of a grade 2 gravel road, which is accurately mapped in the underlying OSM data. It is possible to force your hosted version to consider the illegal section by moving the start and goal markers very close to it.

These observations together suggest that your hosted GH instance and our GH 9.1 setup end up with noticeably different weights for the questionable route, in particular that your setup penalises the route (and in particular probably the grade 2 track) much more than we do (with presumably your defaults?), I had assumed that average_car_speed would be set appropriately based on highway grade without having to manually adjust for those.

Have we misconfigured anything on our end? I wanted to use the default upstream vehicle configurations unless I have a good reason to override them. I know how to run my own custom model, but before I start messing with the parameters I was wondering if I already took a wrong turn somewhere.

Just to be clear, I don’t really care about the problem with the inaccessibility that OSM doesn’t know about, but the fact that the gravel road appears too attractive in our GH9.1 setup.

For what its worth, google maps does not consider the illegal road at all as an option, as far as I could determine

Just noticed that Local web and graphhopper.com direction differences sounds somewhat similar (it also looks at the same GH versions we are considering here, and also pertains to particular aspects of the car routing, when using the built-in car.json file).

Maybe related?

What makes this illegal?

You can reduce the speed or priority for road_class == TRACK in the custom model to avoid this route.

I had assumed that average_car_speed would be set appropriately based on highway grade without having to manually adjust for those.

It should be, yes:

But I expect that this route is then still faster or in combination with distance better than the motorway route.

You can see the speeds for that path segment in the UI selecting the encoded value Avg. speed.

Reg the “illegal” part: AFAIK, cars are not allowed to take paths marked with this sign (a small police emergency vehicle might be able to take that route, not sure if the bridge in the middle is actually wide enough, but regular car routing should definitely not consider that path as accessible). Though as mentioned, the underlying OSM data does not flag the road in question accordingly, so this part of the question is effectively a side issue.

More importantly, though is the apparent routing profile differences between what you ship in your sources (via https://github.com/graphhopper/graphhopper/blob/master/core/src/main/resources/com/graphhopper/custom_models/car.json) and what you are hosting on GraphHopper Maps | Route Planner. The former is what we are using, and what results in the undesirable routing. The hosted instance on the other hand needs a lot more coaxing to consider the questionable route as the “best” option (essentially moving the start and end markers very close to the “problematic” route, which in turn makes the “detour” of the “correct” routing longer and longer, until the result snaps over). The bottom line is that the problematic segment appears to be penalised a lot more in the hosted version than in the shipped version of GH 9.1. I am trying to understand why. (The part of about the grade2 track was just an assumption, it might be something different that is at work here, which may or may not be the the distance influence thing).

Note that I could not really validate my assumption that the hosted instance is using a modified car routing, as it won’t accept the contents of graphhopper/core/src/main/resources/com/graphhopper/custom_models/car.json at master · graphhopper/graphhopper · GitHub as a valid custom model: it complains about average_car_speed not being allowed.

If possible, it would help tremendously if the car profile actively in use on GraphHopper Maps | Route Planner would be accessible somewhere (and for good measure the configurations of the other live profiles might be interesting as well)

AFAIK, cars are not allowed to take paths marked with this sign

If there is such a sign, then this is a tagging issue and not a GraphHopper issue.

I am trying to understand why.

Read more about it here.

average_car_speed

Yes, we do not allow this at the moment for the hosted version. Note, it is called car_average_speed.