You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use max_speed EV for the AbstractFlagEncoder #2266
I'm currently testing to switch the AbstractFlagEncoder to use the max_speed encoded value and have already a working prototype. The remaining problem seems to be related to how we handle spatial rules and fallback values.
Let's take the following route which is part of our unittests as an example:
The route changes if the encoded max_speed values in conjunction with spatial rules are used:
The detour seems to be caused by the high fallback values of the spatial rule which assumes 100kmh for unclassified/residential. This is higher than the tagged speedlimit of 70kmh for the B85 and causes the routing to bypass it.
I can lower the limits in the GermanySpatialRule so that they fit the defaultSpeedMap values of the CarFlagEncoder but i'm not sure if that's the best course of action.
I am not 100% sure what you are doing, but there are two different values now: max_speed and average_speed. For the routing, I would use average_speed, not sure if you are using max_speed there?
getSpeed retrieves the default speed for the FlagEncoder based on the road class, applyMaxSpeed retrieves the maxspeed for the way and falls back to former default speed if no valid value could be found. And finally the speed is capped by applyBadSurfaceSpeed based on the surface of the way.
So we're parsing the maximum speed for each way in the OSMMaxSpeedParser and again for each registered FlagEncoder. And on top of that SpatialRules are not applied.
I don't think this will be possible. In #2810 I will feed max_speed with a precise value based on the country and urban_density but this will be available after the import only. So I think the best way to make this happen is in a custom model (?)
Activity
boldtrn commentedon Mar 25, 2021
I am not 100% sure what you are doing, but there are two different values now: max_speed and average_speed. For the routing, I would use average_speed, not sure if you are using max_speed there?
otbutz commentedon Mar 25, 2021
The AbstractFlagEncoder currently does the following as part of its avg speed calculation:
graphhopper/core/src/main/java/com/graphhopper/routing/util/AbstractFlagEncoder.java
Lines 212 to 223 in e919a94
So it's basically doing the same as the OSMMaxSpeedParser but doesn't take SpatialRules into account.
graphhopper/core/src/main/java/com/graphhopper/routing/util/CarFlagEncoder.java
Lines 237 to 248 in e919a94
getSpeedretrieves the default speed for the FlagEncoder based on the road class,applyMaxSpeedretrieves the maxspeed for the way and falls back to former default speed if no valid value could be found. And finally the speed is capped byapplyBadSurfaceSpeedbased on the surface of the way.otbutz commentedon Mar 25, 2021
So we're parsing the maximum speed for each way in the OSMMaxSpeedParser and again for each registered FlagEncoder. And on top of that SpatialRules are not applied.
otbutz commentedon Mar 25, 2021
Lowering the fallback speeds for Germany yields the expected result:
karussell commentedon May 31, 2023
I don't think this will be possible. In #2810 I will feed max_speed with a precise value based on the country and urban_density but this will be available after the import only. So I think the best way to make this happen is in a custom model (?)
otbutz commentedon May 31, 2023
#2810 is the better approach 😉