better handling of access and barrier tags

This commit is contained in:
Emil Tin 2012-10-03 19:04:56 +02:00
parent 30465f08ac
commit 4b00557fda
13 changed files with 162 additions and 159 deletions

View File

@ -7,6 +7,7 @@ Feature: Bike - Restricted access
Scenario: Bike - Access tags on ways
Then routability should be
| access | bothw |
| | x |
| yes | x |
| motorcar | x |
| motor_vehicle | x |
@ -14,31 +15,17 @@ Feature: Bike - Restricted access
| permissive | x |
| designated | x |
| no | |
| foot | |
| private | |
| agricultural | |
| forestry | |
| designated | |
| forestery | |
| some_tag | x |
Scenario: Bike - Access tags for other modes should have no effect
Then routability should be
| 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: Bike - Access tags on nodes
Then routability should be
| node:access | bothw |
| node/access | bothw |
| | x |
| yes | x |
| motorcar | x |
| motor_vehicle | x |
@ -46,21 +33,24 @@ Feature: Bike - Restricted access
| permissive | x |
| designated | x |
| no | |
| foot | |
| private | |
| agricultural | |
| forestry | |
| designated | |
| forestery | |
| some_tag | x |
Scenario: Bike - Access tags on both nodes and way
Then routability should be
| access | node:access | bothw |
| access | node/access | bothw |
| yes | yes | x |
| yes | no | |
| yes | some_tag | |
| yes | foot | |
| yes | some_tag | x |
| no | yes | |
| no | no | |
| no | foot | |
| no | some_tag | |
| some_tag | yes | |
| some_tag | yes | x |
| some_tag | no | |
| some_tag | some_tag | |
| some_tag | foot | |
| some_tag | some_tag | x |

View File

@ -6,37 +6,43 @@ Feature: Barriers
Scenario: Bike - Barriers
Then routability should be
| highway | node/barrier | node/access | bothw |
| primary | | | x |
| primary | gate | | x |
| primary | cattle_grid | | x |
| primary | border_control | | x |
| primary | toll_booth | | x |
| primary | sally_port | | x |
| primary | bollard | | x |
| primary | some_tag | | |
| node/barrier | bothw |
| | x |
| bollard | x |
| gate | x |
| cattle_grid | x |
| border_control | x |
| toll_booth | x |
| sally_port | x |
| entrance | x |
| wall | |
| fence | |
| some_tag | |
Scenario: Bike - Access tag trumphs barriers
Then routability should be
| highway | node/barrier | node/access | bothw |
| primary | bollard | yes | x |
| primary | gate | yes | x |
| primary | cattle_grid | yes | x |
| primary | border_control | yes | x |
| primary | toll_booth | yes | x |
| primary | sally_port | yes | x |
| primary | bollard | no | |
| primary | gate | no | |
| primary | cattle_grid | no | |
| primary | border_control | no | |
| primary | toll_booth | no | |
| primary | sally_port | no | |
| primary | sally_port | some_tag | |
| primary | some_tag | bicycle | x |
| primary | some_tag | foot | |
| primary | some_tag | motorcar | |
| primary | some_tag | motor_vehicle | |
| primary | some_tag | vehicle | |
| primary | some_tag | motorcar | |
| primary | some_tag | permissive | |
| primary | some_tag | designated | |
| node/barrier | node/access | bothw |
| bollard | | x |
| bollard | yes | x |
| bollard | bicycle | x |
| bollard | vehicle | x |
| bollard | motorcar | x |
| bollard | motor_vehicle | x |
| bollard | permissive | x |
| bollard | designated | x |
| bollard | no | |
| bollard | foot | |
| bollard | private | |
| bollard | agricultural | |
| wall | | |
| wall | yes | x |
| wall | bicycle | x |
| wall | vehicle | x |
| wall | motorcar | x |
| wall | motor_vehicle | x |
| wall | permissive | x |
| wall | designated | x |
| wall | no | |
| wall | foot | |
| wall | private | |
| wall | agricultural | |

