handle cycleway tags

This commit is contained in:
Emil Tin 2012-10-05 12:06:42 +02:00
parent 386d4c7e72
commit 2a89aeecd8
3 changed files with 85 additions and 55 deletions

View File

@ -25,32 +25,36 @@ Reference: http://wiki.openstreetmap.org/wiki/Key:cycleway
| residential | share_busway | x |
| residential | sharrow | x |
Scenario: Bike - Left/right side cycleways
Scenario: Bike - Left/right side cycleways on implied bidirectionals
Then routability should be
| highway | cycleway | cycleway:left | cycleway:right | forw | backw |
| primary | | | | x | x |
| motorway | | | | | |
| motorway | track | | | x | x |
| motorway | lane | | | x | x |
| motorway | oppposite | | | | x |
| motorway | opposite_track | | | | x |
| motorway | opposite_lane | | | | x |
| motorway | | track | | | x |
| motorway | | lane | | | x |
| motorway | | opposite_track | | x | |
| motorway | | opposite_lane | | x | |
| motorway | | | track | x | |
| motorway | | | lane | x | |
| motorway | | | opposite_track | | x |
| motorway | | | opposite_lane | | x |
| motorway | | track | track | x | x |
| motorway | | lane | lane | x | x |
| motorway | | opposite_track | opposite_track | x | x |
| motorway | | opposite_lane | opposite_lane | x | x |
| motorway | | track | opposite_track | | x |
| motorway | | lane | opposite_lane | | x |
| motorway | | opposite_track | track | x | |
| motorway | | opposite_lane | lane | x | |
| highway | cycleway | cycleway:left | cycleway:right | forw | backw |
| primary | | | | x | x |
| pirmary | track | | | x | x |
| pirmary | opposite | | | x | x |
| pirmary | | track | | x | x |
| pirmary | | opposite | | x | x |
| pirmary | | | track | x | x |
| pirmary | | | opposite | x | x |
| pirmary | | track | track | x | x |
| pirmary | | opposite | opposite | x | x |
| pirmary | | track | opposite | x | x |
| pirmary | | opposite | track | x | x |
Scenario: Bike - Left/right side cycleways on implied oneways
Then routability should be
| highway | cycleway | cycleway:left | cycleway:right | forw | backw |
| primary | | | | x | x |
| motorway | | | | | |
| motorway | track | | | x | |
| motorway | opposite | | | | x |
| motorway | | track | | | x |
| motorway | | opposite | | | x |
| motorway | | | track | x | |
| motorway | | | opposite | x | |
| motorway | | track | track | x | x |
| motorway | | opposite | opposite | x | x |
| motorway | | track | opposite | x | x |
| motorway | | opposite | track | x | x |
Scenario: Bike - Invalid cycleway tags
Then routability should be
@ -74,4 +78,4 @@ Reference: http://wiki.openstreetmap.org/wiki/Key:cycleway
| motorway | lane | yes | x |
| residential | lane | yes | x |
| footway | lane | yes | x |
| cycleway | lane | yes | x |
| cycleway | lane | yes | x |

View File

@ -18,7 +18,7 @@ Handle oneways streets, as defined at http://wiki.openstreetmap.org/wiki/OSM_tag
Scenario: Bike - Around the Block
Given the node map
| a | b |
| d | c |
| d | c |
And the ways
| nodes | oneway |
@ -47,18 +47,13 @@ Handle oneways streets, as defined at http://wiki.openstreetmap.org/wiki/OSM_tag
Scenario: Bike - Implied oneways
Then routability should be
| junction | forw | backw |
| | x | x |
| | x | x |
| | x | x |
| | x | x |
| | x | x |
| | x | x |
| | x | x |
| roundabout | x | |
| roundabout | x | |
| roundabout | x | |
| roundabout | x | |
| highway | bicycle | junction | forw | backw |
| | | | x | x |
| | | roundabout | x | |
| motorway | yes | | x | |
| motorway_link | yes | | x | |
| motorway | yes | roundabout | x | |
| motorway_link | yes | roundabout | x | |
Scenario: Bike - Overriding implied oneways
Then routability should be

