From 8e6b7766a14382d78d73b1ca1324433a32483d6e Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Thu, 4 Oct 2012 08:36:14 +0200 Subject: [PATCH] parse access tag hierachy in bike profile --- features/bicycle/access.feature | 13 +++++++++++++ features/bicycle/barrier.feature | 10 ---------- features/car/barrier.feature | 10 ---------- profiles/bicycle.lua | 28 +++++++++++++++++++--------- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/features/bicycle/access.feature b/features/bicycle/access.feature index 240f16590..f7313ddd9 100644 --- a/features/bicycle/access.feature +++ b/features/bicycle/access.feature @@ -8,18 +8,31 @@ Reference: http://wiki.openstreetmap.org/wiki/Key:access Scenario: Bike - Access tag hierachy Then routability should be | access | vehicle | bicycle | bothw | + | | | | x | | yes | | | x | | no | | | | + | | yes | | x | | yes | yes | | x | | no | yes | | x | + | | no | | | | yes | no | | | | no | no | | | + | | | yes | x | + | yes | | yes | x | + | no | | yes | x | + | | yes | yes | x | | yes | yes | yes | x | | no | yes | yes | x | + | | no | yes | x | | yes | no | yes | x | | no | no | yes | x | + | | | no | | + | yes | | no | | + | no | | no | | + | | yes | no | | | yes | yes | no | | | no | yes | no | | + | | no | no | | | yes | no | no | | | no | no | no | | diff --git a/features/bicycle/barrier.feature b/features/bicycle/barrier.feature index 8a52d9478..dd75dd2b6 100644 --- a/features/bicycle/barrier.feature +++ b/features/bicycle/barrier.feature @@ -24,25 +24,15 @@ Feature: Barriers | 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/barrier.feature b/features/car/barrier.feature index b031d84d8..1ae343237 100644 --- a/features/car/barrier.feature +++ b/features/car/barrier.feature @@ -24,25 +24,15 @@ Feature: Car - Barriers | 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/profiles/bicycle.lua b/profiles/bicycle.lua index f6de00484..3abe84dd1 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -1,9 +1,10 @@ -- Begin of globals 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_whitelist = { ["yes"] = true, ["permissive"] = true, ["designated"] = true } +access_tag_blacklist = { ["no"] = true, ["private"] = true, ["agricultural"] = true, ["forestery"] = true } access_tag_restricted = { ["destination"] = true, ["delivery"] = true } +access_tags_hierachy = { "bicycle", "vehicle", "access" } service_tag_restricted = { ["parking_aisle"] = true } ignore_in_grid = { ["ferry"] = true } @@ -41,9 +42,20 @@ u_turn_penalty = 20 -- End of globals +--find first tag in access hierachy which is set +function find_access_tag(source) + for i,v in ipairs(access_tags_hierachy) do + local tag = source.tags:Find(v) + if tag ~= '' then --and tag ~= "" then + return tag + end + end + return nil +end + function node_function (node) local barrier = node.tags:Find ("barrier") - local access = node.tags:Find ("access") + local access = find_access_tag(node) local traffic_signal = node.tags:Find("highway") -- flag node if it carries a traffic light @@ -52,20 +64,18 @@ function node_function (node) end -- parse access and barrier tags - if access ~= "" then + if access and access ~= "" then if access_tag_blacklist[access] then node.bollard = true else node.bollard = false end - elseif barrier ~= "" then + elseif barrier and barrier ~= "" then if barrier_whitelist[barrier] then node.bollard = false else node.bollard = true end - else - node.bollard = false end return 1 @@ -92,11 +102,11 @@ function way_function (way, numberOfNodesInWay) local duration = way.tags:Find("duration") local service = way.tags:Find("service") local area = way.tags:Find("area") - local access = way.tags:Find("access") + local access = find_access_tag(way) -- Check if we are allowed to access the way - if access_tag_blacklist[access] ~=nil and access_tag_blacklist[access] then + if access_tag_blacklist[access] then return 0 end