Module:Infobox mapframe: Difference between revisions

Fix
(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 config["frame-coord"] or ""
     args["frame-coord"] = config["frame-coordinates"] or ""
    -- Note: config["coordinates"] or config["coord"] should not be used for the alignment of the frame;
    -- see talk page ( https://en.wikipedia.org/wiki/Special:Diff/876492931 )


     -- deprecated lat and long parameters
     -- deprecated lat and long parameters