View File

@ -16,29 +16,13 @@ Feature: Car - Restricted access
| no | |
| private | |
| agricultural | |
| forestry | |
| designated | |
| forestery | |
| some_tag | x |
Scenario: Car - Access tags for other modes should have no effect
Then routability should be
| 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: Car - Access tags on nodes
Then routability should be
| node:access | bothw |
| node/access | bothw |
| yes | x |
| motorcar | x |
| motor_vehicle | x |
@ -48,19 +32,18 @@ Feature: Car - Restricted access
| no | |
| private | |
| agricultural | |
| forestry | |
| designated | |
| forestery | |
| some_tag | x |
Scenario: Car - Access tags on both nodes and way
Then routability should be
| access | node:access | bothw |
| access | node/access | bothw |
| yes | yes | x |
| yes | no | |
| yes | some_tag | |
| yes | some_tag | x |
| no | yes | |
| no | no | |
| no | some_tag | |
| some_tag | yes | |
| some_tag | yes | x |
| some_tag | no | |
| some_tag | some_tag | |
| some_tag | some_tag | x |

View File

@ -6,37 +6,43 @@ Feature: Car - Barriers
Scenario: Car - Barriers
Then routability should be
| highway | node/barrier | node/access | bothw |
| primary | | | x |
| primary | gate | | x |
| primary | cattle_grid | | x |
| primary | border_control | | x |
| primary | toll_booth | | x |
| primary | sally_port | | x |
| primary | bollard | | |
| primary | some_tag | | |
| node/barrier | bothw |
| | x |
| bollard | |
| gate | x |
| cattle_grid | x |
| border_control | x |
| toll_booth | x |
| sally_port | x |
| entrance | |
| wall | |
| fence | |
| some_tag | |
Scenario: Car - Access tag trumphs barriers
Then routability should be
| highway | node/barrier | node/access | bothw |
| primary | bollard | yes | x |
| primary | gate | yes | x |
| primary | cattle_grid | yes | x |
| primary | border_control | yes | x |
| primary | toll_booth | yes | x |
| primary | sally_port | yes | x |
| primary | bollard | no | |
| primary | gate | no | |
| primary | cattle_grid | no | |
| primary | border_control | no | |
| primary | toll_booth | no | |
| primary | sally_port | no | |
| primary | sally_port | some_tag | |
| primary | bollard | bicycle | |
| primary | bollard | foot | |
| primary | bollard | motorcar | x |
| primary | bollard | motor_vehicle | x |
| primary | bollard | vehicle | x |
| primary | bollard | motorcar | x |
| primary | bollard | permissive | x |
| primary | bollard | designated | x |
| node/barrier | node/access | bothw |
| gate | | x |
| gate | yes | x |
| gate | vehicle | x |
| gate | motorcar | x |
| gate | motor_vehicle | x |
| gate | permissive | x |
| gate | designated | x |
| gate | no | |
| gate | foot | |
| gate | bicycle | |
| gate | private | |
| gate | agricultural | |
| wall | | |
| wall | yes | x |
| wall | vehicle | x |
| wall | motorcar | x |
| wall | motor_vehicle | x |
| wall | permissive | x |
| wall | designated | x |
| wall | no | |
| wall | foot | |
| wall | bicycle | |
| wall | private | |
| wall | agricultural | |

View File

