Add support for non-numerical units in car profile for maxheight #4763
This commit is contained in:
committed by
Patrick Niklaus
parent
8114104a43
commit
2987292cc0
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user