Some improvements in code
This commit is contained in:
parent
3634aa9a3c
commit
3fd961a551
@ -403,20 +403,16 @@ function process_way(profile, way, result, relations)
|
|||||||
if result.ref then
|
if result.ref then
|
||||||
local match_res = Relations.match_to_ref(relations, result.ref)
|
local match_res = Relations.match_to_ref(relations, result.ref)
|
||||||
|
|
||||||
order = match_res['order']
|
|
||||||
matched_refs = match_res['match']
|
|
||||||
|
|
||||||
local ref = ''
|
local ref = ''
|
||||||
for _, k in pairs(order) do
|
for _, m in pairs(match_res) do
|
||||||
local v = matched_refs[k]
|
|
||||||
if ref ~= '' then
|
if ref ~= '' then
|
||||||
ref = ref .. '; '
|
ref = ref .. '; '
|
||||||
end
|
end
|
||||||
|
|
||||||
if v then
|
if m.dir then
|
||||||
ref = ref .. k .. ' $' .. v
|
ref = ref .. m.ref .. ' $' .. m.dir
|
||||||
else
|
else
|
||||||
ref = ref .. k
|
ref = ref .. m.ref
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -431,35 +427,35 @@ function process_relation(profile, relation, result)
|
|||||||
function add_extra_data(m)
|
function add_extra_data(m)
|
||||||
local name = relation:get_value_by_key("name")
|
local name = relation:get_value_by_key("name")
|
||||||
if name then
|
if name then
|
||||||
result[m]["route_name"] = name
|
result[m]['route_name'] = name
|
||||||
end
|
end
|
||||||
|
|
||||||
local ref = relation:get_value_by_key("ref")
|
local ref = relation:get_value_by_key("ref")
|
||||||
if ref then
|
if ref then
|
||||||
result[m]["route_ref"] = ref
|
result[m]['route_ref'] = ref
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if t == "route" then
|
if t == 'route' then
|
||||||
local route = relation:get_value_by_key("route")
|
local route = relation:get_value_by_key("route")
|
||||||
if route == "road" then
|
if route == 'road' then
|
||||||
for _, m in ipairs(relation:members()) do
|
for _, m in ipairs(relation:members()) do
|
||||||
-- process case, where directions set as role
|
-- process case, where directions set as role
|
||||||
local role = string.lower(m:role())
|
local role = string.lower(m:role())
|
||||||
if role == "north" or role == "south" or role == "west" or role == "east" then
|
if role == 'north' or role == 'south' or role == 'west' or role == 'east' then
|
||||||
result[m]["route_direction"] = role
|
result[m]['route_direction'] = role
|
||||||
add_extra_data(m)
|
add_extra_data(m)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local direction = relation:get_value_by_key("direction")
|
local direction = relation:get_value_by_key('direction')
|
||||||
if direction then
|
if direction then
|
||||||
direction = string.lower(direction)
|
direction = string.lower(direction)
|
||||||
if direction == "north" or direction == "south" or direction == "west" or direction == "east" then
|
if direction == 'north' or direction == 'south' or direction == 'west' or direction == 'east' then
|
||||||
for _, m in ipairs(relation:members()) do
|
for _, m in ipairs(relation:members()) do
|
||||||
if m:role() == "forward" then
|
if m:role() == 'forward' then
|
||||||
result[m]["route_direction"] = direction
|
result[m]['route_direction'] = direction
|
||||||
add_extra_data(m)
|
add_extra_data(m)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -7,18 +7,6 @@ Utils = require('lib/utils')
|
|||||||
|
|
||||||
Relations = {}
|
Relations = {}
|
||||||
|
|
||||||
function Relations.Merge(relations)
|
|
||||||
local result = {}
|
|
||||||
|
|
||||||
for _, r in ipairs(relations) do
|
|
||||||
for k, v in pairs(r) do
|
|
||||||
result[k] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
-- match ref values to relations data
|
-- match ref values to relations data
|
||||||
function Relations.match_to_ref(relations, ref)
|
function Relations.match_to_ref(relations, ref)
|
||||||
|
|
||||||
@ -96,8 +84,9 @@ function Relations.match_to_ref(relations, ref)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local result = {}
|
local result = {}
|
||||||
result['order'] = order
|
for i, r in ipairs(order) do
|
||||||
result['match'] = result_match
|
result[i] = { ref = r, dir = result_match[r] };
|
||||||
|
end
|
||||||
|
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user