@ -5,30 +5,30 @@ Feature: Max speed restrictions
Given the speedprofile "car"
Given a grid size of 1000 meters
Scenario: Car - Maxspeed below profile speed of way type
Scenario: Car - Respect maxspeeds when lower that way type speed
Given the node map
| a | b | c |
And the ways
| nodes | highway | maxspeed |
| ab | motorway | |
| bc | motorway | 10 |
| ab | trunk | |
| bc | trunk | 10 |
When I route I should get
| from | to | route | time |
| a | b | ab | 40s ~10% |
| a | b | ab | 42s ~10% |
| b | c | bc | 360s ~10% |
Scenario: Car - Maxspeed above profile speed of way type
Scenario: Car - Use maxspeed when higher that way type speed
Given the node map
| a | b | c |
And the ways
| nodes | highway | maxspeed |
| ab | residential | |
| bc | residential | 50 |
| bc | residential | 85 |
When I route I should get
| from | to | route | time |
| a | b | ab | 145s ~10% |
| b | c | bc | 145s ~10% |
| a | b | ab | 144s ~10% |
| b | c | bc | 42s ~10% |

View File

@ -15,6 +15,16 @@ Handle oneways streets, as defined at http://wiki.openstreetmap.org/wiki/OSM_tag
| highway | oneway | forw | backw |
| primary | -1 | | x |
Scenario: Car - Implied onewatys
Then routability should be
| highway | junction | forw | backw |
| motorway | | x | |
| motorway_link | | x | |
| primary | | x | x |
| motorway | roundabout | x | |
| motorway_link | roundabout | x | |
| primary | roundabout | x | |
Scenario: Car - Around the Block
Given the node map
| a | b |

View File

@ -26,6 +26,7 @@ Handle oneways streets, as defined at http://wiki.openstreetmap.org/wiki/OSM_tag
Scenario: Foot - Oneway:foot tag should not cause walking on big roads
Then routability should be
| highway | oneway:foot | bothw |
| footway | | x |
| motorway | yes | |
| motorway_link | yes | |
| trunk | yes | |

View File

@ -10,7 +10,7 @@ Feature: Foot - Accessability of different way types
| motorway | |
| motorway_link | |
| trunk | |
| trunk_link | x |
| trunk_link | |
| primary | x |
| primary_link | x |
| secondary | x |

View File

@ -157,7 +157,7 @@ Then /^routability should be$/ do |table|
table.hashes.each_with_index do |row,i|
got = row.dup
attempts = []
['forw','backw'].each do |direction|
['forw','backw','bothw'].each do |direction|
if table.headers.include? direction
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}")

View File

@ -121,7 +121,6 @@ Feature: Distance calculation
| a | c | abc | 2000m +-1 |
| c | a | abc | 2000m +-1 |
@winding
Scenario: Distance of a winding south-north path
Given a grid size of 10 meters
Given the node map
@ -144,7 +143,6 @@ Feature: Distance calculation
| a | g | abcdefgh | 60m +-1 |
| a | h | abcdefgh | 70m +-1 |
@winding
Scenario: Distance of a winding east-west path
Given a grid size of 10 meters
Given the node map
@ -231,7 +229,7 @@ Feature: Distance calculation
| x | y | xy | 3162m +-1 |
@maze
Scenario: Distance of a winding south-north path
Scenario: Distance of a maze of short segments
Given a grid size of 7 meters
Given the node map
| a | b | s | t |

View File

