diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d8ee3ae3..26b47ca76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 5.5.1 + - Changes from 5.5.0 + - Profiles: + - Handle `destination:forward`, `destination:backward`, `destination:ref:forward`, `destination:ref:backward` tags + - Properly handle destinations on `oneway=-1` roads + # 5.5.0 - Changes from 5.4.0 - API: diff --git a/features/guidance/directional-destination-signs.feature b/features/guidance/directional-destination-signs.feature new file mode 100644 index 000000000..8376dfae1 --- /dev/null +++ b/features/guidance/directional-destination-signs.feature @@ -0,0 +1,43 @@ +@routing @guidance +Feature: Destination Signs + + Background: + Given the profile "car" + + Scenario: Car - route name assembly with destination signs accounting for directional tags + Given the node map + """ + a b + c d + e f + g h + i j + k l + m n + o p + q r + """ + + And the ways + | nodes | name | ref | destination | destination:ref | destination:forward | destination:backward | oneway | # | + | ab | AB | | Berlin | | | | yes | | + | cd | CD | | | | Berlin | | yes | | + | ef | EF | | | | Berlin | Hamburg | -1 | | + | gh | GH | | | A1 | | | yes | | + | ij | IJ | | Berlin | A1 | | | no | mis-tagged destination: not a oneway | + | kl | KL | | | A1 | Berlin | Hamburg | yes | | + | mn | MN | | Berlin | A1 | Berlin | Hamburg | yes | | + | op | OP | | Berlin | | | Hamburg | -1 | | + | qr | QR | | | | | Hamburg | -1 | | + + When I route I should get + | from | to | route | destinations | ref | # | + | a | b | AB,AB | Berlin,Berlin | , | | + | c | d | CD,CD | Berlin,Berlin | , | | + | f | e | EF,EF | Hamburg,Hamburg | , | | + | g | h | GH,GH | A1,A1 | , | | + | i | j | IJ,IJ | , | , | guard against mis-tagging | + | k | l | KL,KL | A1: Berlin,A1: Berlin | , | | + | m | n | MN,MN | A1: Berlin,A1: Berlin | , | | + | p | o | OP,OP | Hamburg,Hamburg | , | | + | r | q | QR,QR | Hamburg,Hamburg | , | | diff --git a/features/guidance/directional-ref-destination-signs.feature b/features/guidance/directional-ref-destination-signs.feature new file mode 100644 index 000000000..1cdee7a65 --- /dev/null +++ b/features/guidance/directional-ref-destination-signs.feature @@ -0,0 +1,39 @@ +@routing @guidance +Feature: Destination Signs + + Background: + Given the profile "car" + + Scenario: Car - route name assembly with destination signs accounting for directional:ref tags + Given the node map + """ + a b + c d + e f + g h + i j + k l + m n + o p + q r + """ + + And the ways + | nodes | name | destination | destination:ref | destination:ref:forward | destination:ref:backward | destination:forward | destination:backward | oneway | # | + | ab | AB | Berlin | A1 | A1 | A2 | | | yes | | + | cd | CD | | A1 | A1 | A2 | Berlin | Hamburg | -1 | | + | ef | EF | | | A1 | A2 | Berlin | Hamburg | yes | | + | gh | GH | | | A1 | A2 | Berlin | Hamburg | -1 | | + | ij | IJ | Berlin | A1 | | A2 | Berlin | Hamburg | yes | | + | kl | KL | | A1 | | A2 | Berlin | Hamburg | -1 | | + | mn | MN | Berlin | A1 | A1 | | Berlin | Hamburg | no | mis-tagged destination: not a oneway | + + When I route I should get + | from | to | route | destinations | ref | # | + | a | b | AB,AB | A1: Berlin,A1: Berlin | , | | + | d | c | CD,CD | A2: Hamburg,A2: Hamburg | , | | + | e | f | EF,EF | A1: Berlin,A1: Berlin | , | | + | h | g | GH,GH | A2: Hamburg,A2: Hamburg | , | | + | i | j | IJ,IJ | A1: Berlin,A1: Berlin | , | | + | l | k | KL,KL | A2: Hamburg,A2: Hamburg | , | | + | m | n | MN,MN | , | , | guard against mis-tagging | \ No newline at end of file diff --git a/profiles/car.lua b/profiles/car.lua index f51b51396..68c512cb4 100644 --- a/profiles/car.lua +++ b/profiles/car.lua @@ -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 diff --git a/profiles/lib/destination.lua b/profiles/lib/destination.lua index fcdd677ea..93c09b460 100644 --- a/profiles/lib/destination.lua +++ b/profiles/lib/destination.lua @@ -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 \ No newline at end of file diff --git a/taginfo.json b/taginfo.json index 8b6014025..2513279e6 100644 --- a/taginfo.json +++ b/taginfo.json @@ -318,11 +318,31 @@ "object_types": [ "way" ], "description": "Destination of road for navigation instructions, supplements name." }, + { + "key": "destination:forward", + "object_types": [ "way" ], + "description": "Destination and direction of road for oneways for navigation instructions, supplements name." + }, + { + "key": "destination:backward", + "object_types": [ "way" ], + "description": "Destination and direction of road for oneways for navigation instructions, supplements name." + }, { "key": "destination:ref", "object_types": [ "way" ], "description": "Destination of road for navigation instructions, supplements name." }, + { + "key": "destination:ref:forward", + "object_types": [ "way" ], + "description": "Destination and direction of road for oneways for navigation instructions, supplements name." + }, + { + "key": "destination:ref:backward", + "object_types": [ "way" ], + "description": "Destination and direction of road for oneways for navigation instructions, supplements name." + }, { "key": "junction", "object_types": [ "way" ],