From 4b00557fda49f1837471180f45f76a0929ef4c59 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Wed, 3 Oct 2012 19:04:56 +0200 Subject: [PATCH] better handling of access and barrier tags --- features/bicycle/access.feature | 38 ++++++--------- features/bicycle/barrier.feature | 68 +++++++++++++++------------ features/car/access.feature | 31 +++--------- features/car/barrier.feature | 70 +++++++++++++++------------- features/car/maxspeed.feature | 16 +++---- features/car/oneway.feature | 10 ++++ features/foot/oneway.feature | 1 + features/foot/way.feature | 2 +- features/step_definitions/routing.rb | 2 +- features/testbot/distance.feature | 4 +- profiles/bicycle.lua | 41 +++++++++------- profiles/car.lua | 37 ++++++++------- profiles/foot.lua | 1 - 13 files changed, 162 insertions(+), 159 deletions(-) diff --git a/features/bicycle/access.feature b/features/bicycle/access.feature index 0f53e0522..e28559b85 100644 --- a/features/bicycle/access.feature +++ b/features/bicycle/access.feature @@ -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 | diff --git a/features/bicycle/barrier.feature b/features/bicycle/barrier.feature index d6c89e9af..8a52d9478 100644 --- a/features/bicycle/barrier.feature +++ b/features/bicycle/barrier.feature @@ -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 | | \ No newline at end of file + | 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 | | diff --git a/features/car/access.feature b/features/car/access.feature index afccfa723..5e1292df7 100644 --- a/features/car/access.feature +++ b/features/car/access.feature @@ -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 | | \ No newline at end of file + | some_tag | some_tag | x | \ No newline at end of file diff --git a/features/car/barrier.feature b/features/car/barrier.feature index 03772f9ad..b031d84d8 100644 --- a/features/car/barrier.feature +++ b/features/car/barrier.feature @@ -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 | \ No newline at end of file + | 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 | | diff --git a/features/car/maxspeed.feature b/features/car/maxspeed.feature index 54182b83a..c28b42779 100644 --- a/features/car/maxspeed.feature +++ b/features/car/maxspeed.feature @@ -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% | diff --git a/features/car/oneway.feature b/features/car/oneway.feature index 134b43a30..99963680e 100644 --- a/features/car/oneway.feature +++ b/features/car/oneway.feature @@ -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 | diff --git a/features/foot/oneway.feature b/features/foot/oneway.feature index 498ba177e..3eb82b4a4 100644 --- a/features/foot/oneway.feature +++ b/features/foot/oneway.feature @@ -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 | | diff --git a/features/foot/way.feature b/features/foot/way.feature index 6523358c2..19b728ebd 100644 --- a/features/foot/way.feature +++ b/features/foot/way.feature @@ -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 | diff --git a/features/step_definitions/routing.rb b/features/step_definitions/routing.rb index bcc1d6d65..ae7ac38e3 100644 --- a/features/step_definitions/routing.rb +++ b/features/step_definitions/routing.rb @@ -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}") diff --git a/features/testbot/distance.feature b/features/testbot/distance.feature index 46c517650..e88a0244c 100644 --- a/features/testbot/distance.feature +++ b/features/testbot/distance.feature @@ -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 | diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index e10b97a98..f6de00484 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -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 diff --git a/profiles/car.lua b/profiles/car.lua index 35030a6bc..d12fa36b4 100644 --- a/profiles/car.lua +++ b/profiles/car.lua @@ -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) diff --git a/profiles/foot.lua b/profiles/foot.lua index 5efcc459c..959e774e4 100644 --- a/profiles/foot.lua +++ b/profiles/foot.lua @@ -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,