From c7e19396a4800bb8e5ff19b3ebe91446258d051a Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Fri, 29 Apr 2016 12:28:03 +0200 Subject: [PATCH] Guard against mis-tagging: only use destination tag in combination with oneway tag --- features/guidance/destination-signs.feature | 35 +++++++++++---------- profiles/car.lua | 12 ++++--- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/features/guidance/destination-signs.feature b/features/guidance/destination-signs.feature index 426fdb7f6..d8b28c5e3 100644 --- a/features/guidance/destination-signs.feature +++ b/features/guidance/destination-signs.feature @@ -13,23 +13,26 @@ Feature: Destination Signs | i | j | | k | l | | m | n | + | o | p | And the ways - | nodes | name | ref | destination | destination:ref | - | ab | AB | E1 | | | - | cd | CD | | Berlin | | - | ef | EF | | Berlin | A1 | - | gh | | | Berlin | A1 | - | ij | | | Berlin | | - | kl | KL | E1 | Berlin | A1 | - | mn | MN | | Berlin;Hamburg | A1;A2 | + | nodes | name | ref | destination | destination:ref | oneway | # | + | ab | AB | E1 | | | yes | | + | cd | CD | | Berlin | | yes | | + | ef | EF | | Berlin | A1 | yes | | + | gh | | | Berlin | A1 | yes | | + | ij | | | Berlin | | yes | | + | kl | KL | E1 | Berlin | A1 | yes | | + | mn | MN | | Berlin;Hamburg | A1;A2 | yes | | + | op | OP | | Berlin;Hamburg | A1;A2 | no | mis-tagged destination: not a oneway | When I route I should get - | from | to | route | - | a | b | AB (E1),AB (E1) | - | c | d | CD (Berlin),CD (Berlin) | - | e | f | EF (A1: Berlin),EF (A1: Berlin) | - | g | h | , | - | i | j | , | - | k | l | KL (E1),KL (E1) | - | m | n | MN (A1, A2: Berlin, Hamburg),MN (A1, A2: Berlin, Hamburg) | + | from | to | route | # | + | a | b | AB (E1),AB (E1) | | + | c | d | CD (Berlin),CD (Berlin) | | + | e | f | EF (A1: Berlin),EF (A1: Berlin) | | + | g | h | , | | + | i | j | , | | + | k | l | KL (E1),KL (E1) | | + | m | n | MN (A1, A2: Berlin, Hamburg),MN (A1, A2: Berlin, Hamburg) | | + | o | p | OP,OP | guard against mis-tagging | diff --git a/profiles/car.lua b/profiles/car.lua index 905cdb576..ea50b86cc 100644 --- a/profiles/car.lua +++ b/profiles/car.lua @@ -353,19 +353,15 @@ function way_function (way, result) -- local barrier = way:get_value_by_key("barrier", "") -- local cycleway = way:get_value_by_key("cycleway", "") local service = way:get_value_by_key("service") - local destination = get_destination(way) -- Set the name that will be used for instructions local has_ref = ref and "" ~= ref local has_name = name and "" ~= name - local has_destination = destination and "" ~= destination if has_name and has_ref then result.name = name .. " (" .. ref .. ")" elseif has_ref then result.name = ref - elseif has_name and has_destination then - result.name = name .. " (" .. destination .. ")" elseif has_name then result.name = name -- else @@ -397,6 +393,14 @@ function way_function (way, result) (highway == "motorway_link" and oneway ~="no") or (highway == "motorway" and oneway ~= "no") then 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 + + if has_destination and has_name and not has_ref then + result.name = name .. " (" .. destination .. ")" + end end end