osrm-backend/profiles/lib/destination.lua

30 lines
861 B
Lua
Raw Permalink Normal View History

local Destination = {}
2016-11-16 18:26:39 -05:00
function Destination.get_directional_tag(way, is_forward, tag)
local v
if is_forward then
v = way:get_value_by_key(tag .. ':forward') or way:get_value_by_key(tag)
else
v = way:get_value_by_key(tag .. ':backward') or way:get_value_by_key(tag)
end
2016-11-16 18:26:39 -05:00
if v then
return v.gsub(v, ';', ', ')
end
end
2016-11-16 18:26:39 -05:00
-- Assemble destination as: "A59: Düsseldorf, Köln"
-- destination:ref ^ ^ destination
function Destination.get_destination(way, is_forward)
2016-11-16 18:33:44 -05:00
ref = Destination.get_directional_tag(way, is_forward, 'destination:ref')
dest = Destination.get_directional_tag(way, is_forward, 'destination')
street = Destination.get_directional_tag(way, is_forward, 'destination:street')
2016-11-16 18:33:44 -05:00
if ref and dest then
return ref .. ': ' .. dest
else
return ref or dest or street or ''
2016-11-16 18:33:44 -05:00
end
end
return Destination