13,401
edits
(Rm WB) |
(Fix) |
||
Line 104: | Line 104: | ||
local mapframe = p._main(parentArgs) | local mapframe = p._main(parentArgs) | ||
return frame:preprocess(mapframe) | return frame:preprocess(mapframe) | ||
end | |||
function getZoom(value, unit) | |||
local length_km | |||
if unit == 'km' then | |||
length_km = tonumber(value) | |||
elseif unit == 'mi' then | |||
length_km = tonumber(value)*1.609344 | |||
elseif unit == 'km2' then | |||
length_km = math.sqrt(tonumber(value)) | |||
elseif unit == 'mi2' then | |||
length_km = math.sqrt(tonumber(value))*1.609344 | |||
end | |||
-- max for zoom 2 is 6400km, for zoom 3 is 3200km, for zoom 4 is 1600km, etc | |||
local zoom = math.floor(8 - (math.log10(length_km) - 2)/(math.log10(2))) | |||
-- limit to values below 17 | |||
zoom = math.min(17, zoom) | |||
-- take off 1 when calculated from area, to account for unusual shapes | |||
if unit == 'km2' or unit == 'mi2' then | |||
zoom = zoom - 1 | |||
end | |||
-- minimum value is 1 | |||
return math.max(1, zoom) | |||
end | end | ||
Line 121: | Line 144: | ||
args["frame-align"] = "center" | args["frame-align"] = "center" | ||
args["frame-coord"] = config["frame-coordinates"] or | args["frame-coord"] = config["frame-coordinates"] or "" | ||
-- deprecated lat and long parameters | -- deprecated lat and long parameters |
edits