@ -1,12 +1,9 @@
-- Bicycle profile
-- Begin of globals
bollards_whitelist = { [""] = true, ["cattle_grid"] = true, ["border_control"] = true, ["toll_booth"] = true, ["no"] = true, ["sally_port"] = true, ["gate"] = true}
access_tag_whitelist = { ["yes"] = true, ["vehicle"] = true, ["permissive"] = true, ["designated"] = true }
access_tag_blacklist = { ["no"] = true, ["private"] = true, ["agricultural"] = true, ["forestery"] = true }
barrier_whitelist = { [""] = true, ["bollard"] = true, ["entrance"] = true, ["cattle_grid"] = true, ["border_control"] = true, ["toll_booth"] = true, ["no"] = true, ["sally_port"] = true, ["gate"] = true}
access_tag_whitelist = { ["yes"] = true, ["bicycle"] = true, ["vehicle"] = true, ["permissive"] = true, ["designated"] = true }
access_tag_blacklist = { ["no"] = true, ["foot"] = true, ["private"] = true, ["agricultural"] = true, ["forestery"] = true }
access_tag_restricted = { ["destination"] = true, ["delivery"] = true }
access_tags = { "bicycle", "vehicle" }
service_tag_restricted = { ["parking_aisle"] = true }
ignore_in_grid = { ["ferry"] = true }
@ -49,23 +46,28 @@ function node_function (node)
local access = node.tags:Find ("access")
local traffic_signal = node.tags:Find("highway")
--flag node if it carries a traffic light
-- flag node if it carries a traffic light
if traffic_signal == "traffic_signals" then
node.traffic_light = true;
node.traffic_light = true
end
if obey_bollards then
--flag node as unpassable if it black listed as unpassable
if access_tag_blacklist[barrier] then
node.bollard = true;
-- parse access and barrier tags
if access ~= "" then
if access_tag_blacklist[access] then
node.bollard = true
else
node.bollard = false
end
--reverse the previous flag if there is an access tag specifying entrance
if node.bollard and not bollards_whitelist[barrier] and not access_tag_whitelist[barrier] then
node.bollard = false;
elseif barrier ~= "" then
if barrier_whitelist[barrier] then
node.bollard = false
else
node.bollard = true
end
else
node.bollard = false
end
return 1
end
@ -93,6 +95,11 @@ function way_function (way, numberOfNodesInWay)
local access = way.tags:Find("access")
-- Check if we are allowed to access the way
if access_tag_blacklist[access] ~=nil and access_tag_blacklist[access] then
return 0
end
-- Set the name that will be used for instructions
if "" ~= ref then
way.name = ref

View File

@ -2,7 +2,7 @@
barrier_whitelist = { ["cattle_grid"] = true, ["border_control"] = true, ["toll_booth"] = true, ["no"] = true, ["sally_port"] = true, ["gate"] = true}
access_tag_whitelist = { ["yes"] = true, ["motorcar"] = true, ["motor_vehicle"] = true, ["vehicle"] = true, ["permissive"] = true, ["designated"] = true }
access_tag_blacklist = { ["no"] = true, ["private"] = true, ["agricultural"] = true, ["forestery"] = true }
access_tag_blacklist = { ["no"] = true, ["foot"] = true, ["bicycle"] = true, ["private"] = true, ["agricultural"] = true, ["forestery"] = true }
access_tag_restricted = { ["destination"] = true, ["delivery"] = true }
access_tags = { "motorcar", "motor_vehicle", "vehicle" }
service_tag_restricted = { ["parking_aisle"] = true }
@ -44,26 +44,29 @@ function node_function (node)
local access = node.tags:Find ("access")
local traffic_signal = node.tags:Find("highway")
--flag node if it carries a traffic light
-- flag node if it carries a traffic light
if traffic_signal == "traffic_signals" then
node.traffic_light = true;
node.traffic_light = true
end
if "" ~= barrier and obey_bollards then
node.bollard = true; -- flag as unpassable and then check
if "yes" == access then
node.bollard = false;
return
end
--reverse the previous flag if there is an access tag specifying entrance
if node.bollard and (barrier_whitelist[barrier] or access_tag_whitelist[access]) then
node.bollard = false;
return
-- parse access and barrier tags
if access ~= "" then
if access_tag_blacklist[access] then
node.bollard = true
else
node.bollard = false
end
elseif barrier ~= "" then
if barrier_whitelist[barrier] then
node.bollard = false
else
node.bollard = true
end
else
node.bollard = false
end
end
return 1
end
function way_function (way, numberOfNodesInWay)

View File

@ -11,7 +11,6 @@ service_tag_restricted = { ["parking_aisle"] = true }
ignore_in_grid = { ["ferry"] = true }
speed_profile = {
["trunk_link"] = 5,
["primary"] = 5,
["primary_link"] = 5,
["secondary"] = 5,