Merge branch 'develop'
This commit is contained in:
+116
-118
@@ -125,42 +125,40 @@ function get_exceptions(vector)
|
||||
end
|
||||
end
|
||||
|
||||
function node_function (node)
|
||||
local barrier = node.tags:Find ("barrier")
|
||||
function node_function (node, result)
|
||||
local barrier = node:get_value_by_key("barrier")
|
||||
local access = Access.find_access_tag(node, access_tags_hierachy)
|
||||
local traffic_signal = node.tags:Find("highway")
|
||||
local traffic_signal = node:get_value_by_key("highway")
|
||||
|
||||
-- flag node if it carries a traffic light
|
||||
if traffic_signal == "traffic_signals" then
|
||||
node.traffic_light = true
|
||||
if traffic_signal and traffic_signal == "traffic_signals" then
|
||||
result.traffic_lights = true
|
||||
end
|
||||
|
||||
-- parse access and barrier tags
|
||||
if access and access ~= "" then
|
||||
if access_tag_blacklist[access] then
|
||||
node.bollard = true
|
||||
result.barrier = true
|
||||
else
|
||||
node.bollard = false
|
||||
result.barrier = false
|
||||
end
|
||||
elseif barrier and barrier ~= "" then
|
||||
if barrier_whitelist[barrier] then
|
||||
node.bollard = false
|
||||
result.barrier = false
|
||||
else
|
||||
node.bollard = true
|
||||
result.barrier = true
|
||||
end
|
||||
end
|
||||
|
||||
-- return 1
|
||||
end
|
||||
|
||||
function way_function (way)
|
||||
function way_function (way, result)
|
||||
-- initial routability check, filters out buildings, boundaries, etc
|
||||
local highway = way.tags:Find("highway")
|
||||
local route = way.tags:Find("route")
|
||||
local man_made = way.tags:Find("man_made")
|
||||
local railway = way.tags:Find("railway")
|
||||
local amenity = way.tags:Find("amenity")
|
||||
local public_transport = way.tags:Find("public_transport")
|
||||
local highway = way:get_value_by_key("highway")
|
||||
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
|
||||
(not route or route == '') and
|
||||
(not railway or railway=='') and
|
||||
@@ -178,117 +176,117 @@ function way_function (way)
|
||||
|
||||
-- access
|
||||
local access = Access.find_access_tag(way, access_tags_hierachy)
|
||||
if access_tag_blacklist[access] then
|
||||
if access and access_tag_blacklist[access] then
|
||||
return
|
||||
end
|
||||
|
||||
-- other tags
|
||||
local name = way.tags:Find("name")
|
||||
local ref = way.tags:Find("ref")
|
||||
local junction = way.tags:Find("junction")
|
||||
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 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")
|
||||
local foot = way.tags:Find("foot")
|
||||
local surface = way.tags:Find("surface")
|
||||
local bicycle = way.tags:Find("bicycle")
|
||||
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 maxspeed = parse_maxspeed(way:get_value_by_key ( "maxspeed") )
|
||||
local maxspeed_forward = parse_maxspeed(way:get_value_by_key( "maxspeed:forward"))
|
||||
local maxspeed_backward = parse_maxspeed(way:get_value_by_key( "maxspeed:backward"))
|
||||
local barrier = way:get_value_by_key("barrier")
|
||||
local oneway = way:get_value_by_key("oneway")
|
||||
local onewayClass = way:get_value_by_key("oneway:bicycle")
|
||||
local cycleway = way:get_value_by_key("cycleway")
|
||||
local cycleway_left = way:get_value_by_key("cycleway:left")
|
||||
local cycleway_right = way:get_value_by_key("cycleway:right")
|
||||
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")
|
||||
local bicycle = way:get_value_by_key("bicycle")
|
||||
|
||||
-- name
|
||||
if "" ~= ref and "" ~= name then
|
||||
way.name = name .. ' / ' .. ref
|
||||
elseif "" ~= ref then
|
||||
way.name = ref
|
||||
elseif "" ~= name then
|
||||
way.name = name
|
||||
else
|
||||
if ref and "" ~= ref and name and "" ~= name then
|
||||
result.name = name .. ' / ' .. ref
|
||||
elseif ref and "" ~= ref then
|
||||
result.name = ref
|
||||
elseif name and "" ~= name then
|
||||
result.name = name
|
||||
elseif highway then
|
||||
-- if no name exists, use way type
|
||||
-- this encoding scheme is excepted to be a temporary solution
|
||||
way.name = "{highway:"..highway.."}"
|
||||
result.name = "{highway:"..highway.."}"
|
||||
end
|
||||
|
||||
-- roundabout handling
|
||||
if "roundabout" == junction then
|
||||
way.roundabout = true;
|
||||
if junction and "roundabout" == junction then
|
||||
result.roundabout = true;
|
||||
end
|
||||
|
||||
-- speed
|
||||
if route_speeds[route] then
|
||||
-- ferries (doesn't cover routes tagged using relations)
|
||||
way.forward_mode = mode_ferry
|
||||
way.backward_mode = mode_ferry
|
||||
way.ignore_in_grid = true
|
||||
if durationIsValid(duration) then
|
||||
way.duration = math.max( 1, parseDuration(duration) )
|
||||
result.forward_mode = mode_ferry
|
||||
result.backward_mode = mode_ferry
|
||||
result.ignore_in_grid = true
|
||||
if duration and durationIsValid(duration) then
|
||||
result.duration = math.max( 1, parseDuration(duration) )
|
||||
else
|
||||
way.forward_speed = route_speeds[route]
|
||||
way.backward_speed = route_speeds[route]
|
||||
result.forward_speed = route_speeds[route]
|
||||
result.backward_speed = route_speeds[route]
|
||||
end
|
||||
elseif railway and platform_speeds[railway] then
|
||||
-- railway platforms (old tagging scheme)
|
||||
way.forward_speed = platform_speeds[railway]
|
||||
way.backward_speed = platform_speeds[railway]
|
||||
result.forward_speed = platform_speeds[railway]
|
||||
result.backward_speed = platform_speeds[railway]
|
||||
elseif platform_speeds[public_transport] then
|
||||
-- public_transport platforms (new tagging platform)
|
||||
way.forward_speed = platform_speeds[public_transport]
|
||||
way.backward_speed = platform_speeds[public_transport]
|
||||
result.forward_speed = platform_speeds[public_transport]
|
||||
result.backward_speed = platform_speeds[public_transport]
|
||||
elseif railway and railway_speeds[railway] then
|
||||
way.forward_mode = mode_train
|
||||
way.backward_mode = mode_train
|
||||
result.forward_mode = mode_train
|
||||
result.backward_mode = mode_train
|
||||
-- railways
|
||||
if access and access_tag_whitelist[access] then
|
||||
way.forward_speed = railway_speeds[railway]
|
||||
way.backward_speed = railway_speeds[railway]
|
||||
result.forward_speed = railway_speeds[railway]
|
||||
result.backward_speed = railway_speeds[railway]
|
||||
end
|
||||
elseif amenity and amenity_speeds[amenity] then
|
||||
-- parking areas
|
||||
way.forward_speed = amenity_speeds[amenity]
|
||||
way.backward_speed = amenity_speeds[amenity]
|
||||
result.forward_speed = amenity_speeds[amenity]
|
||||
result.backward_speed = amenity_speeds[amenity]
|
||||
elseif bicycle_speeds[highway] then
|
||||
-- regular ways
|
||||
way.forward_speed = bicycle_speeds[highway]
|
||||
way.backward_speed = bicycle_speeds[highway]
|
||||
result.forward_speed = bicycle_speeds[highway]
|
||||
result.backward_speed = bicycle_speeds[highway]
|
||||
elseif access and access_tag_whitelist[access] then
|
||||
-- unknown way, but valid access tag
|
||||
way.forward_speed = default_speed
|
||||
way.backward_speed = default_speed
|
||||
result.forward_speed = default_speed
|
||||
result.backward_speed = default_speed
|
||||
else
|
||||
-- biking not allowed, maybe we can push our bike?
|
||||
-- essentially requires pedestrian profiling, for example foot=no mean we can't push a bike
|
||||
if foot ~= 'no' and junction ~= "roundabout" then
|
||||
if pedestrian_speeds[highway] then
|
||||
-- pedestrian-only ways and areas
|
||||
way.forward_speed = pedestrian_speeds[highway]
|
||||
way.backward_speed = pedestrian_speeds[highway]
|
||||
way.forward_mode = mode_pushing
|
||||
way.backward_mode = mode_pushing
|
||||
result.forward_speed = pedestrian_speeds[highway]
|
||||
result.backward_speed = pedestrian_speeds[highway]
|
||||
result.forward_mode = mode_pushing
|
||||
result.backward_mode = mode_pushing
|
||||
elseif man_made and man_made_speeds[man_made] then
|
||||
-- man made structures
|
||||
way.forward_speed = man_made_speeds[man_made]
|
||||
way.backward_speed = man_made_speeds[man_made]
|
||||
way.forward_mode = mode_pushing
|
||||
way.backward_mode = mode_pushing
|
||||
result.forward_speed = man_made_speeds[man_made]
|
||||
result.backward_speed = man_made_speeds[man_made]
|
||||
result.forward_mode = mode_pushing
|
||||
result.backward_mode = mode_pushing
|
||||
elseif foot == 'yes' then
|
||||
way.forward_speed = walking_speed
|
||||
way.backward_speed = walking_speed
|
||||
way.forward_mode = mode_pushing
|
||||
way.backward_mode = mode_pushing
|
||||
result.forward_speed = walking_speed
|
||||
result.backward_speed = walking_speed
|
||||
result.forward_mode = mode_pushing
|
||||
result.backward_mode = mode_pushing
|
||||
elseif foot_forward == 'yes' then
|
||||
way.forward_speed = walking_speed
|
||||
way.forward_mode = mode_pushing
|
||||
way.backward_mode = 0
|
||||
result.forward_speed = walking_speed
|
||||
result.forward_mode = mode_pushing
|
||||
result.backward_mode = 0
|
||||
elseif foot_backward == 'yes' then
|
||||
way.forward_speed = walking_speed
|
||||
way.forward_mode = 0
|
||||
way.backward_mode = mode_pushing
|
||||
result.forward_speed = walking_speed
|
||||
result.forward_mode = 0
|
||||
result.backward_mode = mode_pushing
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -300,84 +298,84 @@ function way_function (way)
|
||||
end
|
||||
|
||||
if onewayClass == "yes" or onewayClass == "1" or onewayClass == "true" then
|
||||
way.backward_mode = 0
|
||||
result.backward_mode = 0
|
||||
elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then
|
||||
-- prevent implied oneway
|
||||
elseif onewayClass == "-1" then
|
||||
way.forward_mode = 0
|
||||
result.forward_mode = 0
|
||||
elseif oneway == "no" or oneway == "0" or oneway == "false" then
|
||||
-- prevent implied oneway
|
||||
elseif cycleway and string.find(cycleway, "opposite") == 1 then
|
||||
if impliedOneway then
|
||||
way.forward_mode = 0
|
||||
way.backward_mode = mode_normal
|
||||
way.backward_speed = bicycle_speeds["cycleway"]
|
||||
result.forward_mode = 0
|
||||
result.backward_mode = mode_normal
|
||||
result.backward_speed = bicycle_speeds["cycleway"]
|
||||
end
|
||||
elseif cycleway_left and cycleway_tags[cycleway_left] and cycleway_right and cycleway_tags[cycleway_right] then
|
||||
-- prevent implied
|
||||
elseif cycleway_left and cycleway_tags[cycleway_left] then
|
||||
if impliedOneway then
|
||||
way.forward_mode = 0
|
||||
way.backward_mode = mode_normal
|
||||
way.backward_speed = bicycle_speeds["cycleway"]
|
||||
result.forward_mode = 0
|
||||
result.backward_mode = mode_normal
|
||||
result.backward_speed = bicycle_speeds["cycleway"]
|
||||
end
|
||||
elseif cycleway_right and cycleway_tags[cycleway_right] then
|
||||
if impliedOneway then
|
||||
way.forward_mode = mode_normal
|
||||
way.backward_speed = bicycle_speeds["cycleway"]
|
||||
way.backward_mode = 0
|
||||
result.forward_mode = mode_normal
|
||||
result.backward_speed = bicycle_speeds["cycleway"]
|
||||
result.backward_mode = 0
|
||||
end
|
||||
elseif oneway == "-1" then
|
||||
way.forward_mode = 0
|
||||
result.forward_mode = 0
|
||||
elseif oneway == "yes" or oneway == "1" or oneway == "true" or impliedOneway then
|
||||
way.backward_mode = 0
|
||||
result.backward_mode = 0
|
||||
end
|
||||
|
||||
|
||||
-- pushing bikes
|
||||
if bicycle_speeds[highway] or pedestrian_speeds[highway] then
|
||||
if foot ~= "no" and junction ~= "roundabout" then
|
||||
if way.backward_mode == 0 then
|
||||
way.backward_speed = walking_speed
|
||||
way.backward_mode = mode_pushing
|
||||
elseif way.forward_mode == 0 then
|
||||
way.forward_speed = walking_speed
|
||||
way.forward_mode = mode_pushing
|
||||
if result.backward_mode == 0 then
|
||||
result.backward_speed = walking_speed
|
||||
result.backward_mode = mode_pushing
|
||||
elseif result.forward_mode == 0 then
|
||||
result.forward_speed = walking_speed
|
||||
result.forward_mode = mode_pushing
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- cycleways
|
||||
if cycleway and cycleway_tags[cycleway] then
|
||||
way.forward_speed = bicycle_speeds["cycleway"]
|
||||
result.forward_speed = bicycle_speeds["cycleway"]
|
||||
elseif cycleway_left and cycleway_tags[cycleway_left] then
|
||||
way.forward_speed = bicycle_speeds["cycleway"]
|
||||
result.forward_speed = bicycle_speeds["cycleway"]
|
||||
elseif cycleway_right and cycleway_tags[cycleway_right] then
|
||||
way.forward_speed = bicycle_speeds["cycleway"]
|
||||
result.forward_speed = bicycle_speeds["cycleway"]
|
||||
end
|
||||
|
||||
-- dismount
|
||||
if bicycle == "dismount" then
|
||||
way.forward_mode = mode_pushing
|
||||
way.backward_mode = mode_pushing
|
||||
way.forward_speed = walking_speed
|
||||
way.backward_speed = walking_speed
|
||||
result.forward_mode = mode_pushing
|
||||
result.backward_mode = mode_pushing
|
||||
result.forward_speed = walking_speed
|
||||
result.backward_speed = walking_speed
|
||||
end
|
||||
|
||||
-- surfaces
|
||||
if surface then
|
||||
surface_speed = surface_speeds[surface]
|
||||
if surface_speed then
|
||||
if way.forward_speed > 0 then
|
||||
way.forward_speed = surface_speed
|
||||
if result.forward_speed > 0 then
|
||||
result.forward_speed = surface_speed
|
||||
end
|
||||
if way.backward_speed > 0 then
|
||||
way.backward_speed = surface_speed
|
||||
if result.backward_speed > 0 then
|
||||
result.backward_speed = surface_speed
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- maxspeed
|
||||
MaxSpeed.limit( way, maxspeed, maxspeed_forward, maxspeed_backward )
|
||||
MaxSpeed.limit( result, maxspeed, maxspeed_forward, maxspeed_backward )
|
||||
end
|
||||
|
||||
function turn_function (angle)
|
||||
|
||||
+106
-116
@@ -103,6 +103,9 @@ maxspeed_table_default = {
|
||||
|
||||
-- List only exceptions
|
||||
maxspeed_table = {
|
||||
["ch:rural"] = 80,
|
||||
["ch:trunk"] = 100,
|
||||
["ch:motorway"] = 120,
|
||||
["de:living_street"] = 7,
|
||||
["ru:living_street"] = 20,
|
||||
["ru:urban"] = 60,
|
||||
@@ -124,11 +127,11 @@ maxspeed_table = {
|
||||
}
|
||||
|
||||
traffic_signal_penalty = 2
|
||||
use_turn_restrictions = true
|
||||
|
||||
local take_minimum_of_speeds = false
|
||||
local obey_oneway = true
|
||||
local obey_bollards = true
|
||||
local use_turn_restrictions = true
|
||||
local ignore_areas = true -- future feature
|
||||
local u_turn_penalty = 20
|
||||
|
||||
@@ -142,15 +145,14 @@ local speed_reduction = 0.8
|
||||
local mode_normal = 1
|
||||
local mode_ferry = 2
|
||||
|
||||
|
||||
local function find_access_tag(source,access_tags_hierachy)
|
||||
local function find_access_tag(source, access_tags_hierachy)
|
||||
for i,v in ipairs(access_tags_hierachy) do
|
||||
local has_tag = source.tags:Holds(v)
|
||||
if has_tag then
|
||||
return source.tags:Find(v)
|
||||
local access_tag = source:get_value_by_key(v)
|
||||
if access_tag and "" ~= access_tag then
|
||||
return access_tag
|
||||
end
|
||||
end
|
||||
return nil
|
||||
return ""
|
||||
end
|
||||
|
||||
function get_exceptions(vector)
|
||||
@@ -191,69 +193,59 @@ end
|
||||
-- return penalty
|
||||
-- end
|
||||
|
||||
function node_function (node)
|
||||
function node_function (node, result)
|
||||
-- parse access and barrier tags
|
||||
local access = find_access_tag(node, access_tags_hierachy)
|
||||
|
||||
--flag node if it carries a traffic light
|
||||
if node.tags:Holds("highway") then
|
||||
if node.tags:Find("highway") == "traffic_signals" then
|
||||
node.traffic_light = true;
|
||||
if access ~= "" then
|
||||
if access_tag_blacklist[access] then
|
||||
result.barrier = true
|
||||
end
|
||||
else
|
||||
local barrier = node:get_value_by_key("barrier")
|
||||
if barrier and "" ~= barrier then
|
||||
if barrier_whitelist[barrier] then
|
||||
return
|
||||
else
|
||||
result.barrier = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- parse access and barrier tags
|
||||
if access and access ~= "" then
|
||||
if access_tag_blacklist[access] then
|
||||
node.bollard = true
|
||||
end
|
||||
elseif node.tags:Holds("barrier") then
|
||||
local barrier = node.tags:Find("barrier")
|
||||
if barrier_whitelist[barrier] then
|
||||
return
|
||||
else
|
||||
node.bollard = true
|
||||
end
|
||||
-- check if node is a traffic light
|
||||
local tag = node:get_value_by_key("highway")
|
||||
if tag and "traffic_signals" == tag then
|
||||
result.traffic_lights = true;
|
||||
end
|
||||
end
|
||||
|
||||
function way_function (way)
|
||||
function way_function (way, result)
|
||||
local highway = way:get_value_by_key("highway")
|
||||
local route = way:get_value_by_key("route")
|
||||
|
||||
local is_highway = way.tags:Holds("highway")
|
||||
local is_route = way.tags:Holds("route")
|
||||
|
||||
if not (is_highway or is_route) then
|
||||
if not ((highway and highway ~= "") or (route and route ~= "")) then
|
||||
return
|
||||
end
|
||||
|
||||
-- we dont route over areas
|
||||
local is_area = way.tags:Holds("area")
|
||||
if ignore_areas and is_area then
|
||||
local area = way.tags:Find("area")
|
||||
if "yes" == area then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- check if oneway tag is unsupported
|
||||
local oneway = way.tags:Find("oneway")
|
||||
if "reversible" == oneway then
|
||||
local area = way:get_value_by_key("area")
|
||||
if ignore_areas and area and "yes" == area then
|
||||
return
|
||||
end
|
||||
|
||||
local is_impassable = way.tags:Holds("impassable")
|
||||
if is_impassable then
|
||||
local impassable = way.tags:Find("impassable")
|
||||
if "yes" == impassable then
|
||||
return
|
||||
end
|
||||
-- check if oneway tag is unsupported
|
||||
local oneway = way:get_value_by_key("oneway")
|
||||
if oneway and "reversible" == oneway then
|
||||
return
|
||||
end
|
||||
|
||||
local is_status = way.tags:Holds("status")
|
||||
if is_status then
|
||||
local status = way.tags:Find("status")
|
||||
if "impassable" == status then
|
||||
return
|
||||
end
|
||||
local impassable = way:get_value_by_key("impassable")
|
||||
if impassable and "yes" == impassable then
|
||||
return
|
||||
end
|
||||
|
||||
local status = way:get_value_by_key("status")
|
||||
if status and "impassable" == status then
|
||||
return
|
||||
end
|
||||
|
||||
-- Check if we are allowed to access the way
|
||||
@@ -262,22 +254,18 @@ function way_function (way)
|
||||
return
|
||||
end
|
||||
|
||||
-- Second, parse the way according to these properties
|
||||
local highway = way.tags:Find("highway")
|
||||
local route = way.tags:Find("route")
|
||||
|
||||
-- Handling ferries and piers
|
||||
local route_speed = speed_profile[route]
|
||||
if(route_speed and route_speed > 0) then
|
||||
highway = route;
|
||||
local duration = way.tags:Find("duration")
|
||||
if durationIsValid(duration) then
|
||||
way.duration = max( parseDuration(duration), 1 );
|
||||
local duration = way:get_value_by_key("duration")
|
||||
if duration and durationIsValid(duration) then
|
||||
result.duration = max( parseDuration(duration), 1 );
|
||||
end
|
||||
way.forward_mode = mode_ferry
|
||||
way.backward_mode = mode_ferry
|
||||
way.forward_speed = route_speed
|
||||
way.backward_speed = route_speed
|
||||
result.forward_mode = mode_ferry
|
||||
result.backward_mode = mode_ferry
|
||||
result.forward_speed = route_speed
|
||||
result.backward_speed = route_speed
|
||||
end
|
||||
|
||||
-- leave early of this way is not accessible
|
||||
@@ -285,122 +273,124 @@ function way_function (way)
|
||||
return
|
||||
end
|
||||
|
||||
if way.forward_speed == -1 then
|
||||
if result.forward_speed == -1 then
|
||||
local highway_speed = speed_profile[highway]
|
||||
local max_speed = parse_maxspeed( way.tags:Find("maxspeed") )
|
||||
local max_speed = parse_maxspeed( way:get_value_by_key("maxspeed") )
|
||||
-- Set the avg speed on the way if it is accessible by road class
|
||||
if highway_speed then
|
||||
if max_speed > highway_speed then
|
||||
way.forward_speed = max_speed
|
||||
way.backward_speed = max_speed
|
||||
if max_speed and max_speed > highway_speed then
|
||||
result.forward_speed = max_speed
|
||||
result.backward_speed = max_speed
|
||||
-- max_speed = math.huge
|
||||
else
|
||||
way.forward_speed = highway_speed
|
||||
way.backward_speed = highway_speed
|
||||
result.forward_speed = highway_speed
|
||||
result.backward_speed = highway_speed
|
||||
end
|
||||
else
|
||||
-- Set the avg speed on ways that are marked accessible
|
||||
if access_tag_whitelist[access] then
|
||||
way.forward_speed = speed_profile["default"]
|
||||
way.backward_speed = speed_profile["default"]
|
||||
result.forward_speed = speed_profile["default"]
|
||||
result.backward_speed = speed_profile["default"]
|
||||
end
|
||||
end
|
||||
if 0 == max_speed then
|
||||
max_speed = math.huge
|
||||
end
|
||||
way.forward_speed = min(way.forward_speed, max_speed)
|
||||
way.backward_speed = min(way.backward_speed, max_speed)
|
||||
result.forward_speed = min(result.forward_speed, max_speed)
|
||||
result.backward_speed = min(result.backward_speed, max_speed)
|
||||
end
|
||||
|
||||
if -1 == way.forward_speed and -1 == way.backward_speed then
|
||||
if -1 == result.forward_speed and -1 == result.backward_speed then
|
||||
return
|
||||
end
|
||||
|
||||
-- reduce speed on bad surfaces
|
||||
local surface = way.tags:Find("surface")
|
||||
local tracktype = way.tags:Find("tracktype")
|
||||
local smoothness = way.tags:Find("smoothness")
|
||||
local surface = way:get_value_by_key("surface")
|
||||
local tracktype = way:get_value_by_key("tracktype")
|
||||
local smoothness = way:get_value_by_key("smoothness")
|
||||
|
||||
if surface and surface_speeds[surface] then
|
||||
way.forward_speed = math.min(surface_speeds[surface], way.forward_speed)
|
||||
way.backward_speed = math.min(surface_speeds[surface], way.backward_speed)
|
||||
result.forward_speed = math.min(surface_speeds[surface], result.forward_speed)
|
||||
result.backward_speed = math.min(surface_speeds[surface], result.backward_speed)
|
||||
end
|
||||
if tracktype and tracktype_speeds[tracktype] then
|
||||
way.forward_speed = math.min(tracktype_speeds[tracktype], way.forward_speed)
|
||||
way.backward_speed = math.min(tracktype_speeds[tracktype], way.backward_speed)
|
||||
result.forward_speed = math.min(tracktype_speeds[tracktype], result.forward_speed)
|
||||
result.backward_speed = math.min(tracktype_speeds[tracktype], result.backward_speed)
|
||||
end
|
||||
if smoothness and smoothness_speeds[smoothness] then
|
||||
way.forward_speed = math.min(smoothness_speeds[smoothness], way.forward_speed)
|
||||
way.backward_speed = math.min(smoothness_speeds[smoothness], way.backward_speed)
|
||||
result.forward_speed = math.min(smoothness_speeds[smoothness], result.forward_speed)
|
||||
result.backward_speed = math.min(smoothness_speeds[smoothness], result.backward_speed)
|
||||
end
|
||||
|
||||
-- parse the remaining tags
|
||||
local name = way.tags:Find("name")
|
||||
local ref = way.tags:Find("ref")
|
||||
local junction = way.tags:Find("junction")
|
||||
-- local barrier = way.tags:Find("barrier")
|
||||
-- local cycleway = way.tags:Find("cycleway")
|
||||
local service = way.tags:Find("service")
|
||||
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 barrier = way:get_value_by_key("barrier", "")
|
||||
-- local cycleway = way:get_value_by_key("cycleway", "")
|
||||
local service = way:get_value_by_key("service")
|
||||
|
||||
-- Set the name that will be used for instructions
|
||||
if "" ~= ref then
|
||||
way.name = ref
|
||||
elseif "" ~= name then
|
||||
way.name = name
|
||||
if ref and "" ~= ref then
|
||||
result.name = ref
|
||||
elseif name and "" ~= name then
|
||||
result.name = name
|
||||
-- else
|
||||
-- way.name = highway -- if no name exists, use way type
|
||||
-- result.name = highway -- if no name exists, use way type
|
||||
end
|
||||
|
||||
if "roundabout" == junction then
|
||||
way.roundabout = true;
|
||||
if junction and "roundabout" == junction then
|
||||
result.roundabout = true;
|
||||
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
|
||||
result.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
|
||||
if service and service ~= "" and service_tag_restricted[service] then
|
||||
result.is_access_restricted = true
|
||||
end
|
||||
|
||||
-- Set direction according to tags on way
|
||||
if obey_oneway then
|
||||
if obey_oneway then
|
||||
if oneway == "-1" then
|
||||
way.forward_mode = 0
|
||||
result.forward_mode = 0
|
||||
elseif oneway == "yes" or
|
||||
oneway == "1" or
|
||||
oneway == "true" or
|
||||
junction == "roundabout" or
|
||||
(highway == "motorway_link" and oneway ~="no") or
|
||||
(highway == "motorway" and oneway ~= "no") then
|
||||
way.backward_mode = 0
|
||||
result.backward_mode = 0
|
||||
end
|
||||
end
|
||||
|
||||
-- Override speed settings if explicit forward/backward maxspeeds are given
|
||||
local maxspeed_forward = parse_maxspeed(way.tags:Find( "maxspeed:forward"))
|
||||
local maxspeed_backward = parse_maxspeed(way.tags:Find( "maxspeed:backward"))
|
||||
if maxspeed_forward > 0 then
|
||||
if 0 ~= way.forward_mode and 0 ~= way.backward_mode then
|
||||
way.backward_speed = way.forward_speed
|
||||
local maxspeed_forward = parse_maxspeed(way:get_value_by_key( "maxspeed:forward"))
|
||||
local maxspeed_backward = parse_maxspeed(way:get_value_by_key( "maxspeed:backward"))
|
||||
if maxspeed_forward and maxspeed_forward > 0 then
|
||||
if 0 ~= result.forward_mode and 0 ~= result.backward_mode then
|
||||
result.backward_speed = result.forward_speed
|
||||
end
|
||||
way.forward_speed = maxspeed_forward
|
||||
result.forward_speed = maxspeed_forward
|
||||
end
|
||||
if maxspeed_backward > 0 then
|
||||
way.backward_speed = maxspeed_backward
|
||||
if maxspeed_backward and maxspeed_backward > 0 then
|
||||
result.backward_speed = maxspeed_backward
|
||||
end
|
||||
|
||||
-- Override general direction settings of there is a specific one for our mode of travel
|
||||
if ignore_in_grid[highway] then
|
||||
way.ignore_in_grid = true
|
||||
result.ignore_in_grid = true
|
||||
end
|
||||
|
||||
-- scale speeds to get better avg driving times
|
||||
way.forward_speed = way.forward_speed * speed_reduction
|
||||
if way.backward_speed > 0 then
|
||||
way.backward_speed = way.backward_speed*speed_reduction
|
||||
if result.forward_speed > 0 then
|
||||
result.forward_speed = result.forward_speed*speed_reduction + 11;
|
||||
end
|
||||
if result.backward_speed > 0 then
|
||||
result.backward_speed = result.backward_speed*speed_reduction + 11;
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+55
-55
@@ -73,42 +73,42 @@ function get_exceptions(vector)
|
||||
end
|
||||
end
|
||||
|
||||
function node_function (node)
|
||||
local barrier = node.tags:Find ("barrier")
|
||||
function node_function (node, result)
|
||||
local barrier = node:get_value_by_key("barrier")
|
||||
local access = Access.find_access_tag(node, access_tags_hierachy)
|
||||
local traffic_signal = node.tags:Find("highway")
|
||||
local traffic_signal = node:get_value_by_key("highway")
|
||||
|
||||
-- flag node if it carries a traffic light
|
||||
if traffic_signal == "traffic_signals" then
|
||||
node.traffic_light = true
|
||||
if traffic_signal and traffic_signal == "traffic_signals" then
|
||||
result.traffic_light = true
|
||||
end
|
||||
|
||||
-- parse access and barrier tags
|
||||
if access and access ~= "" then
|
||||
if access_tag_blacklist[access] then
|
||||
node.bollard = true
|
||||
result.barrier = true
|
||||
else
|
||||
node.bollard = false
|
||||
result.barrier = false
|
||||
end
|
||||
elseif barrier and barrier ~= "" then
|
||||
if barrier_whitelist[barrier] then
|
||||
node.bollard = false
|
||||
result.barrier = false
|
||||
else
|
||||
node.bollard = true
|
||||
result.barrier = true
|
||||
end
|
||||
end
|
||||
|
||||
return 1
|
||||
end
|
||||
|
||||
function way_function (way)
|
||||
function way_function (way, result)
|
||||
-- initial routability check, filters out buildings, boundaries, etc
|
||||
local highway = way.tags:Find("highway")
|
||||
local route = way.tags:Find("route")
|
||||
local man_made = way.tags:Find("man_made")
|
||||
local railway = way.tags:Find("railway")
|
||||
local amenity = way.tags:Find("amenity")
|
||||
local public_transport = way.tags:Find("public_transport")
|
||||
local highway = way:get_value_by_key("highway")
|
||||
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
|
||||
(not route or route == '') and
|
||||
(not railway or railway=='') and
|
||||
@@ -130,82 +130,82 @@ function way_function (way)
|
||||
return
|
||||
end
|
||||
|
||||
local name = way.tags:Find("name")
|
||||
local ref = way.tags:Find("ref")
|
||||
local junction = way.tags:Find("junction")
|
||||
local onewayClass = way.tags:Find("oneway:foot")
|
||||
local duration = way.tags:Find("duration")
|
||||
local service = way.tags:Find("service")
|
||||
local area = way.tags:Find("area")
|
||||
local foot = way.tags:Find("foot")
|
||||
local surface = way.tags:Find("surface")
|
||||
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
|
||||
if "" ~= ref and "" ~= name then
|
||||
way.name = name .. ' / ' .. ref
|
||||
elseif "" ~= ref then
|
||||
way.name = ref
|
||||
elseif "" ~= name then
|
||||
way.name = name
|
||||
else
|
||||
way.name = "{highway:"..highway.."}" -- if no name exists, use way type
|
||||
if ref and "" ~= ref and name and "" ~= name then
|
||||
result.name = name .. ' / ' .. ref
|
||||
elseif ref and "" ~= ref then
|
||||
result.name = ref
|
||||
elseif name and "" ~= name then
|
||||
result.name = name
|
||||
elseif highway then
|
||||
result.name = "{highway:"..highway.."}" -- if no name exists, use way type
|
||||
-- this encoding scheme is excepted to be a temporary solution
|
||||
end
|
||||
|
||||
-- roundabouts
|
||||
if "roundabout" == junction then
|
||||
way.roundabout = true;
|
||||
result.roundabout = true;
|
||||
end
|
||||
|
||||
-- speed
|
||||
if route_speeds[route] then
|
||||
-- ferries (doesn't cover routes tagged using relations)
|
||||
way.ignore_in_grid = true
|
||||
if durationIsValid(duration) then
|
||||
way.duration = math.max( 1, parseDuration(duration) )
|
||||
result.ignore_in_grid = true
|
||||
if duration and durationIsValid(duration) then
|
||||
result.duration = math.max( 1, parseDuration(duration) )
|
||||
else
|
||||
way.forward_speed = route_speeds[route]
|
||||
way.backward_speed = route_speeds[route]
|
||||
result.forward_speed = route_speeds[route]
|
||||
result.backward_speed = route_speeds[route]
|
||||
end
|
||||
way.forward_mode = mode_ferry
|
||||
way.backward_mode = mode_ferry
|
||||
result.forward_mode = mode_ferry
|
||||
result.backward_mode = mode_ferry
|
||||
elseif railway and platform_speeds[railway] then
|
||||
-- railway platforms (old tagging scheme)
|
||||
way.forward_speed = platform_speeds[railway]
|
||||
way.backward_speed = platform_speeds[railway]
|
||||
result.forward_speed = platform_speeds[railway]
|
||||
result.backward_speed = platform_speeds[railway]
|
||||
elseif platform_speeds[public_transport] then
|
||||
-- public_transport platforms (new tagging platform)
|
||||
way.forward_speed = platform_speeds[public_transport]
|
||||
way.backward_speed = platform_speeds[public_transport]
|
||||
result.forward_speed = platform_speeds[public_transport]
|
||||
result.backward_speed = platform_speeds[public_transport]
|
||||
elseif amenity and amenity_speeds[amenity] then
|
||||
-- parking areas
|
||||
way.forward_speed = amenity_speeds[amenity]
|
||||
way.backward_speed = amenity_speeds[amenity]
|
||||
result.forward_speed = amenity_speeds[amenity]
|
||||
result.backward_speed = amenity_speeds[amenity]
|
||||
elseif speeds[highway] then
|
||||
-- regular ways
|
||||
way.forward_speed = speeds[highway]
|
||||
way.backward_speed = speeds[highway]
|
||||
result.forward_speed = speeds[highway]
|
||||
result.backward_speed = speeds[highway]
|
||||
elseif access and access_tag_whitelist[access] then
|
||||
-- unknown way, but valid access tag
|
||||
way.forward_speed = walking_speed
|
||||
way.backward_speed = walking_speed
|
||||
result.forward_speed = walking_speed
|
||||
result.backward_speed = walking_speed
|
||||
end
|
||||
|
||||
-- oneway
|
||||
if onewayClass == "yes" or onewayClass == "1" or onewayClass == "true" then
|
||||
way.backward_mode = 0
|
||||
result.backward_mode = 0
|
||||
elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then
|
||||
-- nothing to do
|
||||
elseif onewayClass == "-1" then
|
||||
way.forward_mode = 0
|
||||
result.forward_mode = 0
|
||||
end
|
||||
|
||||
-- surfaces
|
||||
if surface then
|
||||
surface_speed = surface_speeds[surface]
|
||||
if surface_speed then
|
||||
way.forward_speed = math.min(way.forward_speed, surface_speed)
|
||||
way.backward_speed = math.min(way.backward_speed, surface_speed)
|
||||
result.forward_speed = math.min(result.forward_speed, surface_speed)
|
||||
result.backward_speed = math.min(result.backward_speed, surface_speed)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,10 +4,10 @@ module "Access"
|
||||
|
||||
function find_access_tag(source,access_tags_hierachy)
|
||||
for i,v in ipairs(access_tags_hierachy) do
|
||||
local tag = source.tags:Find(v)
|
||||
if tag ~= '' then
|
||||
local tag = source:get_value_by_key(v)
|
||||
if tag and tag ~= '' then
|
||||
return tag
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
+30
-29
@@ -45,46 +45,47 @@ function limit_speed(speed, limits)
|
||||
return speed
|
||||
end
|
||||
|
||||
function node_function (node)
|
||||
local traffic_signal = node.tags:Find("highway")
|
||||
function node_function (node, result)
|
||||
local traffic_signal = node:get_value_by_key("highway")
|
||||
|
||||
if traffic_signal == "traffic_signals" then
|
||||
node.traffic_light = true;
|
||||
if traffic_signal and traffic_signal == "traffic_signals" then
|
||||
result.traffic_lights = true;
|
||||
-- TODO: a way to set the penalty value
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
function way_function (way)
|
||||
local highway = way.tags:Find("highway")
|
||||
local name = way.tags:Find("name")
|
||||
local oneway = way.tags:Find("oneway")
|
||||
local route = way.tags:Find("route")
|
||||
local duration = way.tags:Find("duration")
|
||||
local maxspeed = tonumber(way.tags:Find ( "maxspeed"))
|
||||
local maxspeed_forward = tonumber(way.tags:Find( "maxspeed:forward"))
|
||||
local maxspeed_backward = tonumber(way.tags:Find( "maxspeed:backward"))
|
||||
local junction = way.tags:Find("junction")
|
||||
function way_function (way, result)
|
||||
local highway = way:get_value_by_key("highway")
|
||||
local name = way:get_value_by_key("name")
|
||||
local oneway = way:get_value_by_key("oneway")
|
||||
local route = way:get_value_by_key("route")
|
||||
local duration = way:get_value_by_key("duration")
|
||||
local maxspeed = tonumber(way:get_value_by_key ( "maxspeed"))
|
||||
local maxspeed_forward = tonumber(way:get_value_by_key( "maxspeed:forward"))
|
||||
local maxspeed_backward = tonumber(way:get_value_by_key( "maxspeed:backward"))
|
||||
local junction = way:get_value_by_key("junction")
|
||||
|
||||
way.name = name
|
||||
if name then
|
||||
result.name = name
|
||||
end
|
||||
|
||||
if route ~= nil and durationIsValid(duration) then
|
||||
way.duration = math.max( 1, parseDuration(duration) )
|
||||
way.forward_mode = 2
|
||||
way.backward_mode = 2
|
||||
if duration and durationIsValid(duration) then
|
||||
result.duration = math.max( 1, parseDuration(duration) )
|
||||
result.forward_mode = 2
|
||||
result.backward_mode = 2
|
||||
else
|
||||
local speed_forw = speed_profile[highway] or speed_profile['default']
|
||||
local speed_back = speed_forw
|
||||
|
||||
if highway == "river" then
|
||||
local temp_speed = speed_forw;
|
||||
way.forward_mode = 3
|
||||
way.backward_mode = 4
|
||||
result.forward_mode = 3
|
||||
result.backward_mode = 4
|
||||
speed_forw = temp_speed*1.5
|
||||
speed_back = temp_speed/1.5
|
||||
elseif highway == "steps" then
|
||||
way.forward_mode = 5
|
||||
way.backward_mode = 6
|
||||
result.forward_mode = 5
|
||||
result.backward_mode = 6
|
||||
end
|
||||
|
||||
if maxspeed_forward ~= nil and maxspeed_forward > 0 then
|
||||
@@ -103,19 +104,19 @@ function way_function (way)
|
||||
end
|
||||
end
|
||||
|
||||
way.forward_speed = speed_forw
|
||||
way.backward_speed = speed_back
|
||||
result.forward_speed = speed_forw
|
||||
result.backward_speed = speed_back
|
||||
end
|
||||
|
||||
if oneway == "no" or oneway == "0" or oneway == "false" then
|
||||
-- nothing to do
|
||||
elseif oneway == "-1" then
|
||||
way.forward_mode = 0
|
||||
result.forward_mode = 0
|
||||
elseif oneway == "yes" or oneway == "1" or oneway == "true" or junction == "roundabout" then
|
||||
way.backward_mode = 0
|
||||
result.backward_mode = 0
|
||||
end
|
||||
|
||||
if junction == 'roundabout' then
|
||||
way.roundabout = true
|
||||
result.roundabout = true
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user