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
|
Scenario: Bike - Access combinations
|
||||||
Then routability should be
|
Then routability should be
|
||||||
| highway | access | vehicle | bicycle | bothw |
|
| highway | access | vehicle | bicycle | forw | backw |
|
||||||
| runway | private | | yes | x |
|
| runway | private | | yes | x | x |
|
||||||
| footway | | no | permissive | x |
|
| footway | | no | permissive | x | x |
|
||||||
| motorway | | | yes | x |
|
| motorway | | | yes | x | |
|
||||||
| track | forestry | | permissive | x |
|
| track | forestry | | permissive | x | x |
|
||||||
| cycleway | yes | designated | no | |
|
| cycleway | yes | designated | no | | |
|
||||||
| primary | | yes | private | |
|
| primary | | yes | private | | |
|
||||||
| residential | permissive | | no | |
|
| residential | permissive | | no | | |
|
||||||
|
|
||||||
Scenario: Bike - Ignore access tags for other modes
|
Scenario: Bike - Ignore access tags for other modes
|
||||||
Then routability should be
|
Then routability should be
|
||||||
|
@ -7,23 +7,23 @@ Reference: http://wiki.openstreetmap.org/wiki/Key:cycleway
|
|||||||
|
|
||||||
Scenario: Bike - Cycle tracks/lanes should enable biking
|
Scenario: Bike - Cycle tracks/lanes should enable biking
|
||||||
Then routability should be
|
Then routability should be
|
||||||
| highway | cycleway | bothw |
|
| highway | cycleway | forw | backw |
|
||||||
| motorway | | |
|
| motorway | | | |
|
||||||
| motorway | track | x |
|
| motorway | track | x | |
|
||||||
| motorway | lane | x |
|
| motorway | lane | x | |
|
||||||
| motorway | shared | x |
|
| motorway | shared | x | |
|
||||||
| motorway | share_busway | x |
|
| motorway | share_busway | x | |
|
||||||
| motorway | sharrow | x |
|
| motorway | sharrow | x | |
|
||||||
| some_tag | track | x |
|
| some_tag | track | x | x |
|
||||||
| some_tag | lane | x |
|
| some_tag | lane | x | x |
|
||||||
| some_tag | shared | x |
|
| some_tag | shared | x | x |
|
||||||
| some_tag | share_busway | x |
|
| some_tag | share_busway | x | x |
|
||||||
| some_tag | sharrow | x |
|
| some_tag | sharrow | x | x |
|
||||||
| residential | track | x |
|
| residential | track | x | x |
|
||||||
| residential | lane | x |
|
| residential | lane | x | x |
|
||||||
| residential | shared | x |
|
| residential | shared | x | x |
|
||||||
| residential | share_busway | x |
|
| residential | share_busway | x | x |
|
||||||
| residential | sharrow | x |
|
| residential | sharrow | x | x |
|
||||||
|
|
||||||
Scenario: Bike - Left/right side cycleways on implied bidirectionals
|
Scenario: Bike - Left/right side cycleways on implied bidirectionals
|
||||||
Then routability should be
|
Then routability should be
|
||||||
@ -70,12 +70,12 @@ Reference: http://wiki.openstreetmap.org/wiki/Key:cycleway
|
|||||||
|
|
||||||
Scenario: Bike - Access tags should overwrite cycleway access
|
Scenario: Bike - Access tags should overwrite cycleway access
|
||||||
Then routability should be
|
Then routability should be
|
||||||
| highway | cycleway | access | bothw |
|
| highway | cycleway | access | forw | backw |
|
||||||
| motorway | track | no | |
|
| motorway | track | no | | |
|
||||||
| residential | track | no | |
|
| residential | track | no | | |
|
||||||
| footway | track | no | |
|
| footway | track | no | | |
|
||||||
| cycleway | track | no | |
|
| cycleway | track | no | | |
|
||||||
| motorway | lane | yes | x |
|
| motorway | lane | yes | x | |
|
||||||
| residential | lane | yes | x |
|
| residential | lane | yes | x | x |
|
||||||
| footway | lane | yes | x |
|
| footway | lane | yes | x | x |
|
||||||
| cycleway | lane | yes | 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
|
Scenario: Bike - Pushing bikes on ways with foot=yes
|
||||||
Then routability should be
|
Then routability should be
|
||||||
| highway | foot | bothw |
|
| highway | foot | forw | backw |
|
||||||
| motorway | | |
|
| motorway | | | |
|
||||||
| motorway | yes | foot |
|
| motorway | yes | foot | |
|
||||||
| runway | | |
|
| runway | | | |
|
||||||
| runway | yes | foot |
|
| runway | yes | foot | foot |
|
||||||
|
|
||||||
@todo
|
@todo
|
||||||
Scenario: Bike - Pushing bikes on ways with foot=yes in one direction
|
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|
|
Then /^routability should be$/ do |table|
|
||||||
build_ways_from_table table
|
build_ways_from_table table
|
||||||
reprocess
|
reprocess
|
||||||
@ -9,36 +48,26 @@ Then /^routability should be$/ do |table|
|
|||||||
table.hashes.each_with_index do |row,i|
|
table.hashes.each_with_index do |row,i|
|
||||||
got = row.dup
|
got = row.dup
|
||||||
attempts = []
|
attempts = []
|
||||||
['forw','backw','bothw'].each do |direction|
|
result = test_routability_row i
|
||||||
if table.headers.include? direction
|
(['forw','backw','bothw'] & table.headers).each do |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
|
want = shortcuts_hash[row[direction]] || row[direction] #expand shortcuts
|
||||||
got[direction] = route_status response
|
|
||||||
json = JSON.parse(response.body)
|
case want
|
||||||
if got[direction].empty? == false
|
when '', 'x'
|
||||||
route = way_list json['route_instructions']
|
got[direction] = result[direction][:status].to_s
|
||||||
if route != "w#{i}"
|
when /^\d+s/
|
||||||
got[direction] = ''
|
got[direction] = "#{result[direction][:time]}s"
|
||||||
elsif want =~ /^\d+s/
|
when /^\d+ km\/h/
|
||||||
time = json['route_summary']['total_time']
|
got[direction] = "#{result[direction][:speed]} km/h"
|
||||||
got[direction] = "#{time}s"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if FuzzyMatch.match got[direction], want
|
if FuzzyMatch.match got[direction], want
|
||||||
got[direction] = row[direction]
|
got[direction] = row[direction]
|
||||||
else
|
else
|
||||||
attempts << { :attempt => direction, :query => @query, :response => response }
|
# attempts << { :attempt => direction, :query => @query, :response => result[direction][:response] }
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
log_fail row,got,attempts if got != row
|
log_fail row,got,attempts if got != row
|
||||||
actual << got
|
actual << got
|
||||||
end
|
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