diff --git a/features/guidance/destination-signs.feature b/features/guidance/destination-signs.feature new file mode 100644 index 000000000..a0eaac014 --- /dev/null +++ b/features/guidance/destination-signs.feature @@ -0,0 +1,33 @@ +@routing @guidance +Feature: Destination Signs + + Background: + Given the profile "car" + + Scenario: Car - route name assembly with destination signs + Given the node map + | a | b | + | c | d | + | e | f | + | g | h | + | i | j | + | k | l | + | m | n | + + 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 | + + 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) | diff --git a/profiles/car.lua b/profiles/car.lua index c2ca53efc..905cdb576 100644 --- a/profiles/car.lua +++ b/profiles/car.lua @@ -1,6 +1,7 @@ -- Car profile local find_access_tag = require("lib/access").find_access_tag +local get_destination = require("lib/destination").get_destination -- Begin of globals barrier_whitelist = { ["cattle_grid"] = true, ["border_control"] = true, ["checkpoint"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = true, ["lift_gate"] = true, ["no"] = true, ["entrance"] = true } @@ -352,15 +353,19 @@ 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 diff --git a/profiles/lib/destination.lua b/profiles/lib/destination.lua new file mode 100644 index 000000000..d89b1a926 --- /dev/null +++ b/profiles/lib/destination.lua @@ -0,0 +1,27 @@ +local Destination = {} + +function Destination.get_destination(way) + local destination = way:get_value_by_key("destination") + local destination_ref = way:get_value_by_key("destination:ref") + + -- Assemble destination as: "A59: Düsseldorf, Köln" + -- destination:ref ^ ^ destination + + local rv = "" + + if destination_ref and destination_ref ~= "" then + rv = rv .. destination_ref + end + + if destination and destination ~= "" then + if rv ~= "" then + rv = rv .. ": " + end + + rv = rv .. string.gsub(destination, ";", ", ") + end + + return rv +end + +return Destination diff --git a/taginfo.json b/taginfo.json index 8acc7d764..574b1dc9a 100644 --- a/taginfo.json +++ b/taginfo.json @@ -204,6 +204,16 @@ "object_types": [ "way" ], "description": "Ref of road for navigation instructions, overrides name." }, + { + "key": "destination", + "object_types": [ "way" ], + "description": "Destination of road for navigation instructions, supplements name." + }, + { + "key": "destination:ref", + "object_types": [ "way" ], + "description": "Destination of road for navigation instructions, supplements name." + }, { "key": "junction", "object_types": [ "way" ],