support testing of all relation types
This commit is contained in:
parent
9a865384a1
commit
f1d47328e9
@ -21,8 +21,8 @@ Feature: Bike - Turn restrictions
|
||||
| ej | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction |
|
||||
| sj | wj | j | no_left_turn |
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
| restriction | sj | wj | j | no_left_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -45,8 +45,8 @@ Feature: Bike - Turn restrictions
|
||||
| ej | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction |
|
||||
| sj | ej | j | no_right_turn |
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
| restriction | sj | ej | j | no_right_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -69,8 +69,8 @@ Feature: Bike - Turn restrictions
|
||||
| ej | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction |
|
||||
| sj | wj | j | no_u_turn |
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
| restriction | sj | wj | j | no_u_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -93,8 +93,8 @@ Feature: Bike - Turn restrictions
|
||||
| ej | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction |
|
||||
| sj | wj | j | no_weird_zigzags |
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
| restriction | sj | wj | j | no_weird_zigzags |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -117,8 +117,8 @@ Feature: Bike - Turn restrictions
|
||||
| ej | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction |
|
||||
| sj | wj | j | only_left_turn |
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
| restriction | sj | wj | j | only_left_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -141,8 +141,8 @@ Feature: Bike - Turn restrictions
|
||||
| ej | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction |
|
||||
| sj | ej | j | only_right_turn |
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
| restriction | sj | ej | j | only_right_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -165,8 +165,8 @@ Feature: Bike - Turn restrictions
|
||||
| ej | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction |
|
||||
| sj | nj | j | only_straight_on |
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
| restriction | sj | nj | j | only_straight_on |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -189,8 +189,8 @@ Feature: Bike - Turn restrictions
|
||||
| ej | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction |
|
||||
| sj | nj | j | only_weird_zigzags |
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
| restriction | sj | nj | j | only_weird_zigzags |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -215,11 +215,11 @@ Feature: Bike - Turn restrictions
|
||||
| dj | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction | except |
|
||||
| sj | aj | j | no_left_turn | bicycle |
|
||||
| sj | bj | j | no_left_turn | |
|
||||
| sj | cj | j | no_right_turn | bicycle |
|
||||
| sj | dj | j | no_right_turn | |
|
||||
| type | way:from | way:to | node:via | restriction | except |
|
||||
| restriction | sj | aj | j | no_left_turn | bicycle |
|
||||
| restriction | sj | bj | j | no_left_turn | |
|
||||
| restriction | sj | cj | j | no_right_turn | bicycle |
|
||||
| restriction | sj | dj | j | no_right_turn | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -242,8 +242,8 @@ Feature: Bike - Turn restrictions
|
||||
| bj | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction | except |
|
||||
| sj | aj | j | only_straight_on | bicycle |
|
||||
| type | way:from | way:to | node:via | restriction | except |
|
||||
| restriction | sj | aj | j | only_straight_on | bicycle |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
|
@ -21,8 +21,8 @@ Feature: Car - Turn restrictions
|
||||
| ej | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction |
|
||||
| sj | wj | j | no_left_turn |
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
| restriction | sj | wj | j | no_left_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -45,8 +45,8 @@ Feature: Car - Turn restrictions
|
||||
| ej | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction |
|
||||
| sj | ej | j | no_right_turn |
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
| restriction | sj | ej | j | no_right_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -69,8 +69,8 @@ Feature: Car - Turn restrictions
|
||||
| ej | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction |
|
||||
| sj | wj | j | no_u_turn |
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
| restriction | sj | wj | j | no_u_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -93,8 +93,8 @@ Feature: Car - Turn restrictions
|
||||
| ej | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction |
|
||||
| sj | wj | j | no_weird_zigzags |
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
| restriction | sj | wj | j | no_weird_zigzags |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -117,8 +117,8 @@ Feature: Car - Turn restrictions
|
||||
| ej | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction |
|
||||
| sj | wj | j | only_left_turn |
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
| restriction | sj | wj | j | only_left_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -141,8 +141,8 @@ Feature: Car - Turn restrictions
|
||||
| ej | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction |
|
||||
| sj | ej | j | only_right_turn |
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
| restriction | sj | ej | j | only_right_turn |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -165,8 +165,8 @@ Feature: Car - Turn restrictions
|
||||
| ej | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction |
|
||||
| sj | nj | j | only_straight_on |
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
| restriction | sj | nj | j | only_straight_on |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -189,8 +189,8 @@ Feature: Car - Turn restrictions
|
||||
| ej | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction |
|
||||
| sj | nj | j | only_weird_zigzags |
|
||||
| type | way:from | way:to | node:via | restriction |
|
||||
| restriction | sj | nj | j | only_weird_zigzags |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -215,11 +215,11 @@ Feature: Car - Turn restrictions
|
||||
| dj | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction | except |
|
||||
| sj | aj | j | no_left_turn | motorcar |
|
||||
| sj | bj | j | no_left_turn | |
|
||||
| sj | cj | j | no_right_turn | motorcar |
|
||||
| sj | dj | j | no_right_turn | |
|
||||
| type | way:from | way:to | node:via | restriction | except |
|
||||
| restriction | sj | aj | j | no_left_turn | motorcar |
|
||||
| restriction | sj | bj | j | no_left_turn | |
|
||||
| restriction | sj | cj | j | no_right_turn | motorcar |
|
||||
| restriction | sj | dj | j | no_right_turn | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
@ -242,8 +242,8 @@ Feature: Car - Turn restrictions
|
||||
| bj | -1 |
|
||||
|
||||
And the relations
|
||||
| from | to | via | restriction | except |
|
||||
| sj | aj | j | only_straight_on | motorcar |
|
||||
| type | way:from | way:to | node:via | restriction | except |
|
||||
| restriction | sj | aj | j | only_straight_on | motorcar |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
|
@ -88,20 +88,21 @@ end
|
||||
Given /^the relations$/ do |table|
|
||||
table.hashes.each do |row|
|
||||
relation = OSM::Relation.new make_osm_id, OSM_USER, OSM_TIMESTAMP
|
||||
relation << { :type => :restriction, :restriction => row['restriction'] }
|
||||
from_way = find_way_by_name(row['from'])
|
||||
raise "*** unknown way '#{row['from']}'" unless from_way
|
||||
to_way = find_way_by_name(row['to'])
|
||||
raise "*** unknown way '#{row['to']}'" unless to_way
|
||||
relation << OSM::Member.new( 'way', from_way.id, 'from' )
|
||||
relation << OSM::Member.new( 'way', to_way.id, 'to' )
|
||||
c = row['via']
|
||||
unless c.empty?
|
||||
raise "*** node invalid name '#{c}', must be single characters" unless c.size == 1
|
||||
raise "*** via node cannot use numbered nodes, '#{c}'" unless c.match /[a-z]/
|
||||
via_node = find_node_by_name(c)
|
||||
raise "*** unknown node '#{row['via']}'" unless via_node
|
||||
relation << OSM::Member.new( 'node', via_node.id, 'via' )
|
||||
row.each_pair do |key,value|
|
||||
if key =~ /^node:(.*)/
|
||||
raise "***invalid relation node member '#{value}', must be single character" unless value.size == 1
|
||||
node = find_node_by_name(value)
|
||||
raise "*** unknown relation node member '#{value}'" unless node
|
||||
relation << OSM::Member.new( 'node', node.id, $1 )
|
||||
elsif key =~ /^way:(.*)/
|
||||
way = find_way_by_name(value)
|
||||
raise "*** unknown relation way member '#{value}'" unless way
|
||||
relation << OSM::Member.new( 'way', way.id, $1 )
|
||||
elsif key =~ /^(.*):(.*)/
|
||||
raise "*** unknown relation member type '#{$1}', must be either 'node' or 'way'"
|
||||
else
|
||||
relation << { key => value }
|
||||
end
|
||||
end
|
||||
relation.uid = OSM_UID
|
||||
osm_db << relation
|
||||
|
Loading…
Reference in New Issue
Block a user