2012-09-19 12:35:45 -04:00
|
|
|
-- Foot profile
|
|
|
|
|
|
|
|
-- Begin of globals
|
|
|
|
|
2012-11-02 04:10:19 -04:00
|
|
|
bollards_whitelist = { [""] = true, ["cattle_grid"] = true, ["border_control"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = true}
|
2012-09-19 12:35:45 -04:00
|
|
|
access_tag_whitelist = { ["yes"] = true, ["foot"] = 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 = { "foot" }
|
|
|
|
service_tag_restricted = { ["parking_aisle"] = true }
|
|
|
|
ignore_in_grid = { ["ferry"] = true }
|
2013-01-05 11:32:39 -05:00
|
|
|
restriction_exception_tags = { "foot" }
|
2012-09-19 12:35:45 -04:00
|
|
|
|
2013-09-07 05:16:45 -04:00
|
|
|
speed_profile = {
|
2012-09-19 12:35:45 -04:00
|
|
|
["primary"] = 5,
|
|
|
|
["primary_link"] = 5,
|
|
|
|
["secondary"] = 5,
|
|
|
|
["secondary_link"] = 5,
|
|
|
|
["tertiary"] = 5,
|
|
|
|
["tertiary_link"] = 5,
|
|
|
|
["unclassified"] = 5,
|
|
|
|
["residential"] = 5,
|
|
|
|
["road"] = 5,
|
|
|
|
["living_street"] = 5,
|
|
|
|
["service"] = 5,
|
|
|
|
["track"] = 5,
|
|
|
|
["path"] = 5,
|
|
|
|
["steps"] = 5,
|
|
|
|
["ferry"] = 5,
|
|
|
|
["pedestrian"] = 5,
|
|
|
|
["footway"] = 5,
|
|
|
|
["pier"] = 5,
|
|
|
|
["default"] = 5
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
take_minimum_of_speeds = true
|
2012-09-30 08:40:59 -04:00
|
|
|
obey_oneway = true
|
2012-09-19 12:35:45 -04:00
|
|
|
obey_bollards = false
|
|
|
|
use_restrictions = false
|
|
|
|
ignore_areas = true -- future feature
|
|
|
|
traffic_signal_penalty = 2
|
|
|
|
u_turn_penalty = 2
|
2013-02-11 04:05:53 -05:00
|
|
|
use_turn_restrictions = false
|
2012-09-19 12:35:45 -04:00
|
|
|
-- End of globals
|
|
|
|
|
2013-01-05 11:32:39 -05:00
|
|
|
function get_exceptions(vector)
|
2013-09-07 05:16:45 -04:00
|
|
|
for i,v in ipairs(restriction_exception_tags) do
|
2013-01-05 11:32:39 -05:00
|
|
|
vector:Add(v)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-09-19 12:35:45 -04:00
|
|
|
function node_function (node)
|
|
|
|
local barrier = node.tags:Find ("barrier")
|
|
|
|
local access = node.tags:Find ("access")
|
|
|
|
local traffic_signal = node.tags:Find("highway")
|
2013-09-07 05:16:45 -04:00
|
|
|
|
2012-09-19 12:35:45 -04:00
|
|
|
--flag node if it carries a traffic light
|
2013-09-07 05:16:45 -04:00
|
|
|
|
2012-09-19 12:35:45 -04:00
|
|
|
if traffic_signal == "traffic_signals" then
|
|
|
|
node.traffic_light = true;
|
|
|
|
end
|
2013-09-07 05:16:45 -04:00
|
|
|
|
2012-09-19 12:35:45 -04:00
|
|
|
if obey_bollards then
|
|
|
|
--flag node as unpassable if it black listed as unpassable
|
|
|
|
if access_tag_blacklist[barrier] then
|
|
|
|
node.bollard = true;
|
|
|
|
end
|
2013-09-07 05:16:45 -04:00
|
|
|
|
2012-09-19 12:35:45 -04:00
|
|
|
--reverse the previous flag if there is an access tag specifying entrance
|
|
|
|
if node.bollard and not bollards_whitelist[barrier] and not access_tag_whitelist[barrier] then
|
|
|
|
node.bollard = false;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
|
2013-02-27 11:36:44 -05:00
|
|
|
function way_function (way)
|
2012-09-19 12:35:45 -04:00
|
|
|
|
|
|
|
-- First, get the properties of each way that we come across
|
|
|
|
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 = parseMaxspeed(way.tags:Find ( "maxspeed") )
|
|
|
|
local man_made = way.tags:Find("man_made")
|
|
|
|
local barrier = way.tags:Find("barrier")
|
|
|
|
local oneway = way.tags:Find("oneway")
|
2012-09-30 08:40:59 -04:00
|
|
|
local onewayClass = way.tags:Find("oneway:foot")
|
2012-09-19 12:35:45 -04:00
|
|
|
local duration = way.tags:Find("duration")
|
|
|
|
local service = way.tags:Find("service")
|
|
|
|
local area = way.tags:Find("area")
|
|
|
|
local access = way.tags:Find("access")
|
|
|
|
|
|
|
|
-- Second parse the way according to these properties
|
|
|
|
|
|
|
|
if ignore_areas and ("yes" == area) then
|
|
|
|
return 0
|
|
|
|
end
|
2013-09-07 05:16:45 -04:00
|
|
|
|
2012-09-19 12:35:45 -04:00
|
|
|
-- Check if we are allowed to access the way
|
|
|
|
if access_tag_blacklist[access] ~=nil and access_tag_blacklist[access] then
|
|
|
|
return 0;
|
|
|
|
end
|
2013-09-07 05:16:45 -04:00
|
|
|
|
2012-09-19 12:35:45 -04:00
|
|
|
-- Check if our vehicle types are forbidden
|
2013-09-07 05:16:45 -04:00
|
|
|
for i,v in ipairs(access_tags) do
|
2012-09-19 12:35:45 -04:00
|
|
|
local mode_value = way.tags:Find(v)
|
|
|
|
if nil ~= mode_value and "no" == mode_value then
|
|
|
|
return 0;
|
|
|
|
end
|
|
|
|
end
|
2013-09-07 05:16:45 -04:00
|
|
|
|
|
|
|
|
|
|
|
-- Set the name that will be used for instructions
|
2012-09-19 12:35:45 -04:00
|
|
|
if "" ~= ref then
|
|
|
|
way.name = ref
|
|
|
|
elseif "" ~= name then
|
|
|
|
way.name = name
|
|
|
|
end
|
2013-09-07 05:16:45 -04:00
|
|
|
|
2012-09-19 12:35:45 -04:00
|
|
|
if "roundabout" == junction then
|
|
|
|
way.roundabout = true;
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Handling ferries and piers
|
|
|
|
|
|
|
|
if (speed_profile[route] ~= nil and speed_profile[route] > 0) or
|
2013-09-07 05:16:45 -04:00
|
|
|
(speed_profile[man_made] ~= nil and speed_profile[man_made] > 0)
|
2012-09-19 12:35:45 -04:00
|
|
|
then
|
|
|
|
if durationIsValid(duration) then
|
2013-09-07 05:16:45 -04:00
|
|
|
way.duration = math.max( parseDuration(duration), 1 );
|
2012-09-19 12:35:45 -04:00
|
|
|
end
|
|
|
|
way.direction = Way.bidirectional;
|
|
|
|
if speed_profile[route] ~= nil then
|
|
|
|
highway = route;
|
|
|
|
elseif speed_profile[man_made] ~= nil then
|
|
|
|
highway = man_made;
|
|
|
|
end
|
|
|
|
if not way.is_duration_set then
|
|
|
|
way.speed = speed_profile[highway]
|
|
|
|
end
|
2013-09-07 05:16:45 -04:00
|
|
|
|
2012-09-19 12:35:45 -04:00
|
|
|
end
|
2013-09-07 05:16:45 -04:00
|
|
|
|
2012-09-19 12:35:45 -04:00
|
|
|
-- Set the avg speed on the way if it is accessible by road class
|
2013-09-07 05:16:45 -04:00
|
|
|
if (speed_profile[highway] ~= nil and way.speed == -1 ) then
|
2013-02-04 05:15:06 -05:00
|
|
|
way.speed = speed_profile[highway]
|
2012-09-19 12:35:45 -04:00
|
|
|
end
|
2013-09-07 05:16:45 -04:00
|
|
|
|
2012-09-19 12:35:45 -04:00
|
|
|
-- Set the avg speed on ways that are marked accessible
|
|
|
|
if access_tag_whitelist[access] and way.speed == -1 then
|
|
|
|
if (0 < maxspeed and not take_minimum_of_speeds) or maxspeed == 0 then
|
|
|
|
maxspeed = math.huge
|
|
|
|
end
|
|
|
|
way.speed = math.min(speed_profile["default"], maxspeed)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Set access restriction flag if access is allowed under certain restrictions only
|
|
|
|
if access ~= "" and access_tag_restricted[access] then
|
|
|
|
way.is_access_restricted = true
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Set access restriction flag if service is allowed under certain restrictions only
|
|
|
|
if service ~= "" and service_tag_restricted[service] then
|
|
|
|
way.is_access_restricted = true
|
|
|
|
end
|
2013-09-07 05:16:45 -04:00
|
|
|
|
2012-09-19 12:35:45 -04:00
|
|
|
-- Set direction according to tags on way
|
|
|
|
if obey_oneway then
|
2012-09-30 08:40:59 -04:00
|
|
|
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
|
|
|
|
else
|
|
|
|
way.direction = Way.bidirectional
|
|
|
|
end
|
2012-09-19 12:35:45 -04:00
|
|
|
else
|
|
|
|
way.direction = Way.bidirectional
|
|
|
|
end
|
2013-09-07 05:16:45 -04:00
|
|
|
|
2012-09-19 12:35:45 -04:00
|
|
|
-- Override general direction settings of there is a specific one for our mode of travel
|
2013-09-07 05:16:45 -04:00
|
|
|
|
2012-09-19 12:35:45 -04:00
|
|
|
if ignore_in_grid[highway] ~= nil and ignore_in_grid[highway] then
|
|
|
|
way.ignore_in_grid = true
|
|
|
|
end
|
|
|
|
way.type = 1
|
|
|
|
return 1
|
|
|
|
end
|