Support route relation tests
This commit is contained in:
parent
4b8daac104
commit
f9c7e1e55e
@ -22,8 +22,8 @@ Feature: Car - route relations
|
|||||||
|
|
||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| waypoints | route | ref |
|
| waypoints | route | ref |
|
||||||
| b,a | westbound,westbound | I 80 $west,I 80 $west |
|
| b,a | westbound,westbound | I 80 $west,I 80 $west |
|
||||||
| c,d | eastbound,eastbound | I 80 $east; CO 93 $east,I 80 $east; CO 93 $east |
|
| c,d | eastbound,eastbound | I 80 $east; CO 93 $east,I 80 $east; CO 93 $east |
|
||||||
|
|
||||||
Scenario: Assignment using relation direction property (no role on members)
|
Scenario: Assignment using relation direction property (no role on members)
|
||||||
@ -133,7 +133,7 @@ Feature: Car - route relations
|
|||||||
|
|
||||||
And the relations
|
And the relations
|
||||||
| type | direction | relation | route | ref | network | name |
|
| 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
|
When I route I should get
|
||||||
| waypoints | route | ref |
|
| waypoints | route | ref |
|
||||||
|
@ -427,6 +427,8 @@ function process_way(profile, way, result, relations)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- print(result.name, ref)
|
||||||
|
|
||||||
result.ref = ref
|
result.ref = ref
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -103,6 +103,7 @@ function get_direction_from_superrel(rel, relations)
|
|||||||
function set_result(direction, current_rel)
|
function set_result(direction, current_rel)
|
||||||
if (result ~= nil) and (direction ~= nil) then
|
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())
|
print('WARNING: relation ' .. rel:id() .. ' is a part of more then one supperrelations ' .. result_id .. ' and ' .. current_rel:id())
|
||||||
|
result = nil
|
||||||
else
|
else
|
||||||
result = direction
|
result = direction
|
||||||
result_id = current_rel:id()
|
result_id = current_rel:id()
|
||||||
@ -147,40 +148,53 @@ function Relations.parse_route_relation(rel, way, relations)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if t == 'route' then
|
if t == 'route' then
|
||||||
|
local role_direction = nil
|
||||||
local route = rel:get_value_by_key("route")
|
local route = rel:get_value_by_key("route")
|
||||||
if route == 'road' then
|
if route == 'road' then
|
||||||
-- process case, where directions set as role
|
-- process case, where directions set as role
|
||||||
if is_direction(role) then
|
if is_direction(role) then
|
||||||
result['route_direction'] = role
|
role_direction = role
|
||||||
add_extra_data(m)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local tag_direction = nil
|
||||||
local direction = rel:get_value_by_key('direction')
|
local direction = rel:get_value_by_key('direction')
|
||||||
if direction then
|
if direction then
|
||||||
direction = string.lower(direction)
|
direction = string.lower(direction)
|
||||||
if is_direction(direction) then
|
if is_direction(direction) then
|
||||||
if role == 'forward' then
|
tag_direction = direction
|
||||||
result['route_direction'] = direction
|
|
||||||
add_extra_data(m)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
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
|
||||||
|
|
||||||
|
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 ' .. result_direction .. ' superrelation direction is ' .. super_dir)
|
||||||
|
result_direction = nil
|
||||||
|
elseif result_direction == nil then
|
||||||
|
result_direction = super_dir
|
||||||
|
end
|
||||||
|
|
||||||
|
result['route_direction'] = result_direction
|
||||||
|
add_extra_data(m)
|
||||||
end
|
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
|
|
||||||
print('ERROR: conflicting relation directions found for way ' .. way:id() ..
|
|
||||||
' relation direction is ' .. dir .. ' superrelation direction is ' .. super_dir)
|
|
||||||
end
|
|
||||||
|
|
||||||
if (dir == nil) and (super_dir ~= nil) then
|
|
||||||
result['route_direction'] = super_dir
|
|
||||||
end
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user