-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
get_forward_backward_by_key is buggy on non oneway roads #6568
Description
osrm-backend/profiles/lib/tags.lua
Lines 20 to 31 in 51e0420
| if (data.oneway) then | |
| if data.is_forward_oneway then | |
| forward = forward or common | |
| end | |
| if data.is_reverse_oneway then | |
| backward = backward or common | |
| end | |
| else | |
| forward = forward or common | |
| backward = backward or common | |
| end | |
| end |
data.oneway could be “yes”, “1”, “true”, “no”, and some others. In case of “no” this is no oneway. However in lua if ("no") is similiar to JS and actually only checks if a string exists, that is not empty. So it actually results to true and would behave as if it would be a oneway. This is very wrong. Oneway handling/calculation is done before already, so it should be sufficient, to check for is_forward_oneway and is_reverse_oneway as that is already calculated and also considers implicit oneways like motorways and link roads.
oneway is calculated here already:
osrm-backend/profiles/lib/way_handlers.lua
Lines 544 to 589 in 51e0420
| function WayHandlers.oneway(profile,way,result,data) | |
| if not profile.oneway_handling then | |
| return | |
| end | |
| local oneway | |
| if profile.oneway_handling == true then | |
| oneway = Tags.get_value_by_prefixed_sequence(way,profile.restrictions,'oneway') or way:get_value_by_key("oneway") | |
| elseif profile.oneway_handling == 'specific' then | |
| oneway = Tags.get_value_by_prefixed_sequence(way,profile.restrictions,'oneway') | |
| elseif profile.oneway_handling == 'conditional' then | |
| -- Following code assumes that `oneway` and `oneway:conditional` tags have opposite values and takes weakest (always `no`). | |
| -- So if we will have: | |
| -- oneway=yes, oneway:conditional=no @ (condition1) | |
| -- oneway=no, oneway:conditional=yes @ (condition2) | |
| -- condition1 will be always true and condition2 will be always false. | |
| if way:get_value_by_key("oneway:conditional") then | |
| oneway = "no" | |
| else | |
| oneway = Tags.get_value_by_prefixed_sequence(way,profile.restrictions,'oneway') or way:get_value_by_key("oneway") | |
| end | |
| end | |
| data.oneway = oneway | |
| if oneway == "-1" then | |
| data.is_reverse_oneway = true | |
| result.forward_mode = mode.inaccessible | |
| elseif oneway == "yes" or | |
| oneway == "1" or | |
| oneway == "true" then | |
| data.is_forward_oneway = true | |
| result.backward_mode = mode.inaccessible | |
| elseif profile.oneway_handling == true then | |
| local junction = way:get_value_by_key("junction") | |
| if data.highway == "motorway" or | |
| junction == "roundabout" or | |
| junction == "circular" then | |
| if oneway ~= "no" then | |
| -- implied oneway | |
| data.is_forward_oneway = true | |
| result.backward_mode = mode.inaccessible | |
| end | |
| end | |
| end | |
| end |