support testing of turn directions

This commit is contained in:
Emil Tin
2012-12-09 18:21:33 +01:00
parent 86a5bbac51
commit e41d52570e
3 changed files with 144 additions and 1 deletions
+25 -1
View File
@@ -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