fixes #695 for bike profile

This commit is contained in:
Dennis Luxen 2013-08-12 18:00:56 +02:00
parent e50b5202b8
commit aeba3aa209
2 changed files with 46 additions and 29 deletions

View File

@ -15,7 +15,7 @@ Feature: Bike - Max speed restrictions
| highway | maxspeed | bothw | | highway | maxspeed | bothw |
| residential | | 49s ~10% | | residential | | 49s ~10% |
| residential | 80 | 49s ~10% | | residential | 80 | 49s ~10% |
@todo @todo
Scenario: Bicycle - Maxspeed formats Scenario: Bicycle - Maxspeed formats
Then routability should be Then routability should be
@ -68,3 +68,20 @@ Feature: Bike - Max speed restrictions
| 1 | 10 | | run | snail | | 1 | 10 | | run | snail |
| 1 | | 10 | snail | run | | 1 | | 10 | snail | run |
| 1 | 5 | 10 | walk | run | | 1 | 5 | 10 | walk | run |
Scenario: Bike - Maxspeed should not allow routing on unroutable ways
Then routability should be
| highway | railway | access | maxspeed | maxspeed:forward | maxspeed:backward | bothw |
| primary | | | | | | x |
| secondary | | no | | | | |
| secondary | | no | 100 | | | |
| secondary | | no | | 100 | | |
| secondary | | no | | | 100 | |
| (nil) | train | | | | | |
| (nil) | train | | 100 | | | |
| (nil) | train | | | 100 | | |
| (nil) | train | | | | 100 | |
| runway | | | | | | |
| runway | | | 100 | | | |
| runway | | | | 100 | | |
| runway | | | | | 100 | |

View File

