cuke: improve routability tables, test for speed
This commit is contained in:
parent
b0ce9e4af7
commit
cb1b824a75
@ -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
|
||||
|
@ -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 |
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
result = test_routability_row i
|
||||
(['forw','backw','bothw'] & table.headers).each do |direction|
|
||||
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
|
||||
|
||||
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 => response }
|
||||
end
|
||||
# attempts << { :attempt => direction, :query => @query, :response => result[direction][:response] }
|
||||
end
|
||||
end
|
||||
|
||||
log_fail row,got,attempts if got != row
|
||||
actual << got
|
||||
end
|
||||
|
18
features/testbot/speed.feature
Normal file
18
features/testbot/speed.feature
Normal file
@ -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 |
|
Loading…
Reference in New Issue
Block a user