test access tags

This commit is contained in:
Emil Tin 2012-09-30 12:01:56 +02:00 committed by Emil Tin
parent 2798c5a48d
commit 81b9e3b4cb
6 changed files with 217 additions and 77 deletions

View File

@ -1,80 +1,66 @@
@routing @access
Feature: Default speedprofiles
Basic accessability of various way types depending on speedprofile.
Feature: Restricted access
Scenario: Basic access for cars
Given the speedprofile "car"
Background:
Given the speedprofile "bicycle"
Scenario: Access tags on ways
Then routability should be
| highway | forw |
| motorway | x |
| motorway_link | x |
| trunk | x |
| trunk_link | x |
| primary | x |
| secondary | x |
| tertiary | x |
| residential | x |
| service | x |
| unclassified | x |
| living_street | x |
| road | |
| track | |
| path | |
| footway | |
| pedestrian | |
| steps | |
| pier | |
| cycleway | |
| bridleway | |
| access | bothw |
| yes | x |
| motorcar | x |
| motor_vehicle | x |
| vehicle | x |
| permissive | x |
| designated | x |
| no | |
| private | |
| agricultural | |
| forestry | |
| designated | |
| some_tag | x |
Scenario: Basic access for bicycles
Bikes are allowed on footways etc because you can pull your bike at a lower speed.
Given the speedprofile "bicycle"
Scenario: Access tags for other modes should have no effect
Then routability should be
| highway | forw |
| motorway | |
| motorway_link | |
| trunk | |
| trunk_link | |
| primary | x |
| secondary | x |
| tertiary | x |
| residential | x |
| service | x |
| unclassified | x |
| living_street | x |
| road | x |
| track | x |
| path | x |
| footway | x |
| pedestrian | x |
| steps | x |
| pier | x |
| cycleway | x |
| bridleway | |
| access | bothw |
| ufo:yes | x |
| ufo:motorcar | x |
| ufo:motor_vehicle | x |
| ufo:vehicle | x |
| ufo:permissive | x |
| ufo:designated | x |
| ufo:no | x |
| ufo:private | x |
| ufo:agricultural | x |
| ufo:forestry | x |
| ufo:designated | x |
| ufo:some_tag | x |
Scenario: Basic access for walking
Given the speedprofile "foot"
Scenario: Access tags on nodes
Then routability should be
| highway | forw |
| motorway | |
| motorway_link | |
| trunk | |
| trunk_link | x |
| primary | x |
| secondary | x |
| tertiary | x |
| residential | x |
| service | x |
| unclassified | x |
| living_street | x |
| road | x |
| track | x |
| path | x |
| footway | x |
| pedestrian | x |
| steps | x |
| pier | x |
| cycleway | x |
| bridleway | |
| node:access | bothw |
| yes | x |
| motorcar | x |
| motor_vehicle | x |
| vehicle | x |
| permissive | x |
| designated | x |
| no | |
| private | |
| agricultural | |
| forestry | |
| designated | |
| some_tag | x |
Scenario: Access tags on both nodes and way
Then routability should be
| access | node:access | bothw |
| yes | yes | x |
| yes | no | |
| yes | some_tag | |
| no | yes | |
| no | no | |
| no | some_tag | |
| some_tag | yes | |
| some_tag | no | |
| some_tag | some_tag | |

View File

@ -0,0 +1,70 @@
@routing @destination
Feature: Destination only, no passing through
Background:
Given the speedprofile "car"
Scenario: Destination only street
Given the node map
| a | | | | |
| | b | c | d | |
| | | | | e |
And the ways
| nodes | access |
| ab | |
| bcd | destination |
| de | |
When I route I should get
| from | to | route |
| a | b | ab |
| a | c | ab,bcd |
| a | d | ab,bcd |
| a | e | ab,bcd,de |
| e | d | de |
| e | c | de,bcd |
| e | b | de,bcd |
| e | a | de,bcd,ab |
| b | c | bcd |
| b | d | bcd |
| d | c | bcd |
| d | b | bcd |
Scenario: Series of destination only streets
Given the node map
| a | | c | | e |
| | b | | d | |
And the ways
| nodes | access |
| ab | |
| bc | destination |
| cd | destination |
| de | destination |
When I route I should get
| from | to | route |
| a | b | ab |
| a | c | ab |
| a | d | ab |
| a | e | ab |
Scenario: Routing inside a destination only area
Given the node map
| a | | c | | e |
| | b | | d | |
And the ways
| nodes | access |
| ab | destination |
| bc | destination |
| cd | destination |
| de | destination |
When I route I should get
| from | to | route |
| a | e | ab,bc,cd,de |
| e | a | de,cd,bc,ab |
| b | d | bc,cd |
| d | b | cd,bc |

