commit
						b353df83ee
					
				
							
								
								
									
										99
									
								
								features/bearing.feature
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								features/bearing.feature
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,99 @@
 | 
			
		||||
@routing @bearing
 | 
			
		||||
Feature: Compass bearing
 | 
			
		||||
	
 | 
			
		||||
	@northwest
 | 
			
		||||
	Scenario: Bearing when going northwest
 | 
			
		||||
		Given the node map
 | 
			
		||||
		 | b |   |
 | 
			
		||||
		 |   | a |
 | 
			
		||||
 | 
			
		||||
		And the ways
 | 
			
		||||
		 | nodes |
 | 
			
		||||
		 | ab    |
 | 
			
		||||
 | 
			
		||||
		When I route I should get
 | 
			
		||||
		 | from | to | route | compass | bearing |
 | 
			
		||||
		 | a    | b  | ab    | NW      | 45      |
 | 
			
		||||
 | 
			
		||||
	@west
 | 
			
		||||
	Scenario: Bearing when going west
 | 
			
		||||
		Given the node map
 | 
			
		||||
		 | b | a |
 | 
			
		||||
 | 
			
		||||
		And the ways
 | 
			
		||||
		 | nodes |
 | 
			
		||||
		 | ab    |
 | 
			
		||||
 | 
			
		||||
		When I route I should get
 | 
			
		||||
		 | from | to | route | compass | bearing |
 | 
			
		||||
		 | a    | b  | ab    | W       | 90      |
 | 
			
		||||
 | 
			
		||||
	Scenario: Bearing af 45 degree intervals
 | 
			
		||||
		Given the node map
 | 
			
		||||
		 | b | a | h |
 | 
			
		||||
		 | c | x | g |
 | 
			
		||||
		 | d | e | f |
 | 
			
		||||
 | 
			
		||||
		And the ways
 | 
			
		||||
		 | nodes |
 | 
			
		||||
		 | xa    |
 | 
			
		||||
		 | xb    |
 | 
			
		||||
		 | xc    |
 | 
			
		||||
		 | xd    |
 | 
			
		||||
		 | xe    |
 | 
			
		||||
		 | xf    |
 | 
			
		||||
		 | xg    |
 | 
			
		||||
		 | xh    |
 | 
			
		||||
 | 
			
		||||
		When I route I should get
 | 
			
		||||
		 | from | to | route | compass | bearing |
 | 
			
		||||
		 | x    | a  | xa    | N       | 0       |
 | 
			
		||||
		 | x    | b  | xb    | NW      | 45      |
 | 
			
		||||
		 | x    | c  | xc    | W       | 90      |
 | 
			
		||||
		 | x    | d  | xd    | SW      | 135     |
 | 
			
		||||
		 | x    | e  | xe    | S       | 180     |
 | 
			
		||||
		 | x    | f  | xf    | SE      | 225     |
 | 
			
		||||
		 | x    | g  | xg    | E       | 270     |
 | 
			
		||||
		 | x    | h  | xh    | NE      | 315     |
 | 
			
		||||
 | 
			
		||||
	Scenario: Bearing in a roundabout
 | 
			
		||||
		Given the node map
 | 
			
		||||
		 |   | d | c |   |
 | 
			
		||||
		 | e |   |   | b |
 | 
			
		||||
		 | f |   |   | a |
 | 
			
		||||
		 |   | g | h |   |
 | 
			
		||||
 | 
			
		||||
		And the ways
 | 
			
		||||
		 | nodes | oneway |
 | 
			
		||||
		 | ab    | yes    |
 | 
			
		||||
		 | bc    | yes    |
 | 
			
		||||
		 | cd    | yes    |
 | 
			
		||||
		 | de    | yes    |
 | 
			
		||||
		 | ef    | yes    |
 | 
			
		||||
		 | fg    | yes    |
 | 
			
		||||
		 | gh    | yes    |
 | 
			
		||||
		 | ha    | yes    |
 | 
			
		||||
 | 
			
		||||
		When I route I should get
 | 
			
		||||
		 | from | to | route                | compass          | bearing                 |
 | 
			
		||||
		 | c    | b  | cd,de,ef,fg,gh,ha,ab | W,SW,S,SE,E,NE,N | 90,135,180,225,270,0,45 |
 | 
			
		||||
		 | g    | f  | gh,ha,ab,bc,cd,de,ef | E,NE,N,NW,W,SW,S | 270,315,0,45,90,180,225 |
 | 
			
		||||
 | 
			
		||||
	Scenario: Bearing should stay constant when zig-zagging
 | 
			
		||||
		Given the node map
 | 
			
		||||
		 | b | d | f | h |
 | 
			
		||||
		 | a | c | e | g |
 | 
			
		||||
 | 
			
		||||
		And the ways
 | 
			
		||||
		 | nodes |
 | 
			
		||||
		 | ab    |
 | 
			
		||||
		 | bc    |
 | 
			
		||||
		 | cd    |
 | 
			
		||||
		 | de    |
 | 
			
		||||
		 | ef    |
 | 
			
		||||
		 | fg    |
 | 
			
		||||
		 | gh    |
 | 
			
		||||
 | 
			
		||||
		When I route I should get
 | 
			
		||||
		 | from | to | route                | compass          | bearing             |
 | 
			
		||||
		 | a    | h  | ab,bc,cd,de,ef,fg,gh | N,SE,N,SE,N,SE,N | 0,225,0,225,0,225,0 |
 | 
			
		||||
