Add support for non-numerical units in car profile for maxheight #4763

This commit is contained in:
Alain ANDRE
2018-01-23 12:12:21 +01:00
committed by Patrick Niklaus
parent 8114104a43
commit 2987292cc0
5 changed files with 5596 additions and 4 deletions
+15 -2
View File
@@ -55,11 +55,24 @@ function Measure.parse_value_kilograms(value)
end
end
-- default maxheight value defined in https://wiki.openstreetmap.org/wiki/Key:maxheight#Non-numerical_values
local default_maxheight = 4.5
-- Available Non numerical values equal to 4.5; below_default and no_indications are not considered
local height_non_numerical_values = Set { "default", "none", "no-sign", "unsigned" }
--- Get maxheight of specified way in meters. If there are no
--- max height, then return nil
function Measure.get_max_height(raw_value)
function Measure.get_max_height(raw_value,way)
if raw_value then
return Measure.parse_value_meters(raw_value)
if height_non_numerical_values[raw_value] then
if way then
return way:get_location_tag('maxheight') or default_maxheight
else
return default_maxheight
end
else
return Measure.parse_value_meters(raw_value)
end
end
end
+2 -2
View File
@@ -465,8 +465,8 @@ end
function WayHandlers.handle_height(profile,way,result,data)
local keys = Sequence { 'maxheight:physical', 'maxheight' }
local forward, backward = Tags.get_forward_backward_by_set(way,data,keys)
forward = Measure.get_max_height(forward)
backward = Measure.get_max_height(backward)
forward = Measure.get_max_height(forward,way)
backward = Measure.get_max_height(backward,way)
if forward and forward < profile.vehicle_height then
result.forward_mode = mode.inaccessible