parse access tag hierachy in bike profile
This commit is contained in:
parent
c1a08af00d
commit
8e6b7766a1
@ -8,18 +8,31 @@ Reference: http://wiki.openstreetmap.org/wiki/Key:access
|
|||||||
Scenario: Bike - Access tag hierachy
|
Scenario: Bike - Access tag hierachy
|
||||||
Then routability should be
|
Then routability should be
|
||||||
| access | vehicle | bicycle | bothw |
|
| access | vehicle | bicycle | bothw |
|
||||||
|
| | | | x |
|
||||||
| yes | | | x |
|
| yes | | | x |
|
||||||
| no | | | |
|
| no | | | |
|
||||||
|
| | yes | | x |
|
||||||
| yes | yes | | x |
|
| yes | yes | | x |
|
||||||
| no | yes | | x |
|
| no | yes | | x |
|
||||||
|
| | no | | |
|
||||||
| yes | no | | |
|
| yes | no | | |
|
||||||
| no | no | | |
|
| no | no | | |
|
||||||
|
| | | yes | x |
|
||||||
|
| yes | | yes | x |
|
||||||
|
| no | | yes | x |
|
||||||
|
| | yes | yes | x |
|
||||||
| yes | yes | yes | x |
|
| yes | yes | yes | x |
|
||||||
| no | yes | yes | x |
|
| no | yes | yes | x |
|
||||||
|
| | no | yes | x |
|
||||||
| yes | no | yes | x |
|
| yes | no | yes | x |
|
||||||
| no | no | yes | x |
|
| no | no | yes | x |
|
||||||
|
| | | no | |
|
||||||
|
| yes | | no | |
|
||||||
|
| no | | no | |
|
||||||
|
| | yes | no | |
|
||||||
| yes | yes | no | |
|
| yes | yes | no | |
|
||||||
| no | yes | no | |
|
| no | yes | no | |
|
||||||
|
| | no | no | |
|
||||||
| yes | no | no | |
|
| yes | no | no | |
|
||||||
| no | no | no | |
|
| no | no | no | |
|
||||||
|
|
||||||
|
@ -24,25 +24,15 @@ Feature: Barriers
|
|||||||
| node/barrier | node/access | bothw |
|
| node/barrier | node/access | bothw |
|
||||||
| bollard | | x |
|
| bollard | | x |
|
||||||
| bollard | yes | x |
|
| bollard | yes | x |
|
||||||
| bollard | bicycle | x |
|
|
||||||
| bollard | vehicle | x |
|
|
||||||
| bollard | motorcar | x |
|
|
||||||
| bollard | motor_vehicle | x |
|
|
||||||
| bollard | permissive | x |
|
| bollard | permissive | x |
|
||||||
| bollard | designated | x |
|
| bollard | designated | x |
|
||||||
| bollard | no | |
|
| bollard | no | |
|
||||||
| bollard | foot | |
|
|
||||||
| bollard | private | |
|
| bollard | private | |
|
||||||
| bollard | agricultural | |
|
| bollard | agricultural | |
|
||||||
| wall | | |
|
| wall | | |
|
||||||
| wall | yes | x |
|
| wall | yes | x |
|
||||||
| wall | bicycle | x |
|
|
||||||
| wall | vehicle | x |
|
|
||||||
| wall | motorcar | x |
|
|
||||||
| wall | motor_vehicle | x |
|
|
||||||
| wall | permissive | x |
|
| wall | permissive | x |
|
||||||
| wall | designated | x |
|
| wall | designated | x |
|
||||||
| wall | no | |
|
| wall | no | |
|
||||||
| wall | foot | |
|
|
||||||
| wall | private | |
|
| wall | private | |
|
||||||
| wall | agricultural | |
|
| wall | agricultural | |
|
||||||
|
@ -24,25 +24,15 @@ Feature: Car - Barriers
|
|||||||
| node/barrier | node/access | bothw |
|
| node/barrier | node/access | bothw |
|
||||||
| gate | | x |
|
| gate | | x |
|
||||||
| gate | yes | x |
|
| gate | yes | x |
|
||||||
| gate | vehicle | x |
|
|
||||||
| gate | motorcar | x |
|
|
||||||
| gate | motor_vehicle | x |
|
|
||||||
| gate | permissive | x |
|
| gate | permissive | x |
|
||||||
| gate | designated | x |
|
| gate | designated | x |
|
||||||
| gate | no | |
|
| gate | no | |
|
||||||
| gate | foot | |
|
|
||||||
| gate | bicycle | |
|
|
||||||
| gate | private | |
|
| gate | private | |
|
||||||
| gate | agricultural | |
|
| gate | agricultural | |
|
||||||
| wall | | |
|
| wall | | |
|
||||||
| wall | yes | x |
|
| wall | yes | x |
|
||||||
| wall | vehicle | x |
|
|
||||||
| wall | motorcar | x |
|
|
||||||
| wall | motor_vehicle | x |
|
|
||||||
| wall | permissive | x |
|
| wall | permissive | x |
|
||||||
| wall | designated | x |
|
| wall | designated | x |
|
||||||
| wall | no | |
|
| wall | no | |
|
||||||
| wall | foot | |
|
|
||||||
| wall | bicycle | |
|
|
||||||
| wall | private | |
|
| wall | private | |
|
||||||
| wall | agricultural | |
|
| wall | agricultural | |
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
-- Begin of globals
|
-- 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}
|
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_whitelist = { ["yes"] = true, ["permissive"] = true, ["designated"] = true }
|
||||||
access_tag_blacklist = { ["no"] = true, ["foot"] = true, ["private"] = true, ["agricultural"] = true, ["forestery"] = true }
|
access_tag_blacklist = { ["no"] = true, ["private"] = true, ["agricultural"] = true, ["forestery"] = true }
|
||||||
access_tag_restricted = { ["destination"] = true, ["delivery"] = true }
|
access_tag_restricted = { ["destination"] = true, ["delivery"] = true }
|
||||||
|
access_tags_hierachy = { "bicycle", "vehicle", "access" }
|
||||||
service_tag_restricted = { ["parking_aisle"] = true }
|
service_tag_restricted = { ["parking_aisle"] = true }
|
||||||
ignore_in_grid = { ["ferry"] = true }
|
ignore_in_grid = { ["ferry"] = true }
|
||||||
|
|
||||||
@ -41,9 +42,20 @@ u_turn_penalty = 20
|
|||||||
|
|
||||||
-- End of globals
|
-- 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)
|
function node_function (node)
|
||||||
local barrier = node.tags:Find ("barrier")
|
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")
|
local traffic_signal = node.tags:Find("highway")
|
||||||
|
|
||||||
-- flag node if it carries a traffic light
|
-- flag node if it carries a traffic light
|
||||||
@ -52,20 +64,18 @@ function node_function (node)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- parse access and barrier tags
|
-- parse access and barrier tags
|
||||||
if access ~= "" then
|
if access and access ~= "" then
|
||||||
if access_tag_blacklist[access] then
|
if access_tag_blacklist[access] then
|
||||||
node.bollard = true
|
node.bollard = true
|
||||||
else
|
else
|
||||||
node.bollard = false
|
node.bollard = false
|
||||||
end
|
end
|
||||||
elseif barrier ~= "" then
|
elseif barrier and barrier ~= "" then
|
||||||
if barrier_whitelist[barrier] then
|
if barrier_whitelist[barrier] then
|
||||||
node.bollard = false
|
node.bollard = false
|
||||||
else
|
else
|
||||||
node.bollard = true
|
node.bollard = true
|
||||||
end
|
end
|
||||||
else
|
|
||||||
node.bollard = false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
@ -92,11 +102,11 @@ function way_function (way, numberOfNodesInWay)
|
|||||||
local duration = way.tags:Find("duration")
|
local duration = way.tags:Find("duration")
|
||||||
local service = way.tags:Find("service")
|
local service = way.tags:Find("service")
|
||||||
local area = way.tags:Find("area")
|
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
|
-- 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
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user