@ -202,6 +202,8 @@ When /^I route I should get$/ do |table|
 | 
			
		||||
        json = JSON.parse response.body
 | 
			
		||||
        if json['status'] == 0
 | 
			
		||||
          instructions = way_list json['route_instructions']
 | 
			
		||||
          bearings = bearing_list json['route_instructions']
 | 
			
		||||
          compasses = compass_list json['route_instructions']
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
@ -221,6 +223,12 @@ When /^I route I should get$/ do |table|
 | 
			
		||||
          raise "*** time must be specied in seconds. (ex: 60s)" unless row['time'] =~ /\d+s/
 | 
			
		||||
          got['time'] = instructions ? "#{json['route_summary']['total_time'].to_s}s" : nil
 | 
			
		||||
        end
 | 
			
		||||
        if table.headers.include? 'bearing'
 | 
			
		||||
          got['bearing'] = bearings
 | 
			
		||||
        end
 | 
			
		||||
        if table.headers.include? 'compass'
 | 
			
		||||
          got['compass'] = compasses
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
      if row != got
 | 
			
		||||
 | 
			
		||||
@ -69,3 +69,17 @@ def way_list instructions
 | 
			
		||||
  map { |r| r=="" ? '""' : r }.
 | 
			
		||||
  join(',')
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
def compass_list instructions
 | 
			
		||||
  instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
 | 
			
		||||
  map { |r| r[6] }.
 | 
			
		||||
  map { |r| r=="" ? '""' : r }.
 | 
			
		||||
  join(',')
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
def bearing_list instructions
 | 
			
		||||
  instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
 | 
			
		||||
  map { |r| r[7] }.
 | 
			
		||||
  map { |r| r=="" ? '""' : r }.
 | 
			
		||||
  join(',')
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										39
									
								
								features/weird.feature
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								features/weird.feature
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,39 @@
 | 
			
		||||
@routing @weird
 | 
			
		||||
Feature: Weird routings discovered
 | 
			
		||||
	
 | 
			
		||||
Scenario: Routing on a oneway roundabout
 | 
			
		||||
	Given the node map
 | 
			
		||||
	 |   | d | c |   |
 | 
			
		||||
	 | e |   |   | b |
 | 
			
		||||
	 | f |   |   | a |
 | 
			
		||||
	 |   | g | h |   |
 | 
			
		||||
 | 
			
		||||
	And the ways
 | 
			
		||||
	 | nodes | oneway |
 | 
			
		||||
	 | ab    | yes    |
 | 
			
		||||
	 | bc    | yes    |
 | 
			
		||||
	 | cd    | yes    |
 | 
			
		||||
	 | de    | yes    |
 | 
			
		||||
	 | ef    | yes    |
 | 
			
		||||
	 | fg    | yes    |
 | 
			
		||||
	 | gh    | yes    |
 | 
			
		||||
	 | ha    | yes    |
 | 
			
		||||
 | 
			
		||||
	When I route I should get
 | 
			
		||||
	 | from | to | route                |
 | 
			
		||||
	 | a    | b  | ab                   |
 | 
			
		||||
	 | b    | c  | bc                   |
 | 
			
		||||
	 | c    | d  | cd                   |
 | 
			
		||||
	 | d    | e  | de                   |
 | 
			
		||||
	 | e    | f  | ef                   |
 | 
			
		||||
	 | f    | g  | fg                   |
 | 
			
		||||
	 | g    | h  | gh                   |
 | 
			
		||||
	 | h    | a  | ha                   |
 | 
			
		||||
	 | b    | a  | bc,cd,de,ef,fg,gh,ha |
 | 
			
		||||
	 | c    | b  | cd,de,ef,fg,gh,ha,ab |
 | 
			
		||||
	 | d    | c  | de,ef,fg,gh,ha,ab,bc |
 | 
			
		||||
	 | e    | d  | ef,fg,gh,ha,ab,bc,cd |
 | 
			
		||||
	 | f    | e  | fg,gh,ha,ab,bc,cd,de |
 | 
			
		||||
	 | g    | f  | gh,ha,ab,bc,cd,de,ef |
 | 
			
		||||
	 | h    | g  | ha,ab,bc,cd,de,ef,fg |
 | 
			
		||||
	 | a    | h  | ab,bc,cd,de,ef,fg,gh |
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user