View File

@ -1,10 +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, ["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" }
cycleway_tags = {["track"]=true,["lane"]=true,["opposite"]=true,["opposite_lane"]=true,["opposite_track"]=true,["share_busway"]=true,["sharrow"]=true,["shared"]=true }
service_tag_restricted = { ["parking_aisle"] = true }
ignore_in_grid = { ["ferry"] = true }
@ -31,7 +31,6 @@ speed_profile = {
["ferry"] = 5
}
take_minimum_of_speeds = true
obey_oneway = true
obey_bollards = false
@ -99,6 +98,8 @@ function way_function (way, numberOfNodesInWay)
local oneway = way.tags:Find("oneway")
local onewayClass = way.tags:Find("oneway:bicycle")
local cycleway = way.tags:Find("cycleway")
local cycleway_left = way.tags:Find("cycleway:left")
local cycleway_right = way.tags:Find("cycleway:right")
local duration = way.tags:Find("duration")
local service = way.tags:Find("service")
local area = way.tags:Find("area")
@ -139,6 +140,7 @@ function way_function (way, numberOfNodesInWay)
print("added "..route.." with speed "..way.speed)
end
-- Set the avg speed on the way if it is accessible by road class
if (speed_profile[highway] ~= nil and way.speed == -1 ) then
if (0 < maxspeed and not take_minimum_of_speeds) or (maxspeed == 0) then
@ -155,29 +157,58 @@ function way_function (way, numberOfNodesInWay)
way.speed = math.min(speed_profile["default"], maxspeed)
end
-- Set direction according to tags on way
if obey_oneway then
if onewayClass == "yes" or onewayClass == "1" or onewayClass == "true" then
way.direction = Way.oneway
elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then
way.direction = Way.bidirectional
elseif onewayClass == "-1" then
-- Set direction
way.direction = Way.bidirectional
local impliedOneway = false
if junction == "roundabout" or highway == "motorway_link" or highway == "motorway" then
way.direction = Way.oneway
impliedOneway = true
end
if onewayClass == "yes" or onewayClass == "1" or onewayClass == "true" then
way.direction = Way.oneway
elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then
way.direction = Way.bidirectional
elseif onewayClass == "-1" then
way.direction = Way.opposite
elseif oneway == "no" or oneway == "0" or oneway == "false" then
way.direction = Way.bidirectional
elseif cycleway and string.find(cycleway, "opposite") == 1 then
if impliedOneway then
way.direction = Way.opposite
elseif oneway == "no" or oneway == "0" or oneway == "false" then
else
way.direction = Way.bidirectional
elseif cycleway == "opposite" or cycleway == "opposite_track" or cycleway == "opposite_lane" then
way.direction = Way.bidirectional
elseif oneway == "-1" then
end
elseif cycleway_left and cycleway_tags[cycleway_left] and cycleway_right and cycleway_tags[cycleway_right] then
way.direction = Way.bidirectional
elseif cycleway_left and cycleway_tags[cycleway_left] then
if impliedOneway then
way.direction = Way.opposite
elseif oneway == "yes" or oneway == "1" or oneway == "true" or junction == "roundabout" or highway == "motorway_link" or highway == "motorway" then
else
way.direction = Way.bidirectional
end
elseif cycleway_right and cycleway_tags[cycleway_right] then
if impliedOneway then
way.direction = Way.oneway
else
way.direction = Way.bidirectional
end
else
way.direction = Way.bidirectional
elseif oneway == "-1" then
way.direction = Way.opposite
elseif oneway == "yes" or oneway == "1" or oneway == "true" then
way.direction = Way.oneway
end
-- Cycleways
if cycleway and cycleway_tags[cycleway] then
way.speed = speed_profile["cycleway"]
elseif cycleway_left and cycleway_tags[cycleway_left] then
way.speed = speed_profile["cycleway"]
elseif cycleway_right and cycleway_tags[cycleway_right] then
way.speed = speed_profile["cycleway"]
end
way.type = 1
return 1
end