Jump to content

Module:AutoMapZoom

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by Pppery (talk | contribs) at 15:02, 7 September 2022 (Boilerplate). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
local p = {}

--  Given an input area, return a map zoom level to use with mw:Extension:Kartographer. Defaults to mapzoom=15. 
function p.autoMapZoom(frame)
	local sizestr,null = frame.args[1]:gsub("%D+%.?%D+", ""):gsub(",","")
	local size = tonumber(sizestr) or 0
	local LUT = { 5000000, 1000000, 100000, 50000, 10000, 2000, 150, 50, 19, 14, 5, 1, 0.5 } 
	for zoom, scale in ipairs(LUT) do
		if size > scale then
			return zoom+1
		end
	end
	return 15
end

return p