Directional Destination Tags (#3061)

* cucumber test scenarios, #3027

* post review comments

* two tests are still failing

* fixed one test

* passing tests

* cleaner code refactor

* possible sceanrios for destination:ref:forward/backward

* added code for direction:ref:forward/backward, tests pass

* changelog

* store direction in variable

* added tags to taginfo

* fixed dumb error

* use boolean flags

* null pointer checks

* hopefully better null pointer checks
This commit is contained in:
Kajari Ghosh
2016-10-18 23:09:19 -04:00
committed by GitHub
parent f77a2474ea
commit 3f0f0e306b
6 changed files with 144 additions and 11 deletions
+5 -6
View File
@@ -498,20 +498,19 @@ function way_function (way, result)
-- Set direction according to tags on way
if obey_oneway then
if oneway == "-1" then
local is_forward = false
result.forward_mode = mode.inaccessible
result.destinations = get_destination(way, is_forward)
elseif oneway == "yes" or
oneway == "1" or
oneway == "true" or
junction == "roundabout" or
(highway == "motorway" and oneway ~= "no") then
local is_forward = true
result.backward_mode = mode.inaccessible
-- If we're on a oneway and there is no ref tag, re-use destination tag as ref.
local destination = get_destination(way)
local has_destination = destination and "" ~= destination
result.destinations = destination
result.destinations = get_destination(way, is_forward)
end
end
-- Override speed settings if explicit forward/backward maxspeeds are given
+31 -5
View File
@@ -1,27 +1,53 @@
local Destination = {}
function Destination.get_destination(way)
function Destination.get_destination(way, is_forward)
local destination = way:get_value_by_key("destination")
local destination_forward = way:get_value_by_key("destination:forward")
local destination_backward = way:get_value_by_key("destination:backward")
local destination_ref = way:get_value_by_key("destination:ref")
local destination_ref_forward = way:get_value_by_key("destination:ref:forward")
local destination_ref_backward = way:get_value_by_key("destination:ref:backward")
-- Assemble destination as: "A59: Düsseldorf, Köln"
-- destination:ref ^ ^ destination
local rv = ""
if destination_ref and destination_ref ~= "" then
if destination_ref then
if is_forward == true and destination_ref == "" then
if destination_ref_forward then
destination_ref = destination_ref_forward
end
elseif is_forward == false then
if destination_ref_backward then
destination_ref = destination_ref_backward
end
end
rv = rv .. string.gsub(destination_ref, ";", ", ")
end
if destination and destination ~= "" then
if destination then
if is_forward == true and destination == "" then
if destination_forward then
destination = destination_forward
end
elseif is_forward == false then
if destination_backward then
destination = destination_backward
end
end
if destination ~= "" then
if rv ~= "" then
rv = rv .. ": "
end
rv = rv .. string.gsub(destination, ";", ", ")
end
end
return rv
end
return Destination
return Destination