support testing of all relation types

This commit is contained in:
Emil Tin 2012-11-30 13:40:21 +01:00
parent 9a865384a1
commit f1d47328e9
3 changed files with 104 additions and 103 deletions

View File

@ -21,8 +21,8 @@ Feature: Bike - Turn restrictions
| ej | -1 | | ej | -1 |
And the relations And the relations
| from | to | via | restriction | | type | way:from | way:to | node:via | restriction |
| sj | wj | j | no_left_turn | | restriction | sj | wj | j | no_left_turn |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -45,8 +45,8 @@ Feature: Bike - Turn restrictions
| ej | -1 | | ej | -1 |
And the relations And the relations
| from | to | via | restriction | | type | way:from | way:to | node:via | restriction |
| sj | ej | j | no_right_turn | | restriction | sj | ej | j | no_right_turn |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -69,8 +69,8 @@ Feature: Bike - Turn restrictions
| ej | -1 | | ej | -1 |
And the relations And the relations
| from | to | via | restriction | | type | way:from | way:to | node:via | restriction |
| sj | wj | j | no_u_turn | | restriction | sj | wj | j | no_u_turn |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -93,8 +93,8 @@ Feature: Bike - Turn restrictions
| ej | -1 | | ej | -1 |
And the relations And the relations
| from | to | via | restriction | | type | way:from | way:to | node:via | restriction |
| sj | wj | j | no_weird_zigzags | | restriction | sj | wj | j | no_weird_zigzags |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -117,8 +117,8 @@ Feature: Bike - Turn restrictions
| ej | -1 | | ej | -1 |
And the relations And the relations
| from | to | via | restriction | | type | way:from | way:to | node:via | restriction |
| sj | wj | j | only_left_turn | | restriction | sj | wj | j | only_left_turn |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -141,8 +141,8 @@ Feature: Bike - Turn restrictions
| ej | -1 | | ej | -1 |
And the relations And the relations
| from | to | via | restriction | | type | way:from | way:to | node:via | restriction |
| sj | ej | j | only_right_turn | | restriction | sj | ej | j | only_right_turn |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -165,8 +165,8 @@ Feature: Bike - Turn restrictions
| ej | -1 | | ej | -1 |
And the relations And the relations
| from | to | via | restriction | | type | way:from | way:to | node:via | restriction |
| sj | nj | j | only_straight_on | | restriction | sj | nj | j | only_straight_on |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -189,8 +189,8 @@ Feature: Bike - Turn restrictions
| ej | -1 | | ej | -1 |
And the relations And the relations
| from | to | via | restriction | | type | way:from | way:to | node:via | restriction |
| sj | nj | j | only_weird_zigzags | | restriction | sj | nj | j | only_weird_zigzags |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -215,11 +215,11 @@ Feature: Bike - Turn restrictions
| dj | -1 | | dj | -1 |
And the relations And the relations
| from | to | via | restriction | except | | type | way:from | way:to | node:via | restriction | except |
| sj | aj | j | no_left_turn | bicycle | | restriction | sj | aj | j | no_left_turn | bicycle |
| sj | bj | j | no_left_turn | | | restriction | sj | bj | j | no_left_turn | |
| sj | cj | j | no_right_turn | bicycle | | restriction | sj | cj | j | no_right_turn | bicycle |
| sj | dj | j | no_right_turn | | | restriction | sj | dj | j | no_right_turn | |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -242,8 +242,8 @@ Feature: Bike - Turn restrictions
| bj | -1 | | bj | -1 |
And the relations And the relations
| from | to | via | restriction | except | | type | way:from | way:to | node:via | restriction | except |
| sj | aj | j | only_straight_on | bicycle | | restriction | sj | aj | j | only_straight_on | bicycle |
When I route I should get When I route I should get
| from | to | route | | from | to | route |

View File