View File

@ -150,8 +150,8 @@ Then /^routability should be$/ do |table|
build_ways_from_table table
reprocess
actual = []
if table.headers&["forw","backw"] == []
raise "*** routability tabel must contain either 'forw' or 'backw' column"
if table.headers&["forw","backw","bothw"] == []
raise "*** routability tabel must contain either 'forw', 'backw' or 'bothw' column"
end
OSRMLauncher.new do
table.hashes.each_with_index do |row,i|
@ -159,9 +159,9 @@ Then /^routability should be$/ do |table|
attempts = []
['forw','backw'].each do |direction|
if table.headers.include? direction
if direction == 'forw'
if direction == 'forw' || direction == 'bothw'
response = request_route("#{ORIGIN[1]},#{ORIGIN[0]+(1+WAY_SPACING*i)*@zoom}","#{ORIGIN[1]},#{ORIGIN[0]+(3+WAY_SPACING*i)*@zoom}")
elsif direction == 'backw'
elsif direction == 'backw' || direction == 'bothw'
response = request_route("#{ORIGIN[1]},#{ORIGIN[0]+(3+WAY_SPACING*i)*@zoom}","#{ORIGIN[1]},#{ORIGIN[0]+(1+WAY_SPACING*i)*@zoom}")
end
got[direction] = route_status response

View File

@ -76,7 +76,8 @@ def build_ways_from_table table
tags.reject! { |k,v| v=='' }
# sort tag keys in the form of 'node/....'
way_tags = {}
way_tags = { 'highway' => 'primary' }
node_tags = {}
tags.each_pair do |k,v|
if k =~ /node\/(.*)/

View File

@ -7,4 +7,8 @@ class OSRMError < StandardError
@code = code
@msg = msg
end
def to_s
@msg
end
end

79
features/way.feature Normal file
View File

@ -0,0 +1,79 @@
@routing @way
Feature: Accessability of different way types
Scenario: Basic access for cars
Given the speedprofile "car"
Then routability should be
| highway | forw |
| motorway | x |
| motorway_link | x |
| trunk | x |
| trunk_link | x |
| primary | x |
| secondary | x |
| tertiary | x |
| residential | x |
| service | x |
| unclassified | x |
| living_street | x |
| road | |
| track | |
| path | |
| footway | |
| pedestrian | |
| steps | |
| pier | |
| cycleway | |
| bridleway | |
Scenario: Basic access for bicycles
Bikes are allowed on footways etc because you can pull your bike at a lower speed.
Given the speedprofile "bicycle"
Then routability should be
| highway | forw |
| motorway | |
| motorway_link | |
| trunk | |
| trunk_link | |
| primary | x |
| secondary | x |
| tertiary | x |
| residential | x |
| service | x |
| unclassified | x |
| living_street | x |
| road | x |
| track | x |
| path | x |
| footway | x |
| pedestrian | x |
| steps | x |
| pier | x |
| cycleway | x |
| bridleway | |
Scenario: Basic access for walking
Given the speedprofile "foot"
Then routability should be
| highway | forw |
| motorway | |
| motorway_link | |
| trunk | |
| trunk_link | x |
| primary | x |
| secondary | x |
| tertiary | x |
| residential | x |
| service | x |
| unclassified | x |
| living_street | x |
| road | x |
| track | x |
| path | x |
| footway | x |
| pedestrian | x |
| steps | x |
| pier | x |
| cycleway | x |
| bridleway | |