refactored some parameter setting

This commit is contained in:
Dennis Luxen 2013-06-26 13:40:25 -04:00
parent 9d6bd91279
commit 48cb374d94
2 changed files with 89 additions and 90 deletions

View File

@ -70,7 +70,7 @@ function node_function (node)
--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
@ -90,33 +90,38 @@ end
function way_function (way) function way_function (way)
-- First, get the properties of each way that we come across -- we dont route over areas
local highway = way.tags:Find("highway") local area = way.tags:Find("area")
local name = way.tags:Find("name") if ignore_areas and ("yes" == area) then
local ref = way.tags:Find("ref") return 0
local junction = way.tags:Find("junction") end
local route = way.tags:Find("route")
local maxspeed = parse_maxspeed(way.tags:Find ( "maxspeed") ) -- check if oneway tag is unsupported
local maxspeed_forward = parse_maxspeed(way.tags:Find( "maxspeed:forward")) local oneway = way.tags:Find("oneway")
local maxspeed_backward = parse_maxspeed(way.tags:Find( "maxspeed:backward")) if "reversible" == oneway then
local barrier = way.tags:Find("barrier") return 0
local oneway = way.tags:Find("oneway") end
local cycleway = way.tags:Find("cycleway")
local duration = way.tags:Find("duration") -- Check if we are allowed to access the way
local service = way.tags:Find("service") local access = Access.find_access_tag(way, access_tags_hierachy)
local area = way.tags:Find("area") if access_tag_blacklist[access] then
local access = Access.find_access_tag(way, access_tags_hierachy) return 0
end
-- Second, parse the way according to these properties -- Second, parse the way according to these properties
local highway = way.tags:Find("highway")
local name = way.tags:Find("name")
local ref = way.tags:Find("ref")
local junction = way.tags:Find("junction")
local route = way.tags:Find("route")
local maxspeed = parse_maxspeed(way.tags:Find ( "maxspeed") )
local maxspeed_forward = parse_maxspeed(way.tags:Find( "maxspeed:forward"))
local maxspeed_backward = parse_maxspeed(way.tags:Find( "maxspeed:backward"))
local barrier = way.tags:Find("barrier")
local cycleway = way.tags:Find("cycleway")
local duration = way.tags:Find("duration")
local service = way.tags:Find("service")
if ignore_areas and ("yes" == area) then
return 0
end
-- Check if we are allowed to access the way
if access_tag_blacklist[access] then
return 0
end
-- Set the name that will be used for instructions -- Set the name that will be used for instructions
if "" ~= ref then if "" ~= ref then
@ -133,80 +138,75 @@ function way_function (way)
-- Handling ferries and piers -- Handling ferries and piers
if (speed_profile[route] ~= nil and speed_profile[route] > 0) then if (speed_profile[route] ~= nil and speed_profile[route] > 0) then
if durationIsValid(duration) then if durationIsValid(duration) then
way.duration = math.max( parseDuration(duration), 1 ); way.duration = math.max( parseDuration(duration), 1 );
end end
way.direction = Way.bidirectional way.direction = Way.bidirectional
if speed_profile[route] ~= nil then if speed_profile[route] ~= nil then
highway = route; highway = route;
end end
if tonumber(way.duration) < 0 then if tonumber(way.duration) < 0 then
way.speed = speed_profile[highway] way.speed = speed_profile[highway]
end end
end end
-- Set the avg speed on the way if it is accessible by road class -- 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 (speed_profile[highway] ~= nil and way.speed == -1 ) then
if maxspeed > speed_profile[highway] then if maxspeed > speed_profile[highway] then
way.speed = maxspeed way.speed = maxspeed
else else
if 0 == maxspeed then if 0 == maxspeed then
maxspeed = math.huge maxspeed = math.huge
end end
way.speed = math.min(speed_profile[highway], maxspeed) way.speed = math.min(speed_profile[highway], maxspeed)
end end
end end
-- Set the avg speed on ways that are marked accessible -- Set the avg speed on ways that are marked accessible
if "" ~= highway and access_tag_whitelist[access] and way.speed == -1 then if "" ~= highway and access_tag_whitelist[access] and way.speed == -1 then
if 0 == maxspeed then if 0 == maxspeed then
maxspeed = math.huge maxspeed = math.huge
end
way.speed = math.min(speed_profile["default"], maxspeed)
end end
way.speed = math.min(speed_profile["default"], maxspeed)
end
-- Set access restriction flag if access is allowed under certain restrictions only -- Set access restriction flag if access is allowed under certain restrictions only
if access ~= "" and access_tag_restricted[access] then if access ~= "" and access_tag_restricted[access] then
way.is_access_restricted = true way.is_access_restricted = true
end end
-- Set access restriction flag if service is allowed under certain restrictions only -- Set access restriction flag if service is allowed under certain restrictions only
if service ~= "" and service_tag_restricted[service] then if service ~= "" and service_tag_restricted[service] then
way.is_access_restricted = true way.is_access_restricted = true
end end
-- Set direction according to tags on way -- Set direction according to tags on way
if obey_oneway then way.direction = Way.bidirectional
if oneway == "no" or oneway == "0" or oneway == "false" then if obey_oneway then
way.direction = Way.bidirectional if oneway == "-1" then
elseif oneway == "-1" then
way.direction = Way.opposite way.direction = Way.opposite
elseif oneway == "yes" or oneway == "1" or oneway == "true" or junction == "roundabout" or highway == "motorway_link" or highway == "motorway" then elseif oneway == "yes" or oneway == "1" or oneway == "true" or junction == "roundabout" or highway == "motorway_link" or highway == "motorway" then
way.direction = Way.oneway way.direction = Way.oneway
else
way.direction = Way.bidirectional
end
else
way.direction = Way.bidirectional
end 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 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
way.speed = maxspeed_forward
end
if maxspeed_backward ~= nil and maxspeed_backward > 0 then
way.backward_speed = maxspeed_backward
end end
way.speed = maxspeed_forward
end
if maxspeed_backward ~= nil and maxspeed_backward > 0 then
way.backward_speed = maxspeed_backward
end
-- Override general direction settings of there is a specific one for our mode of travel -- Override general direction settings of there is a specific one for our mode of travel
if ignore_in_grid[highway] ~= nil and ignore_in_grid[highway] then
if ignore_in_grid[highway] ~= nil and ignore_in_grid[highway] then
way.ignore_in_grid = true way.ignore_in_grid = true
end end
way.type = 1
way.type = 1
return 1 return 1
end end

View File

@ -4,8 +4,7 @@ module "Access"
function find_access_tag(source,access_tags_hierachy) function find_access_tag(source,access_tags_hierachy)
for i,v in ipairs(access_tags_hierachy) do for i,v in ipairs(access_tags_hierachy) do
local tag = source.tags:Find(v) if source.tags:Find(v) ~= '' then
if tag ~= '' then
return tag return tag
end end
end end