2012-09-19 12:35:45 -04:00
|
|
|
-- Foot profile
|
|
|
|
|
2015-05-01 14:06:45 -04:00
|
|
|
local find_access_tag = require("lib/access").find_access_tag
|
2012-09-19 12:35:45 -04:00
|
|
|
|
2015-05-01 14:06:45 -04:00
|
|
|
-- Begin of globals
|
2015-09-07 06:20:50 -04:00
|
|
|
barrier_whitelist = { [""] = true, ["cycle_barrier"] = true, ["bollard"] = true, ["entrance"] = true, ["cattle_grid"] = true, ["border_control"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = true, ["no"] = true, ["block"] = true}
|
2012-09-19 12:35:45 -04:00
|
|
|
access_tag_whitelist = { ["yes"] = true, ["foot"] = true, ["permissive"] = true, ["designated"] = true }
|
2016-04-04 05:49:40 -04:00
|
|
|
access_tag_blacklist = { ["no"] = true, ["private"] = true, ["agricultural"] = true, ["forestry"] = true, ["delivery"] = true }
|
2016-04-04 05:09:13 -04:00
|
|
|
access_tags_hierarchy = { "foot", "access" }
|
2016-09-09 06:34:04 -04:00
|
|
|
restrictions = { "foot" }
|
2012-09-19 12:35:45 -04:00
|
|
|
|
2013-09-08 16:51:44 -04:00
|
|
|
walking_speed = 5
|
|
|
|
|
|
|
|
speeds = {
|
|
|
|
["primary"] = walking_speed,
|
|
|
|
["primary_link"] = walking_speed,
|
|
|
|
["secondary"] = walking_speed,
|
|
|
|
["secondary_link"] = walking_speed,
|
|
|
|
["tertiary"] = walking_speed,
|
|
|
|
["tertiary_link"] = walking_speed,
|
|
|
|
["unclassified"] = walking_speed,
|
|
|
|
["residential"] = walking_speed,
|
|
|
|
["road"] = walking_speed,
|
|
|
|
["living_street"] = walking_speed,
|
|
|
|
["service"] = walking_speed,
|
|
|
|
["track"] = walking_speed,
|
|
|
|
["path"] = walking_speed,
|
|
|
|
["steps"] = walking_speed,
|
|
|
|
["pedestrian"] = walking_speed,
|
|
|
|
["footway"] = walking_speed,
|
|
|
|
["pier"] = walking_speed,
|
|
|
|
["default"] = walking_speed
|
2012-09-19 12:35:45 -04:00
|
|
|
}
|
|
|
|
|
2013-09-08 16:51:44 -04:00
|
|
|
route_speeds = {
|
2015-05-29 14:48:04 -04:00
|
|
|
["ferry"] = 5
|
2013-09-08 16:51:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
platform_speeds = {
|
2015-05-29 14:48:04 -04:00
|
|
|
["platform"] = walking_speed
|
2013-09-08 16:51:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
amenity_speeds = {
|
2015-05-29 14:48:04 -04:00
|
|
|
["parking"] = walking_speed,
|
|
|
|
["parking_entrance"] = walking_speed
|
2013-09-08 16:51:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
man_made_speeds = {
|
2015-05-29 14:48:04 -04:00
|
|
|
["pier"] = walking_speed
|
2013-09-08 16:51:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
surface_speeds = {
|
2015-05-29 14:48:04 -04:00
|
|
|
["fine_gravel"] = walking_speed*0.75,
|
|
|
|
["gravel"] = walking_speed*0.75,
|
2015-06-09 23:16:58 -04:00
|
|
|
["pebblestone"] = walking_speed*0.75,
|
2015-05-29 14:48:04 -04:00
|
|
|
["mud"] = walking_speed*0.5,
|
|
|
|
["sand"] = walking_speed*0.5
|
2013-09-08 16:51:44 -04:00
|
|
|
}
|
2012-09-19 12:35:45 -04:00
|
|
|
|
2015-05-29 14:45:34 -04:00
|
|
|
leisure_speeds = {
|
|
|
|
["track"] = walking_speed
|
|
|
|
}
|
|
|
|
|
2016-04-12 12:47:00 -04:00
|
|
|
properties.traffic_signal_penalty = 2
|
|
|
|
properties.u_turn_penalty = 2
|
2016-11-01 17:13:10 -04:00
|
|
|
properties.max_speed_for_map_matching = 40/3.6 -- kmph -> m/s
|
2016-04-12 12:47:00 -04:00
|
|
|
properties.use_turn_restrictions = false
|
|
|
|
properties.continue_straight_at_waypoint = false
|
2016-03-21 17:42:47 -04:00
|
|
|
|
2016-09-09 06:34:04 -04:00
|
|
|
function get_restrictions(vector)
|
|
|
|
for i,v in ipairs(restrictions) do
|
2015-05-29 14:48:04 -04:00
|
|
|
vector:Add(v)
|
|
|
|
end
|
2013-01-05 11:32:39 -05:00
|
|
|
end
|
|
|
|
|
2014-08-27 12:43:07 -04:00
|
|
|
function node_function (node, result)
|
2015-05-29 14:48:04 -04:00
|
|
|
local barrier = node:get_value_by_key("barrier")
|
2016-04-04 05:09:13 -04:00
|
|
|
local access = find_access_tag(node, access_tags_hierarchy)
|
2015-05-29 14:48:04 -04:00
|
|
|
local traffic_signal = node:get_value_by_key("highway")
|
2013-09-07 05:16:45 -04:00
|
|
|
|
2015-05-29 14:48:04 -04:00
|
|
|
-- flag node if it carries a traffic light
|
|
|
|
if traffic_signal and traffic_signal == "traffic_signals" then
|
2015-07-09 15:24:07 -04:00
|
|
|
result.traffic_lights = true
|
2015-05-29 14:48:04 -04:00
|
|
|
end
|
2013-12-06 06:06:51 -05:00
|
|
|
|
2015-05-29 14:48:04 -04:00
|
|
|
-- parse access and barrier tags
|
|
|
|
if access and access ~= "" then
|
2013-09-08 16:51:44 -04:00
|
|
|
if access_tag_blacklist[access] then
|
2015-05-29 14:48:04 -04:00
|
|
|
result.barrier = true
|
|
|
|
else
|
|
|
|
result.barrier = false
|
|
|
|
end
|
|
|
|
elseif barrier and barrier ~= "" then
|
|
|
|
if barrier_whitelist[barrier] then
|
|
|
|
result.barrier = false
|
|
|
|
else
|
|
|
|
result.barrier = true
|
2013-09-08 16:51:44 -04:00
|
|
|
end
|
2015-05-29 14:48:04 -04:00
|
|
|
end
|
2013-12-06 06:06:51 -05:00
|
|
|
|
2015-05-29 14:48:04 -04:00
|
|
|
return 1
|
|
|
|
end
|
|
|
|
|
|
|
|
function way_function (way, result)
|
|
|
|
-- initial routability check, filters out buildings, boundaries, etc
|
|
|
|
local highway = way:get_value_by_key("highway")
|
2015-05-29 14:45:34 -04:00
|
|
|
local leisure = way:get_value_by_key("leisure")
|
2015-05-29 14:48:04 -04:00
|
|
|
local route = way:get_value_by_key("route")
|
|
|
|
local man_made = way:get_value_by_key("man_made")
|
|
|
|
local railway = way:get_value_by_key("railway")
|
|
|
|
local amenity = way:get_value_by_key("amenity")
|
|
|
|
local public_transport = way:get_value_by_key("public_transport")
|
|
|
|
if (not highway or highway == '') and
|
2015-05-29 14:45:34 -04:00
|
|
|
(not leisure or leisure == '') and
|
2015-05-29 14:48:04 -04:00
|
|
|
(not route or route == '') and
|
|
|
|
(not railway or railway=='') and
|
|
|
|
(not amenity or amenity=='') and
|
|
|
|
(not man_made or man_made=='') and
|
|
|
|
(not public_transport or public_transport=='')
|
|
|
|
then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
-- don't route on ways that are still under construction
|
|
|
|
if highway=='construction' then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
-- access
|
2016-04-04 05:09:13 -04:00
|
|
|
local access = find_access_tag(way, access_tags_hierarchy)
|
2015-05-29 14:48:04 -04:00
|
|
|
if access_tag_blacklist[access] then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2016-02-25 14:03:49 -05:00
|
|
|
result.forward_mode = mode.walking
|
|
|
|
result.backward_mode = mode.walking
|
|
|
|
|
2015-05-29 14:48:04 -04:00
|
|
|
local name = way:get_value_by_key("name")
|
|
|
|
local ref = way:get_value_by_key("ref")
|
|
|
|
local junction = way:get_value_by_key("junction")
|
|
|
|
local onewayClass = way:get_value_by_key("oneway:foot")
|
|
|
|
local duration = way:get_value_by_key("duration")
|
|
|
|
local service = way:get_value_by_key("service")
|
|
|
|
local area = way:get_value_by_key("area")
|
|
|
|
local foot = way:get_value_by_key("foot")
|
|
|
|
local surface = way:get_value_by_key("surface")
|
|
|
|
|
|
|
|
-- name
|
2016-09-05 09:01:51 -04:00
|
|
|
if name and "" ~= name then
|
2015-05-29 14:48:04 -04:00
|
|
|
result.name = name
|
|
|
|
end
|
2016-09-05 09:01:51 -04:00
|
|
|
if ref and "" ~= ref then
|
|
|
|
result.ref = ref
|
|
|
|
end
|
2013-09-07 05:16:45 -04:00
|
|
|
|
2016-11-24 07:08:49 -05:00
|
|
|
-- roundabouts
|
2016-06-02 09:03:28 -04:00
|
|
|
if "roundabout" == junction then
|
2015-09-02 06:23:26 -04:00
|
|
|
result.roundabout = true
|
2015-05-29 14:48:04 -04:00
|
|
|
end
|
2016-11-24 07:08:49 -05:00
|
|
|
if "circular" == junction then
|
|
|
|
result.circular = true
|
|
|
|
end
|
2012-09-19 12:35:45 -04:00
|
|
|
|
2013-09-08 16:51:44 -04:00
|
|
|
-- speed
|
2015-05-29 14:48:04 -04:00
|
|
|
if route_speeds[route] then
|
|
|
|
-- ferries (doesn't cover routes tagged using relations)
|
|
|
|
result.ignore_in_grid = true
|
|
|
|
if duration and durationIsValid(duration) then
|
|
|
|
result.duration = math.max( 1, parseDuration(duration) )
|
|
|
|
else
|
|
|
|
result.forward_speed = route_speeds[route]
|
|
|
|
result.backward_speed = route_speeds[route]
|
|
|
|
end
|
2016-02-25 14:03:49 -05:00
|
|
|
result.forward_mode = mode.ferry
|
|
|
|
result.backward_mode = mode.ferry
|
2015-05-29 14:48:04 -04:00
|
|
|
elseif railway and platform_speeds[railway] then
|
|
|
|
-- railway platforms (old tagging scheme)
|
|
|
|
result.forward_speed = platform_speeds[railway]
|
|
|
|
result.backward_speed = platform_speeds[railway]
|
|
|
|
elseif platform_speeds[public_transport] then
|
|
|
|
-- public_transport platforms (new tagging platform)
|
|
|
|
result.forward_speed = platform_speeds[public_transport]
|
|
|
|
result.backward_speed = platform_speeds[public_transport]
|
|
|
|
elseif amenity and amenity_speeds[amenity] then
|
|
|
|
-- parking areas
|
|
|
|
result.forward_speed = amenity_speeds[amenity]
|
|
|
|
result.backward_speed = amenity_speeds[amenity]
|
2015-05-29 14:45:34 -04:00
|
|
|
elseif leisure and leisure_speeds[leisure] then
|
|
|
|
-- running tracks
|
|
|
|
result.forward_speed = leisure_speeds[leisure]
|
|
|
|
result.backward_speed = leisure_speeds[leisure]
|
2015-05-29 14:48:04 -04:00
|
|
|
elseif speeds[highway] then
|
|
|
|
-- regular ways
|
|
|
|
result.forward_speed = speeds[highway]
|
|
|
|
result.backward_speed = speeds[highway]
|
|
|
|
elseif access and access_tag_whitelist[access] then
|
|
|
|
-- unknown way, but valid access tag
|
|
|
|
result.forward_speed = walking_speed
|
|
|
|
result.backward_speed = walking_speed
|
|
|
|
end
|
|
|
|
|
|
|
|
-- oneway
|
|
|
|
if onewayClass == "yes" or onewayClass == "1" or onewayClass == "true" then
|
2016-02-25 14:03:49 -05:00
|
|
|
result.backward_mode = mode.inaccessible
|
2015-05-29 14:48:04 -04:00
|
|
|
elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then
|
|
|
|
-- nothing to do
|
|
|
|
elseif onewayClass == "-1" then
|
2016-02-25 14:03:49 -05:00
|
|
|
result.forward_mode = mode.inaccessible
|
2015-05-29 14:48:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
-- surfaces
|
|
|
|
if surface then
|
|
|
|
surface_speed = surface_speeds[surface]
|
|
|
|
if surface_speed then
|
|
|
|
result.forward_speed = math.min(result.forward_speed, surface_speed)
|
|
|
|
result.backward_speed = math.min(result.backward_speed, surface_speed)
|
2013-09-08 16:51:44 -04:00
|
|
|
end
|
2015-05-29 14:48:04 -04:00
|
|
|
end
|
2012-09-19 12:35:45 -04:00
|
|
|
end
|