diff --git a/features/bicycle/access.feature b/features/bicycle/access.feature index ad6378836..319d137d0 100644 --- a/features/bicycle/access.feature +++ b/features/bicycle/access.feature @@ -153,14 +153,14 @@ Reference: http://wiki.openstreetmap.org/wiki/Key:access Scenario: Bike - Access combinations Then routability should be - | highway | access | vehicle | bicycle | bothw | - | runway | private | | yes | x | - | footway | | no | permissive | x | - | motorway | | | yes | x | - | track | forestry | | permissive | x | - | cycleway | yes | designated | no | | - | primary | | yes | private | | - | residential | permissive | | no | | + | highway | access | vehicle | bicycle | forw | backw | + | runway | private | | yes | x | x | + | footway | | no | permissive | x | x | + | motorway | | | yes | x | | + | track | forestry | | permissive | x | x | + | cycleway | yes | designated | no | | | + | primary | | yes | private | | | + | residential | permissive | | no | | | Scenario: Bike - Ignore access tags for other modes Then routability should be diff --git a/features/bicycle/cycleway.feature b/features/bicycle/cycleway.feature index 989e2ae79..5da976e1d 100644 --- a/features/bicycle/cycleway.feature +++ b/features/bicycle/cycleway.feature @@ -7,23 +7,23 @@ Reference: http://wiki.openstreetmap.org/wiki/Key:cycleway Scenario: Bike - Cycle tracks/lanes should enable biking Then routability should be - | highway | cycleway | bothw | - | motorway | | | - | motorway | track | x | - | motorway | lane | x | - | motorway | shared | x | - | motorway | share_busway | x | - | motorway | sharrow | x | - | some_tag | track | x | - | some_tag | lane | x | - | some_tag | shared | x | - | some_tag | share_busway | x | - | some_tag | sharrow | x | - | residential | track | x | - | residential | lane | x | - | residential | shared | x | - | residential | share_busway | x | - | residential | sharrow | x | + | highway | cycleway | forw | backw | + | motorway | | | | + | motorway | track | x | | + | motorway | lane | x | | + | motorway | shared | x | | + | motorway | share_busway | x | | + | motorway | sharrow | x | | + | some_tag | track | x | x | + | some_tag | lane | x | x | + | some_tag | shared | x | x | + | some_tag | share_busway | x | x | + | some_tag | sharrow | x | x | + | residential | track | x | x | + | residential | lane | x | x | + | residential | shared | x | x | + | residential | share_busway | x | x | + | residential | sharrow | x | x | Scenario: Bike - Left/right side cycleways on implied bidirectionals Then routability should be @@ -70,12 +70,12 @@ Reference: http://wiki.openstreetmap.org/wiki/Key:cycleway Scenario: Bike - Access tags should overwrite cycleway access Then routability should be - | highway | cycleway | access | bothw | - | motorway | track | no | | - | residential | track | no | | - | footway | track | no | | - | cycleway | track | no | | - | motorway | lane | yes | x | - | residential | lane | yes | x | - | footway | lane | yes | x | - | cycleway | lane | yes | x | + | highway | cycleway | access | forw | backw | + | motorway | track | no | | | + | residential | track | no | | | + | footway | track | no | | | + | cycleway | track | no | | | + | motorway | lane | yes | x | | + | residential | lane | yes | x | x | + | footway | lane | yes | x | x | + | cycleway | lane | yes | x | x | diff --git a/features/bicycle/pushing.feature b/features/bicycle/pushing.feature index cd6723a6f..2b238292a 100644 --- a/features/bicycle/pushing.feature +++ b/features/bicycle/pushing.feature @@ -57,11 +57,11 @@ Feature: Bike - Accessability of different way types Scenario: Bike - Pushing bikes on ways with foot=yes Then routability should be - | highway | foot | bothw | - | motorway | | | - | motorway | yes | foot | - | runway | | | - | runway | yes | foot | + | highway | foot | forw | backw | + | motorway | | | | + | motorway | yes | foot | | + | runway | | | | + | runway | yes | foot | foot | @todo Scenario: Bike - Pushing bikes on ways with foot=yes in one direction diff --git a/features/step_definitions/routability.rb b/features/step_definitions/routability.rb index 6305fc1ea..438924667 100644 --- a/features/step_definitions/routability.rb +++ b/features/step_definitions/routability.rb @@ -1,3 +1,42 @@ +def test_routability_row i + result = {} + ['forw','backw'].each do |direction| + a = Location.new @origin[0]+(1+WAY_SPACING*i)*@zoom, @origin[1] + b = Location.new @origin[0]+(3+WAY_SPACING*i)*@zoom, @origin[1] + r = {} + r[:response] = request_route direction=='forw' ? [a,b] : [b,a] + r[:json] = JSON.parse(r[:response].body) + + r[:status] = route_status r[:response] + if r[:status].empty? == false + r[:route] = way_list r[:json]['route_instructions'] + + if r[:route]=="w#{i}" + r[:time] = r[:json]['route_summary']['total_time'] + r[:distance] = r[:json]['route_summary']['total_distance'] + r[:speed] = r[:time]>0 ? (3.6*r[:distance]/r[:time]).to_i : nil + else + # if we hit the wrong way segment, we assume it's + # because the one we tested was not unroutable + r = {} + end + end + result[direction] = r + end + + # check if forw and backw returned the same values + result['bothw'] = {} + [:status,:time,:distance,:speed].each do |key| + if result['forw'][key] == result['backw'][key] + result['bothw'][key] = result['forw'][key] + else + result['bothw'][key] = 'diff' + end + end + + result +end + Then /^routability should be$/ do |table| build_ways_from_table table reprocess @@ -9,36 +48,26 @@ Then /^routability should be$/ do |table| table.hashes.each_with_index do |row,i| got = row.dup attempts = [] - ['forw','backw','bothw'].each do |direction| - if table.headers.include? direction - if direction == 'forw' || direction == 'bothw' - a = Location.new @origin[0]+(1+WAY_SPACING*i)*@zoom, @origin[1] - b = Location.new @origin[0]+(3+WAY_SPACING*i)*@zoom, @origin[1] - response = request_route [a,b] - elsif direction == 'backw' || direction == 'bothw' - a = Location.new @origin[0]+(3+WAY_SPACING*i)*@zoom, @origin[1] - b = Location.new @origin[0]+(1+WAY_SPACING*i)*@zoom, @origin[1] - response = request_route [a,b] - end - want = shortcuts_hash[row[direction]] || row[direction] #expand shortcuts - got[direction] = route_status response - json = JSON.parse(response.body) - if got[direction].empty? == false - route = way_list json['route_instructions'] - if route != "w#{i}" - got[direction] = '' - elsif want =~ /^\d+s/ - time = json['route_summary']['total_time'] - got[direction] = "#{time}s" - end - end - if FuzzyMatch.match got[direction], want - got[direction] = row[direction] - else - attempts << { :attempt => direction, :query => @query, :response => response } - end + result = test_routability_row i + (['forw','backw','bothw'] & table.headers).each do |direction| + want = shortcuts_hash[row[direction]] || row[direction] #expand shortcuts + + case want + when '', 'x' + got[direction] = result[direction][:status].to_s + when /^\d+s/ + got[direction] = "#{result[direction][:time]}s" + when /^\d+ km\/h/ + got[direction] = "#{result[direction][:speed]} km/h" + end + + if FuzzyMatch.match got[direction], want + got[direction] = row[direction] + else +# attempts << { :attempt => direction, :query => @query, :response => result[direction][:response] } end end + log_fail row,got,attempts if got != row actual << got end diff --git a/features/testbot/speed.feature b/features/testbot/speed.feature new file mode 100644 index 000000000..1f183750c --- /dev/null +++ b/features/testbot/speed.feature @@ -0,0 +1,18 @@ +@routing @speed @testbot +Feature: Testbot - speeds + + Background: Use specific speeds + Given the profile "testbot" + + Scenario: Testbot - Speed on roads + Then routability should be + | highway | bothw | + | primary | 36 km/h | + | unknown | 24 km/h | + | secondary | 18 km/h | + | tertiary | 12 km/h | + + Scenario: Testbot - Speed on rivers + Then routability should be + | highway | forw | backw | + | river | 36 km/h | 16 km/h |