Add support for classes on bicycle profile

This commit is contained in:
Patrick Niklaus
2018-04-24 15:34:31 +00:00
committed by Patrick Niklaus
parent 9edd161da3
commit 73716bd651
3 changed files with 122 additions and 8 deletions
+13
View File
@@ -193,6 +193,16 @@ function setup()
sett = 10
},
classes = Sequence {
'ferry', 'tunnel'
},
-- Which classes should be excludable
-- This increases memory usage so its disabled by default.
excludable = Sequence {
-- Set {'ferry'}
},
tracktype_speeds = {
},
@@ -650,6 +660,9 @@ function process_way(profile, way, result)
-- set name, ref and pronunciation
WayHandlers.names,
-- set classes
WayHandlers.classes,
-- set weight properties of the way
WayHandlers.weights
}
+17 -8
View File
@@ -306,37 +306,46 @@ end
-- add class information
function WayHandlers.classes(profile,way,result,data)
if not profile.classes then
return
end
local allowed_classes = Set {}
for k, v in pairs(profile.classes) do
allowed_classes[v] = true
end
local forward_toll, backward_toll = Tags.get_forward_backward_by_key(way, data, "toll")
local forward_route, backward_route = Tags.get_forward_backward_by_key(way, data, "route")
local tunnel = way:get_value_by_key("tunnel")
if tunnel and tunnel ~= "no" then
if allowed_classes["tunnel"] and tunnel and tunnel ~= "no" then
result.forward_classes["tunnel"] = true
result.backward_classes["tunnel"] = true
end
if forward_toll == "yes" then
if allowed_classes["toll"] and forward_toll == "yes" then
result.forward_classes["toll"] = true
end
if backward_toll == "yes" then
if allowed_classes["toll"] and backward_toll == "yes" then
result.backward_classes["toll"] = true
end
if forward_route == "ferry" then
if allowed_classes["ferry"] and forward_route == "ferry" then
result.forward_classes["ferry"] = true
end
if backward_route == "ferry" then
if allowed_classes["ferry"] and backward_route == "ferry" then
result.backward_classes["ferry"] = true
end
if result.forward_restricted then
if allowed_classes["restricted"] and result.forward_restricted then
result.forward_classes["restricted"] = true
end
if result.backward_restricted then
if allowed_classes["restricted"] and result.backward_restricted then
result.backward_classes["restricted"] = true
end
if data.highway == "motorway" or data.highway == "motorway_link" then
if allowed_classes["motorway"] and (data.highway == "motorway" or data.highway == "motorway_link") then
result.forward_classes["motorway"] = true
result.backward_classes["motorway"] = true
end