Merge pull request #1478 from Project-OSRM/fix/profiles-cleanup
Cleanup the profiles
This commit is contained in:
commit
6d9c3bca33
@ -12,10 +12,10 @@ access_tags_hierachy = { "bicycle", "vehicle", "access" }
|
|||||||
cycleway_tags = {["track"]=true,["lane"]=true,["opposite"]=true,["opposite_lane"]=true,["opposite_track"]=true,["share_busway"]=true,["sharrow"]=true,["shared"]=true }
|
cycleway_tags = {["track"]=true,["lane"]=true,["opposite"]=true,["opposite_lane"]=true,["opposite_track"]=true,["share_busway"]=true,["sharrow"]=true,["shared"]=true }
|
||||||
service_tag_restricted = { ["parking_aisle"] = true }
|
service_tag_restricted = { ["parking_aisle"] = true }
|
||||||
restriction_exception_tags = { "bicycle", "vehicle", "access" }
|
restriction_exception_tags = { "bicycle", "vehicle", "access" }
|
||||||
|
unsafe_highway_list = { ["primary"] = true, ["secondary"] = true, ["tertiary"] = true, ["primary_link"] = true, ["secondary_link"] = true, ["tertiary_link"] = true}
|
||||||
|
|
||||||
default_speed = 15
|
local default_speed = 15
|
||||||
|
local walking_speed = 6
|
||||||
walking_speed = 6
|
|
||||||
|
|
||||||
bicycle_speeds = {
|
bicycle_speeds = {
|
||||||
["cycleway"] = default_speed,
|
["cycleway"] = default_speed,
|
||||||
@ -91,24 +91,27 @@ surface_speeds = {
|
|||||||
["sand"] = 3
|
["sand"] = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
take_minimum_of_speeds = true
|
traffic_signal_penalty = 2
|
||||||
obey_oneway = true
|
use_turn_restrictions = false
|
||||||
obey_bollards = false
|
|
||||||
use_restrictions = true
|
|
||||||
ignore_areas = true -- future feature
|
|
||||||
traffic_signal_penalty = 5
|
|
||||||
u_turn_penalty = 20
|
|
||||||
use_turn_restrictions = false
|
|
||||||
turn_penalty = 60
|
|
||||||
turn_bias = 1.4
|
|
||||||
|
|
||||||
|
local obey_oneway = true
|
||||||
|
local obey_bollards = false
|
||||||
|
local ignore_areas = true
|
||||||
|
local u_turn_penalty = 20
|
||||||
|
local turn_penalty = 60
|
||||||
|
local turn_bias = 1.4
|
||||||
|
-- reduce the driving speed by 30% for unsafe roads
|
||||||
|
-- local safety_penalty = 0.7
|
||||||
|
local safety_penalty = 1.0
|
||||||
|
local use_public_transport = true
|
||||||
|
local fallback_names = true
|
||||||
|
|
||||||
--modes
|
--modes
|
||||||
mode_normal = 1
|
local mode_normal = 1
|
||||||
mode_pushing = 2
|
local mode_pushing = 2
|
||||||
mode_ferry = 3
|
local mode_ferry = 3
|
||||||
mode_train = 4
|
local mode_train = 4
|
||||||
mode_movable_bridge = 5
|
local mode_movable_bridge = 5
|
||||||
|
|
||||||
local function parse_maxspeed(source)
|
local function parse_maxspeed(source)
|
||||||
if not source then
|
if not source then
|
||||||
@ -131,29 +134,26 @@ function get_exceptions(vector)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function node_function (node, result)
|
function node_function (node, result)
|
||||||
local barrier = node:get_value_by_key("barrier")
|
-- parse access and barrier tags
|
||||||
local access = find_access_tag(node, access_tags_hierachy)
|
local access = find_access_tag(node, access_tags_hierachy)
|
||||||
local traffic_signal = node:get_value_by_key("highway")
|
if access and 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 not barrier_whitelist[barrier] then
|
||||||
|
result.barrier = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- flag node if it carries a traffic light
|
-- check if node is a traffic light
|
||||||
if traffic_signal and traffic_signal == "traffic_signals" then
|
local tag = node:get_value_by_key("highway")
|
||||||
result.traffic_lights = true
|
if tag and "traffic_signals" == tag then
|
||||||
end
|
result.traffic_lights = true;
|
||||||
|
end
|
||||||
-- parse access and barrier tags
|
|
||||||
if access and access ~= "" then
|
|
||||||
if access_tag_blacklist[access] then
|
|
||||||
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
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function way_function (way, result)
|
function way_function (way, result)
|
||||||
@ -166,8 +166,8 @@ function way_function (way, result)
|
|||||||
local public_transport = way:get_value_by_key("public_transport")
|
local public_transport = way:get_value_by_key("public_transport")
|
||||||
local bridge = way:get_value_by_key("bridge")
|
local bridge = way:get_value_by_key("bridge")
|
||||||
if (not highway or highway == '') and
|
if (not highway or highway == '') and
|
||||||
(not route or route == '') and
|
(not use_public_transport or not route or route == '') and
|
||||||
(not railway or railway=='') and
|
(not use_public_transport or 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=='') and
|
(not public_transport or public_transport=='') and
|
||||||
@ -214,7 +214,8 @@ function way_function (way, result)
|
|||||||
result.name = ref
|
result.name = ref
|
||||||
elseif name and "" ~= name then
|
elseif name and "" ~= name then
|
||||||
result.name = name
|
result.name = name
|
||||||
elseif highway then
|
-- TODO find a better solution for encoding way type
|
||||||
|
elseif fallback_names and highway then
|
||||||
-- if no name exists, use way type
|
-- if no name exists, use way type
|
||||||
-- this encoding scheme is excepted to be a temporary solution
|
-- this encoding scheme is excepted to be a temporary solution
|
||||||
result.name = "{highway:"..highway.."}"
|
result.name = "{highway:"..highway.."}"
|
||||||
@ -247,15 +248,16 @@ function way_function (way, result)
|
|||||||
result.forward_speed = route_speeds[route]
|
result.forward_speed = route_speeds[route]
|
||||||
result.backward_speed = route_speeds[route]
|
result.backward_speed = route_speeds[route]
|
||||||
end
|
end
|
||||||
elseif railway and platform_speeds[railway] then
|
-- public transport
|
||||||
|
elseif use_public_transport and railway and platform_speeds[railway] then
|
||||||
-- railway platforms (old tagging scheme)
|
-- railway platforms (old tagging scheme)
|
||||||
result.forward_speed = platform_speeds[railway]
|
result.forward_speed = platform_speeds[railway]
|
||||||
result.backward_speed = platform_speeds[railway]
|
result.backward_speed = platform_speeds[railway]
|
||||||
elseif platform_speeds[public_transport] then
|
elseif use_public_transport and platform_speeds[public_transport] then
|
||||||
-- public_transport platforms (new tagging platform)
|
-- public_transport platforms (new tagging platform)
|
||||||
result.forward_speed = platform_speeds[public_transport]
|
result.forward_speed = platform_speeds[public_transport]
|
||||||
result.backward_speed = platform_speeds[public_transport]
|
result.backward_speed = platform_speeds[public_transport]
|
||||||
elseif railway and railway_speeds[railway] then
|
elseif use_public_transport and railway and railway_speeds[railway] then
|
||||||
result.forward_mode = mode_train
|
result.forward_mode = mode_train
|
||||||
result.backward_mode = mode_train
|
result.backward_mode = mode_train
|
||||||
-- railways
|
-- railways
|
||||||
@ -271,6 +273,10 @@ function way_function (way, result)
|
|||||||
-- regular ways
|
-- regular ways
|
||||||
result.forward_speed = bicycle_speeds[highway]
|
result.forward_speed = bicycle_speeds[highway]
|
||||||
result.backward_speed = bicycle_speeds[highway]
|
result.backward_speed = bicycle_speeds[highway]
|
||||||
|
if safety_penalty < 1 and unsafe_highway_list[highway] then
|
||||||
|
result.forward_speed = result.forward_speed * safety_penalty
|
||||||
|
result.backward_speed = result.backward_speed * safety_penalty
|
||||||
|
end
|
||||||
elseif access and access_tag_whitelist[access] then
|
elseif access and access_tag_whitelist[access] then
|
||||||
-- unknown way, but valid access tag
|
-- unknown way, but valid access tag
|
||||||
result.forward_speed = default_speed
|
result.forward_speed = default_speed
|
||||||
|
@ -132,10 +132,9 @@ maxspeed_table = {
|
|||||||
traffic_signal_penalty = 2
|
traffic_signal_penalty = 2
|
||||||
use_turn_restrictions = true
|
use_turn_restrictions = true
|
||||||
|
|
||||||
local take_minimum_of_speeds = false
|
|
||||||
local obey_oneway = true
|
local obey_oneway = true
|
||||||
local obey_bollards = true
|
local obey_bollards = true
|
||||||
local ignore_areas = true -- future feature
|
local ignore_areas = true
|
||||||
local u_turn_penalty = 20
|
local u_turn_penalty = 20
|
||||||
|
|
||||||
local abs = math.abs
|
local abs = math.abs
|
||||||
@ -179,6 +178,7 @@ local function parse_maxspeed(source)
|
|||||||
return n
|
return n
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- FIXME Why was this commented out?
|
||||||
-- function turn_function (angle)
|
-- function turn_function (angle)
|
||||||
-- -- print ("called at angle " .. angle )
|
-- -- print ("called at angle " .. angle )
|
||||||
-- local index = math.abs(math.floor(angle/10+0.5))+1 -- +1 'coz LUA starts as idx 1
|
-- local index = math.abs(math.floor(angle/10+0.5))+1 -- +1 'coz LUA starts as idx 1
|
||||||
@ -190,7 +190,7 @@ end
|
|||||||
function node_function (node, result)
|
function node_function (node, result)
|
||||||
-- parse access and barrier tags
|
-- parse access and barrier tags
|
||||||
local access = find_access_tag(node, access_tags_hierachy)
|
local access = find_access_tag(node, access_tags_hierachy)
|
||||||
if access ~= "" then
|
if access and access ~= "" then
|
||||||
if access_tag_blacklist[access] then
|
if access_tag_blacklist[access] then
|
||||||
result.barrier = true
|
result.barrier = true
|
||||||
end
|
end
|
||||||
@ -420,9 +420,3 @@ function way_function (way, result)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- These are wrappers to parse vectors of nodes and ways and thus to speed up any tracing JIT
|
|
||||||
function node_vector_function(vector)
|
|
||||||
for v in vector.nodes do
|
|
||||||
node_function(v)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
Loading…
Reference in New Issue
Block a user