@ -21,8 +21,8 @@ Feature: Car - Turn restrictions
| ej | -1 | | ej | -1 |
And the relations And the relations
| from | to | via | restriction | | type | way:from | way:to | node:via | restriction |
| sj | wj | j | no_left_turn | | restriction | sj | wj | j | no_left_turn |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -45,8 +45,8 @@ Feature: Car - Turn restrictions
| ej | -1 | | ej | -1 |
And the relations And the relations
| from | to | via | restriction | | type | way:from | way:to | node:via | restriction |
| sj | ej | j | no_right_turn | | restriction | sj | ej | j | no_right_turn |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -69,8 +69,8 @@ Feature: Car - Turn restrictions
| ej | -1 | | ej | -1 |
And the relations And the relations
| from | to | via | restriction | | type | way:from | way:to | node:via | restriction |
| sj | wj | j | no_u_turn | | restriction | sj | wj | j | no_u_turn |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -93,8 +93,8 @@ Feature: Car - Turn restrictions
| ej | -1 | | ej | -1 |
And the relations And the relations
| from | to | via | restriction | | type | way:from | way:to | node:via | restriction |
| sj | wj | j | no_weird_zigzags | | restriction | sj | wj | j | no_weird_zigzags |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -117,8 +117,8 @@ Feature: Car - Turn restrictions
| ej | -1 | | ej | -1 |
And the relations And the relations
| from | to | via | restriction | | type | way:from | way:to | node:via | restriction |
| sj | wj | j | only_left_turn | | restriction | sj | wj | j | only_left_turn |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -141,8 +141,8 @@ Feature: Car - Turn restrictions
| ej | -1 | | ej | -1 |
And the relations And the relations
| from | to | via | restriction | | type | way:from | way:to | node:via | restriction |
| sj | ej | j | only_right_turn | | restriction | sj | ej | j | only_right_turn |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -165,8 +165,8 @@ Feature: Car - Turn restrictions
| ej | -1 | | ej | -1 |
And the relations And the relations
| from | to | via | restriction | | type | way:from | way:to | node:via | restriction |
| sj | nj | j | only_straight_on | | restriction | sj | nj | j | only_straight_on |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -189,8 +189,8 @@ Feature: Car - Turn restrictions
| ej | -1 | | ej | -1 |
And the relations And the relations
| from | to | via | restriction | | type | way:from | way:to | node:via | restriction |
| sj | nj | j | only_weird_zigzags | | restriction | sj | nj | j | only_weird_zigzags |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -215,11 +215,11 @@ Feature: Car - Turn restrictions
| dj | -1 | | dj | -1 |
And the relations And the relations
| from | to | via | restriction | except | | type | way:from | way:to | node:via | restriction | except |
| sj | aj | j | no_left_turn | motorcar | | restriction | sj | aj | j | no_left_turn | motorcar |
| sj | bj | j | no_left_turn | | | restriction | sj | bj | j | no_left_turn | |
| sj | cj | j | no_right_turn | motorcar | | restriction | sj | cj | j | no_right_turn | motorcar |
| sj | dj | j | no_right_turn | | | restriction | sj | dj | j | no_right_turn | |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
@ -242,8 +242,8 @@ Feature: Car - Turn restrictions
| bj | -1 | | bj | -1 |
And the relations And the relations
| from | to | via | restriction | except | | type | way:from | way:to | node:via | restriction | except |
| sj | aj | j | only_straight_on | motorcar | | restriction | sj | aj | j | only_straight_on | motorcar |
When I route I should get When I route I should get
| from | to | route | | from | to | route |

View File

@ -88,20 +88,21 @@ end
Given /^the relations$/ do |table| Given /^the relations$/ do |table|
table.hashes.each do |row| table.hashes.each do |row|
relation = OSM::Relation.new make_osm_id, OSM_USER, OSM_TIMESTAMP relation = OSM::Relation.new make_osm_id, OSM_USER, OSM_TIMESTAMP
relation << { :type => :restriction, :restriction => row['restriction'] } row.each_pair do |key,value|
from_way = find_way_by_name(row['from']) if key =~ /^node:(.*)/
raise "*** unknown way '#{row['from']}'" unless from_way raise "***invalid relation node member '#{value}', must be single character" unless value.size == 1
to_way = find_way_by_name(row['to']) node = find_node_by_name(value)
raise "*** unknown way '#{row['to']}'" unless to_way raise "*** unknown relation node member '#{value}'" unless node
relation << OSM::Member.new( 'way', from_way.id, 'from' ) relation << OSM::Member.new( 'node', node.id, $1 )
relation << OSM::Member.new( 'way', to_way.id, 'to' ) elsif key =~ /^way:(.*)/
c = row['via'] way = find_way_by_name(value)
unless c.empty? raise "*** unknown relation way member '#{value}'" unless way
raise "*** node invalid name '#{c}', must be single characters" unless c.size == 1 relation << OSM::Member.new( 'way', way.id, $1 )
raise "*** via node cannot use numbered nodes, '#{c}'" unless c.match /[a-z]/ elsif key =~ /^(.*):(.*)/
via_node = find_node_by_name(c) raise "*** unknown relation member type '#{$1}', must be either 'node' or 'way'"
raise "*** unknown node '#{row['via']}'" unless via_node else
relation << OSM::Member.new( 'node', via_node.id, 'via' ) relation << { key => value }
end
end end
relation.uid = OSM_UID relation.uid = OSM_UID
osm_db << relation osm_db << relation