@ -14,7 +14,7 @@ default_speed = 15
walking_speed = 6 walking_speed = 6
bicycle_speeds = { bicycle_speeds = {
["cycleway"] = default_speed, ["cycleway"] = default_speed,
["primary"] = default_speed, ["primary"] = default_speed,
["primary_link"] = default_speed, ["primary_link"] = default_speed,
@ -33,13 +33,13 @@ bicycle_speeds = {
--["pedestrian"] = 12, --["pedestrian"] = 12,
} }
pedestrian_speeds = { pedestrian_speeds = {
["footway"] = walking_speed, ["footway"] = walking_speed,
["pedestrian"] = walking_speed, ["pedestrian"] = walking_speed,
["steps"] = 2 ["steps"] = 2
} }
railway_speeds = { railway_speeds = {
["train"] = 10, ["train"] = 10,
["railway"] = 10, ["railway"] = 10,
["subway"] = 10, ["subway"] = 10,
@ -48,24 +48,24 @@ railway_speeds = {
["tram"] = 10 ["tram"] = 10
} }
platform_speeds = { platform_speeds = {
["platform"] = walking_speed ["platform"] = walking_speed
} }
amenity_speeds = { amenity_speeds = {
["parking"] = 10, ["parking"] = 10,
["parking_entrance"] = 10 ["parking_entrance"] = 10
} }
man_made_speeds = { man_made_speeds = {
["pier"] = walking_speed ["pier"] = walking_speed
} }
route_speeds = { route_speeds = {
["ferry"] = 5 ["ferry"] = 5
} }
surface_speeds = { surface_speeds = {
["cobblestone:flattened"] = 10, ["cobblestone:flattened"] = 10,
["paving_stones"] = 10, ["paving_stones"] = 10,
["compacted"] = 10, ["compacted"] = 10,
@ -80,7 +80,7 @@ surface_speeds = {
["earth"] = 6, ["earth"] = 6,
["grass"] = 6, ["grass"] = 6,
["mud"] = 3, ["mud"] = 3,
["sand"] = 3 ["sand"] = 3
} }
take_minimum_of_speeds = true take_minimum_of_speeds = true
@ -96,7 +96,7 @@ turn_bias = 1.4
-- End of globals -- End of globals
function get_exceptions(vector) function get_exceptions(vector)
for i,v in ipairs(restriction_exception_tags) do for i,v in ipairs(restriction_exception_tags) do
vector:Add(v) vector:Add(v)
end end
end end
@ -105,12 +105,12 @@ function node_function (node)
local barrier = node.tags:Find ("barrier") local barrier = node.tags:Find ("barrier")
local access = Access.find_access_tag(node, access_tags_hierachy) local access = Access.find_access_tag(node, access_tags_hierachy)
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
if traffic_signal == "traffic_signals" then if traffic_signal == "traffic_signals" then
node.traffic_light = true node.traffic_light = true
end end
-- parse access and barrier tags -- parse access and barrier tags
if access and access ~= "" then if access and access ~= "" then
if access_tag_blacklist[access] then if access_tag_blacklist[access] then
@ -125,7 +125,7 @@ function node_function (node)
node.bollard = true node.bollard = true
end end
end end
return 1 return 1
end end
@ -137,21 +137,21 @@ function way_function (way)
local railway = way.tags:Find("railway") local railway = way.tags:Find("railway")
local amenity = way.tags:Find("amenity") local amenity = way.tags:Find("amenity")
local public_transport = way.tags:Find("public_transport") local public_transport = way.tags:Find("public_transport")
if (not highway or highway == '') and if (not highway or highway == '') and
(not route or route == '') and (not route or route == '') and
(not railway or railway=='') and (not railway or railway=='') and
(not amenity or amenity=='') and (not amenity or amenity=='') and
(not man_made or man_made=='') and (not man_made or man_made=='') and
(not public_transport or public_transport=='') (not public_transport or public_transport=='')
then then
return 0 return 0
end end
-- don't route on ways or railways that are still under construction -- don't route on ways or railways that are still under construction
if highway=='construction' or railway=='construction' then if highway=='construction' or railway=='construction' then
return 0 return 0
end end
-- access -- access
local access = Access.find_access_tag(way, access_tags_hierachy) local access = Access.find_access_tag(way, access_tags_hierachy)
if access_tag_blacklist[access] then if access_tag_blacklist[access] then
@ -178,7 +178,7 @@ function way_function (way)
local foot = way.tags:Find("foot") local foot = way.tags:Find("foot")
local surface = way.tags:Find("surface") local surface = way.tags:Find("surface")
-- name -- name
if "" ~= ref and "" ~= name then if "" ~= ref and "" ~= name then
way.name = name .. ' / ' .. ref way.name = name .. ' / ' .. ref
elseif "" ~= ref then elseif "" ~= ref then
@ -214,7 +214,7 @@ function way_function (way)
elseif railway and railway_speeds[railway] then elseif railway and railway_speeds[railway] then
-- railways -- railways
if access and access_tag_whitelist[access] then if access and access_tag_whitelist[access] then
way.speed = railway_speeds[railway] way.speed = railway_speeds[railway]
way.direction = Way.bidirectional way.direction = Way.bidirectional
end end
elseif amenity and amenity_speeds[amenity] then elseif amenity and amenity_speeds[amenity] then
@ -242,7 +242,7 @@ function way_function (way)
end end
end end
end end
-- direction -- direction
way.direction = Way.bidirectional way.direction = Way.bidirectional
local impliedOneway = false local impliedOneway = false
@ -250,7 +250,7 @@ function way_function (way)
way.direction = Way.oneway way.direction = Way.oneway
impliedOneway = true impliedOneway = true
end end
if onewayClass == "yes" or onewayClass == "1" or onewayClass == "true" then if onewayClass == "yes" or onewayClass == "1" or onewayClass == "true" then
way.direction = Way.oneway way.direction = Way.oneway
elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then
@ -284,7 +284,7 @@ function way_function (way)
elseif oneway == "yes" or oneway == "1" or oneway == "true" then elseif oneway == "yes" or oneway == "1" or oneway == "true" then
way.direction = Way.oneway way.direction = Way.oneway
end end
-- pushing bikes -- pushing bikes
if bicycle_speeds[highway] or pedestrian_speeds[highway] then if bicycle_speeds[highway] or pedestrian_speeds[highway] then
if foot ~= 'no' then if foot ~= 'no' then
@ -303,7 +303,7 @@ function way_function (way)
end end
end end
-- cycleways -- cycleways
if cycleway and cycleway_tags[cycleway] then if cycleway and cycleway_tags[cycleway] then
way.speed = bicycle_speeds["cycleway"] way.speed = bicycle_speeds["cycleway"]
@ -312,7 +312,7 @@ function way_function (way)
elseif cycleway_right and cycleway_tags[cycleway_right] then elseif cycleway_right and cycleway_tags[cycleway_right] then
way.speed = bicycle_speeds["cycleway"] way.speed = bicycle_speeds["cycleway"]
end end
-- surfaces -- surfaces
if surface then if surface then
surface_speed = surface_speeds[surface] surface_speed = surface_speeds[surface]
@ -331,7 +331,7 @@ function way_function (way)
end end
-- Override speed settings if explicit forward/backward maxspeeds are given -- Override speed settings if explicit forward/backward maxspeeds are given
if maxspeed_forward ~= nil and maxspeed_forward > 0 then if way.speed > 0 and maxspeed_forward ~= nil and maxspeed_forward > 0 then
if Way.bidirectional == way.direction then if Way.bidirectional == way.direction then
way.backward_speed = way.speed way.backward_speed = way.speed
end end
@ -342,7 +342,7 @@ function way_function (way)
end end
way.type = 1 way.type = 1
return 1 return 1
end end