Skip to content

Commit

Permalink
Merge pull request #128 from emiltin/cuke_way_check
Browse files Browse the repository at this point in the history
perform a sanity check on which ways are used during routability tests
  • Loading branch information
Project OSRM committed Feb 18, 2012
2 parents 9542ab0 + 801490b commit 4eaaf91
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
35 changes: 20 additions & 15 deletions features/step_definitions/routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,24 +157,29 @@ def computed_route
table.hashes.each_with_index do |row,i|
got = row.dup
attempts = []
if table.headers.include? 'forw'
response = request_route("#{ORIGIN[1]},#{ORIGIN[0]+(1+WAY_SPACING*i)*ZOOM}","#{ORIGIN[1]},#{ORIGIN[0]+(2+WAY_SPACING*i)*ZOOM}")
got['forw'] = route_status response
if got['forw'] != row['forw']
row['way'] = "w#{i}"
got['way'] = "w#{i}"
['forw','backw'].each do |direction|
if table.headers.include? direction
if direction == 'forw'
response = request_route("#{ORIGIN[1]},#{ORIGIN[0]+(1+WAY_SPACING*i)*@zoom}","#{ORIGIN[1]},#{ORIGIN[0]+(2+WAY_SPACING*i)*@zoom}")
elsif direction == 'backw'
response = request_route("#{ORIGIN[1]},#{ORIGIN[0]+(2+WAY_SPACING*i)*@zoom}","#{ORIGIN[1]},#{ORIGIN[0]+(1+WAY_SPACING*i)*@zoom}")
end
got[direction] = route_status response
json = JSON.parse(response.body)
attempts << { :attempt => 'Forward', :query => @query, :response => response }
if got[direction] == 'x'
route = way_list json['route_instructions']
if route != "w#{i}"
got[direction] = "#{route}?"
end
end
if got[direction] != row[direction]
attempts << { :attempt => direction, :query => @query, :response => response }
end
end
end
if table.headers.include? 'backw'
response = request_route("#{ORIGIN[1]},#{ORIGIN[0]+(2+WAY_SPACING*i)*ZOOM}","#{ORIGIN[1]},#{ORIGIN[0]+(1+WAY_SPACING*i)*ZOOM}")
got['backw'] = route_status response
if got['backw'] != row['backw']
attempts << { :attempt => 'Backward', :query => @query, :response => response }
end
end
if got != row
log_fail row,got,attempts
end
log_fail row,got,attempts if got != row
actual << got
end
end
Expand Down
2 changes: 1 addition & 1 deletion features/support/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def build_ways_from_table table
tags = row.dup
tags.delete 'forw'
tags.delete 'backw'
tags['name'] = "abcd#{ri}"
tags['name'] = "w#{ri}"
tags.reject! { |k,v| v=='' }
way << tags
osm_db << way
Expand Down

0 comments on commit 4eaaf91

Please sign in to comment.