According to the current version of car.lua, WayHandlers.maxspeed is called after WayHandlers.speed in:
|
-- compute speed taking into account way type, maxspeed tags, etc. |
|
WayHandlers.speed, |
|
WayHandlers.surface, |
|
WayHandlers.maxspeed, |
|
WayHandlers.penalties, |
|
|
which overwrites the speeds with the maximum speed values.
|
if forward and forward > 0 then |
|
result.forward_speed = forward * profile.speed_reduction |
|
end |
|
|
|
if backward and backward > 0 then |
|
result.backward_speed = backward * profile.speed_reduction |
|
end |
|
end |
It seems more reasonable that, if we specify a default speed per road in:
|
speeds = Sequence { |
|
highway = { |
|
motorway = 90, |
|
motorway_link = 45, |
|
trunk = 85, |
|
trunk_link = 40, |
|
primary = 65, |
|
primary_link = 30, |
|
secondary = 55, |
|
secondary_link = 25, |
|
tertiary = 40, |
|
tertiary_link = 20, |
|
unclassified = 25, |
|
residential = 25, |
|
living_street = 10, |
|
service = 15 |
|
} |
Then we only use (max speed *0.8) if result.forward_speed or result.backward_speed don’t have a value assigned still.
And finally, only assign the default speed if the parse_maxspeed function returns 0.
This could be done by assigning result.forward_speed = -1 instead of profile.default_speed
|
if profile.access_tag_whitelist[data.backward_access] then |
|
result.backward_speed = profile.default_speed |
|
elseif data.backward_access and not profile.access_tag_blacklist[data.backward_access] then |
|
result.backward_speed = profile.default_speed -- fallback to the avg speed if access tag is not blacklisted |
|
elseif not data.backward_access and data.forward_access then |
|
result.backward_mode = mode.inaccessible |
|
end |
and then in WayHandlers.maxspeed function we can assign result.forward_speed = forward * profile.speed_reduction only if result.forward_speed == -1.
Looking forward to having your input on this. Thanks in advance.
According to the current version of car.lua, WayHandlers.maxspeed is called after WayHandlers.speed in:
osrm-backend/profiles/car.lua
Lines 420 to 425 in f520379
which overwrites the speeds with the maximum speed values.
osrm-backend/profiles/lib/way_handlers.lua
Lines 440 to 447 in f520379
It seems more reasonable that, if we specify a default speed per road in:
osrm-backend/profiles/car.lua
Lines 140 to 156 in f520379
Then we only use (max speed *0.8) if result.forward_speed or result.backward_speed don’t have a value assigned still.
And finally, only assign the default speed if the parse_maxspeed function returns 0.
This could be done by assigning result.forward_speed = -1 instead of profile.default_speed
osrm-backend/profiles/lib/way_handlers.lua
Lines 293 to 299 in f520379
and then in WayHandlers.maxspeed function we can assign result.forward_speed = forward * profile.speed_reduction only if result.forward_speed == -1.
Looking forward to having your input on this. Thanks in advance.