Basic destination sign handling.

This first part in our Exit Sign / Destination Sign quest re-wires
the `destination=` and `destination:ref=` tag to the `ref=` tag (in case
it's the highway does not already have a `ref=` tag).

Doing some analysis on both Berlin and San Francisco it looks like this
will add a couple of thousand `ref=` tags that we will announce in guidance.

References:
- https://github.com/Project-OSRM/osrm-backend/issues/2267#issuecomment-214771682
- http://wiki.openstreetmap.org/wiki/Key:destination
- http://wiki.openstreetmap.org/wiki/Proposed_features/Destination_details
This commit is contained in:
Daniel J. Hofmann 2016-04-27 13:24:25 +02:00 committed by Patrick Niklaus
parent 1bb88b374e
commit 4cf94319df
No known key found for this signature in database
GPG Key ID: E426891B5F978B1B
4 changed files with 75 additions and 0 deletions

View File

@ -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) |

View File

@ -1,6 +1,7 @@
-- Car profile -- Car profile
local find_access_tag = require("lib/access").find_access_tag local find_access_tag = require("lib/access").find_access_tag
local get_destination = require("lib/destination").get_destination
-- Begin of globals -- 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 } 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 barrier = way:get_value_by_key("barrier", "")
-- local cycleway = way:get_value_by_key("cycleway", "") -- local cycleway = way:get_value_by_key("cycleway", "")
local service = way:get_value_by_key("service") local service = way:get_value_by_key("service")
local destination = get_destination(way)
-- Set the name that will be used for instructions -- Set the name that will be used for instructions
local has_ref = ref and "" ~= ref local has_ref = ref and "" ~= ref
local has_name = name and "" ~= name local has_name = name and "" ~= name
local has_destination = destination and "" ~= destination
if has_name and has_ref then if has_name and has_ref then
result.name = name .. " (" .. ref .. ")" result.name = name .. " (" .. ref .. ")"
elseif has_ref then elseif has_ref then
result.name = ref result.name = ref
elseif has_name and has_destination then
result.name = name .. " (" .. destination .. ")"
elseif has_name then elseif has_name then
result.name = name result.name = name
-- else -- else

View File

@ -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

View File

@ -204,6 +204,16 @@
"object_types": [ "way" ], "object_types": [ "way" ],
"description": "Ref of road for navigation instructions, overrides name." "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", "key": "junction",
"object_types": [ "way" ], "object_types": [ "way" ],