support testing of turn directions
This commit is contained in:
parent
86a5bbac51
commit
e41d52570e
@ -204,6 +204,7 @@ When /^I route I should get$/ do |table|
|
||||
instructions = way_list json['route_instructions']
|
||||
bearings = bearing_list json['route_instructions']
|
||||
compasses = compass_list json['route_instructions']
|
||||
turns = turn_list json['route_instructions']
|
||||
end
|
||||
end
|
||||
|
||||
@ -232,6 +233,9 @@ When /^I route I should get$/ do |table|
|
||||
if table.headers.include? 'compass'
|
||||
got['compass'] = compasses
|
||||
end
|
||||
if table.headers.include? 'turns'
|
||||
got['turns'] = turns
|
||||
end
|
||||
end
|
||||
|
||||
ok = true
|
||||
|
@ -4,7 +4,7 @@ DESTINATION_REACHED = 15 #OSRM instruction code
|
||||
|
||||
|
||||
def request_route a,b
|
||||
@query = "http://localhost:5000/viaroute?loc=#{a}&loc=#{b}&output=json&instructions=true"
|
||||
@query = "http://localhost:5000/viaroute?loc=#{a}&loc=#{b}&output=json&instructions=true&alt=false"
|
||||
#log @query
|
||||
uri = URI.parse @query
|
||||
Net::HTTP.get_response uri
|
||||
@ -83,3 +83,27 @@ def bearing_list instructions
|
||||
map { |r| r=="" ? '""' : r }.
|
||||
join(',')
|
||||
end
|
||||
|
||||
def turn_list instructions
|
||||
types = {
|
||||
0 => :none,
|
||||
1 => :straight,
|
||||
2 => :slight_right,
|
||||
3 => :right,
|
||||
4 => :sharp_right,
|
||||
5 => :u_turn,
|
||||
6 => :sharp_left,
|
||||
7 => :left,
|
||||
8 => :slight_left,
|
||||
9 => :via,
|
||||
10 => :head,
|
||||
11 => :enter_roundabout,
|
||||
12 => :leave_roundabout,
|
||||
13 => :stay_roundabout,
|
||||
14 => :start_end_of_street,
|
||||
15 => :destination
|
||||
}
|
||||
instructions.
|
||||
map { |r| types[r[0].to_i].to_s }.
|
||||
join(',')
|
||||
end
|
||||
|
115
features/testbot/turns.feature
Normal file
115
features/testbot/turns.feature
Normal file
@ -0,0 +1,115 @@
|
||||
@routing @turns
|
||||
Feature: Turn directions/codes
|
||||
|
||||
Background:
|
||||
Given the speedprofile "testbot"
|
||||
|
||||
Scenario: Turn directions
|
||||
Given the node map
|
||||
| o | p | a | b | c |
|
||||
| n | | | | d |
|
||||
| m | | x | | e |
|
||||
| l | | | | f |
|
||||
| k | j | i | h | g |
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| xa |
|
||||
| xb |
|
||||
| xc |
|
||||
| xd |
|
||||
| xe |
|
||||
| xf |
|
||||
| xg |
|
||||
| xh |
|
||||
| xi |
|
||||
| xj |
|
||||
| xk |
|
||||
| xl |
|
||||
| xm |
|
||||
| xn |
|
||||
| xo |
|
||||
| xp |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | turns |
|
||||
| i | k | xi,xk | head,sharp_left,destination |
|
||||
| i | m | xi,xm | head,left,destination |
|
||||
| i | o | xi,xo | head,slight_left,destination |
|
||||
| i | a | xi,xa | head,straight,destination |
|
||||
| i | c | xi,xc | head,slight_right,destination |
|
||||
| i | e | xi,xe | head,right,destination |
|
||||
| i | g | xi,xg | head,sharp_right,destination |
|
||||
|
||||
| k | m | xk,xm | head,sharp_left,destination |
|
||||
| k | o | xk,xo | head,left,destination |
|
||||
| k | a | xk,xa | head,slight_left,destination |
|
||||
| k | c | xk,xc | head,straight,destination |
|
||||
| k | e | xk,xe | head,slight_right,destination |
|
||||
| k | g | xk,xg | head,right,destination |
|
||||
| k | i | xk,xi | head,sharp_right,destination |
|
||||
|
||||
| m | o | xm,xo | head,sharp_left,destination |
|
||||
| m | a | xm,xa | head,left,destination |
|
||||
| m | c | xm,xc | head,slight_left,destination |
|
||||
| m | e | xm,xe | head,straight,destination |
|
||||
| m | g | xm,xg | head,slight_right,destination |
|
||||
| m | i | xm,xi | head,right,destination |
|
||||
| m | k | xm,xk | head,sharp_right,destination |
|
||||
|
||||
| o | a | xo,xa | head,sharp_left,destination |
|
||||
| o | c | xo,xc | head,left,destination |
|
||||
| o | e | xo,xe | head,slight_left,destination |
|
||||
| o | g | xo,xg | head,straight,destination |
|
||||
| o | i | xo,xi | head,slight_right,destination |
|
||||
| o | k | xo,xk | head,right,destination |
|
||||
| o | m | xo,xm | head,sharp_right,destination |
|
||||
|
||||
| a | c | xa,xc | head,sharp_left,destination |
|
||||
| a | e | xa,xe | head,left,destination |
|
||||
| a | g | xa,xg | head,slight_left,destination |
|
||||
| a | i | xa,xi | head,straight,destination |
|
||||
| a | k | xa,xk | head,slight_right,destination |
|
||||
| a | m | xa,xm | head,right,destination |
|
||||
| a | o | xa,xo | head,sharp_right,destination |
|
||||
|
||||
| c | e | xc,xe | head,sharp_left,destination |
|
||||
| c | g | xc,xg | head,left,destination |
|
||||
| c | i | xc,xi | head,slight_left,destination |
|
||||
| c | k | xc,xk | head,straight,destination |
|
||||
| c | m | xc,xm | head,slight_right,destination |
|
||||
| c | o | xc,xo | head,right,destination |
|
||||
| c | a | xc,xa | head,sharp_right,destination |
|
||||
|
||||
| e | g | xe,xg | head,sharp_left,destination |
|
||||
| e | i | xe,xi | head,left,destination |
|
||||
| e | k | xe,xk | head,slight_left,destination |
|
||||
| e | m | xe,xm | head,straight,destination |
|
||||
| e | o | xe,xo | head,slight_right,destination |
|
||||
| e | a | xe,xa | head,right,destination |
|
||||
| e | c | xe,xc | head,sharp_right,destination |
|
||||
|
||||
| g | i | xg,xi | head,sharp_left,destination |
|
||||
| g | k | xg,xk | head,left,destination |
|
||||
| g | m | xg,xm | head,slight_left,destination |
|
||||
| g | o | xg,xo | head,straight,destination |
|
||||
| g | a | xg,xa | head,slight_right,destination |
|
||||
| g | c | xg,xc | head,right,destination |
|
||||
| g | e | xg,xe | head,sharp_right,destination |
|
||||
|
||||
Scenario: Skadestuevej, København
|
||||
https://github.com/DennisOSRM/Project-OSRM/issues/532
|
||||
Given the node locations
|
||||
| node | lat | lon |
|
||||
| a | 55.68679 | 12.52360 |
|
||||
| b | 55.68745 | 12.52407 |
|
||||
| c | 55.68720 | 12.52509 |
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| ab |
|
||||
| bc |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | bearing | turns |
|
||||
| a | c | ab,bc | 22,113 | head,right,destination |
|
Loading…
Reference in New Issue
Block a user