Module:Mapa

Gikan sa Bikol Sentral na Wikipedia, an talingkas na ensiklopedya
Documentation icon Dokumentasyon nin Modyul[gibuhon]
local head={}
for k,v in ipairs({string.byte("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",1,-1)}) do
	head[v]=k-1
end
local tail={}
for k,v in ipairs({string.byte("==9xsy+===4ldYem5=8kUNIOVn/wcMEAFPfzvbLD=BJZt3jTHCGQg0.rXSKRWo*=7qiahp6===^2u1-==",1,-1)}) do
	if v~=string.byte("=") then
		tail[v]={(k-1)%9-4,math.floor((k-1)/9)-4}
	end
end
return function(name,index)
	local result={}
	for line in string.gmatch(mw.loadData("Module:Mapa/"..name)[index],"[^,]+") do
		local b={line:byte(1,-1)}
		local p={head[b[1]]+64*(head[b[2]]+64*head[b[3]]),head[b[4]]+64*(head[b[5]]+64*head[b[6]])}
		local list={}
		table.insert(list,{p[1]*360/65536,p[2]*360*2/3/65536})
		for k,v in ipairs(b) do
			if k>=7 then
				local d=tail[v]
				p={p[1]+d[1],p[2]+d[2]}
				table.insert(list,{p[1]*360/65536,p[2]*360*2/3/65536})
			end
		end
		table.insert(result,list)
	end
	return result
end