Support route relation tests

This commit is contained in:
Denis Koronchik 2017-10-05 15:29:06 +03:00 committed by Patrick Niklaus
parent 4b8daac104
commit f9c7e1e55e
3 changed files with 38 additions and 22 deletions

View File

@ -133,7 +133,7 @@ Feature: Car - route relations
And the relations
| type | direction | relation | route | ref | network | name |
| route | east | baserelation | road | 80 | US:I | superrelation |
| route | west | baserelation | road | 80 | US:I | superrelation |
When I route I should get
| waypoints | route | ref |

View File

@ -427,6 +427,8 @@ function process_way(profile, way, result, relations)
end
end
-- print(result.name, ref)
result.ref = ref
end
end

View File

@ -103,6 +103,7 @@ function get_direction_from_superrel(rel, relations)
function set_result(direction, current_rel)
if (result ~= nil) and (direction ~= nil) then
print('WARNING: relation ' .. rel:id() .. ' is a part of more then one supperrelations ' .. result_id .. ' and ' .. current_rel:id())
result = nil
else
result = direction
result_id = current_rel:id()
@ -147,41 +148,54 @@ function Relations.parse_route_relation(rel, way, relations)
end
if t == 'route' then
local role_direction = nil
local route = rel:get_value_by_key("route")
if route == 'road' then
-- process case, where directions set as role
if is_direction(role) then
result['route_direction'] = role
add_extra_data(m)
role_direction = role
end
end
local tag_direction = nil
local direction = rel:get_value_by_key('direction')
if direction then
direction = string.lower(direction)
if is_direction(direction) then
if role == 'forward' then
result['route_direction'] = direction
add_extra_data(m)
tag_direction = direction
end
end
-- determine direction
local result_direction = role_direction
if result_direction == nil and tag_direction ~= '' then
result_direction = tag_direction
end
if role_direction ~= nil and tag_direction ~= nil and role_direction ~= tag_direction then
result_direction = nil
print('WARNING: conflict direction in role of way ' .. way:id() .. ' and direction tag in relation ' .. rel:id())
end
-- process superrelations
local super_dir = get_direction_from_superrel(rel, relations)
-- check if there are data error
local dir = result['route_direction']
if (dir ~= nil) and (super_dir ~= nil) and (dir ~= super_dir) then
if (result_direction ~= nil) and (super_dir ~= nil) and (result_direction ~= super_dir) then
print('ERROR: conflicting relation directions found for way ' .. way:id() ..
' relation direction is ' .. dir .. ' superrelation direction is ' .. super_dir)
' relation direction is ' .. result_direction .. ' superrelation direction is ' .. super_dir)
result_direction = nil
elseif result_direction == nil then
result_direction = super_dir
end
if (dir == nil) and (super_dir ~= nil) then
result['route_direction'] = super_dir
result['route_direction'] = result_direction
add_extra_data(m)
end
return result
end