Restore route relations support
This commit is contained in:
parent
c42e247d87
commit
a2b8698bca
@ -316,6 +316,48 @@ function process_node(profile, node, result, relations)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function parse_relation(relation, obj)
|
||||||
|
local t = relation:get_value_by_key("type")
|
||||||
|
local role = relation:get_role(obj)
|
||||||
|
local result = {}
|
||||||
|
|
||||||
|
function add_extra_data(m)
|
||||||
|
local name = relation:get_value_by_key("name")
|
||||||
|
if name then
|
||||||
|
result['route_name'] = name
|
||||||
|
end
|
||||||
|
|
||||||
|
local ref = relation:get_value_by_key("ref")
|
||||||
|
if ref then
|
||||||
|
result['route_ref'] = ref
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if t == 'route' then
|
||||||
|
local route = relation:get_value_by_key("route")
|
||||||
|
if route == 'road' then
|
||||||
|
-- process case, where directions set as role
|
||||||
|
if role == 'north' or role == 'south' or role == 'west' or role == 'east' then
|
||||||
|
result['route_direction'] = role
|
||||||
|
add_extra_data(m)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local direction = relation:get_value_by_key('direction')
|
||||||
|
if direction then
|
||||||
|
direction = string.lower(direction)
|
||||||
|
if direction == 'north' or direction == 'south' or direction == 'west' or direction == 'east' then
|
||||||
|
if role == 'forward' then
|
||||||
|
result['route_direction'] = direction
|
||||||
|
add_extra_data(m)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
function process_way(profile, way, result, relations)
|
function process_way(profile, way, result, relations)
|
||||||
-- the intial filtering of ways based on presence of tags
|
-- the intial filtering of ways based on presence of tags
|
||||||
-- affects processing times significantly, because all ways
|
-- affects processing times significantly, because all ways
|
||||||
@ -402,10 +444,17 @@ function process_way(profile, way, result, relations)
|
|||||||
|
|
||||||
WayHandlers.run(profile, way, result, data, handlers, relations)
|
WayHandlers.run(profile, way, result, data, handlers, relations)
|
||||||
|
|
||||||
|
local parsed_rel_list = {}
|
||||||
|
local rel_id_list = relations:get_relations(way)
|
||||||
|
for i, r in ipairs(rel_id_list) do
|
||||||
|
local rel_id = relations:relation(r)
|
||||||
|
parsed_rel_list[i] = parse_relation(rel_id, way)
|
||||||
|
end
|
||||||
|
|
||||||
-- now process relations data
|
-- now process relations data
|
||||||
local matched_refs = nil;
|
local matched_refs = nil;
|
||||||
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(parsed_rel_list, result.ref)
|
||||||
|
|
||||||
local ref = ''
|
local ref = ''
|
||||||
for _, m in pairs(match_res) do
|
for _, m in pairs(match_res) do
|
||||||
@ -422,53 +471,6 @@ function process_way(profile, way, result, relations)
|
|||||||
|
|
||||||
result.ref = ref
|
result.ref = ref
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function process_relation(profile, relation, result)
|
|
||||||
local t = relation:get_value_by_key("type")
|
|
||||||
|
|
||||||
function add_extra_data(m)
|
|
||||||
local name = relation:get_value_by_key("name")
|
|
||||||
if name then
|
|
||||||
result[m]['route_name'] = name
|
|
||||||
end
|
|
||||||
|
|
||||||
local ref = relation:get_value_by_key("ref")
|
|
||||||
if ref then
|
|
||||||
result[m]['route_ref'] = ref
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if t == 'route' then
|
|
||||||
local route = relation:get_value_by_key("route")
|
|
||||||
if route == 'road' then
|
|
||||||
for _, m in ipairs(relation:members()) do
|
|
||||||
-- process case, where directions set as role
|
|
||||||
local role = string.lower(m:role())
|
|
||||||
if role == 'north' or role == 'south' or role == 'west' or role == 'east' then
|
|
||||||
result[m]['route_direction'] = role
|
|
||||||
add_extra_data(m)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local direction = relation:get_value_by_key('direction')
|
|
||||||
if direction then
|
|
||||||
direction = string.lower(direction)
|
|
||||||
if direction == 'north' or direction == 'south' or direction == 'west' or direction == 'east' then
|
|
||||||
for _, m in ipairs(relation:members()) do
|
|
||||||
if m:role() == 'forward' then
|
|
||||||
result[m]['route_direction'] = direction
|
|
||||||
add_extra_data(m)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function process_turn(profile, turn)
|
function process_turn(profile, turn)
|
||||||
|
Loading…
Reference in New Issue
Block a user