Add support of maxweight in profiles
This commit is contained in:
parent
423a4ef326
commit
c7b1d0c131
@ -20,6 +20,17 @@ local feet_parse_patterns = Sequence {
|
|||||||
"%d+\'%d+\'",
|
"%d+\'%d+\'",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--- according to http://wiki.openstreetmap.org/wiki/Map_Features/Units#Explicit_specifications
|
||||||
|
local tonns_parse_patterns = Sequence {
|
||||||
|
"%d+",
|
||||||
|
"%d+.%d+",
|
||||||
|
"%d+.%d+ t"
|
||||||
|
}
|
||||||
|
|
||||||
|
local kg_parse_patterns = Sequence {
|
||||||
|
"%d+ kg"
|
||||||
|
}
|
||||||
|
|
||||||
function Measure.convert_feet_to_inches(feet)
|
function Measure.convert_feet_to_inches(feet)
|
||||||
return feet * feet_to_inches
|
return feet * feet_to_inches
|
||||||
end
|
end
|
||||||
@ -51,6 +62,30 @@ function Measure.parse_value_meters(value)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
print("Can't parse value: ", value)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Parse weight value in kilograms
|
||||||
|
function Measure.parse_value_kilograms(value)
|
||||||
|
-- try to parse kilograms
|
||||||
|
for i, templ in ipairs(kg_parse_patterns) do
|
||||||
|
m = string.match(value, templ)
|
||||||
|
if m then
|
||||||
|
return tonumber(m)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- try to parse tonns
|
||||||
|
for i, templ in ipairs(tonns_parse_patterns) do
|
||||||
|
m = string.match(value, templ)
|
||||||
|
if m then
|
||||||
|
return tonumber(m) * 1000
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--
|
||||||
|
print("Can't parse value: ", value)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -69,10 +104,18 @@ end
|
|||||||
function Measure.get_max_width(way)
|
function Measure.get_max_width(way)
|
||||||
raw_value = way:get_value_by_key('maxwidth')
|
raw_value = way:get_value_by_key('maxwidth')
|
||||||
if raw_value then
|
if raw_value then
|
||||||
print(way:id(), raw_value)
|
|
||||||
return Measure.parse_value_meters(raw_value)
|
return Measure.parse_value_meters(raw_value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get maxweight of specified way in kilogramms
|
||||||
|
function Measure.get_max_weight(way)
|
||||||
|
raw_value = way:get_value_by_key('maxweight')
|
||||||
|
if raw_value then
|
||||||
|
-- print(way:id(), raw_value)
|
||||||
|
return Measure.parse_value_kilograms(raw_value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return Measure;
|
return Measure;
|
Loading…
Reference in New Issue
Block a user