Modulo:Sandbox/M.casanova/DatiMappa: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
mNessun oggetto della modifica
mNessun oggetto della modifica
Riga 9:
local t = getArgs(frame)
local amn, amx, bmn, bmx = 400, -400, 400, -400
local dimx = tonumber(t[1]) or 1 --larghezza
local dimy = tonumber(t[2]) or 1 --altezza
local vlr
for i,v in ipairs(t) do
if i>2 then
vlr = tonumber(t[i])
if (i % 2 == 0) then --calcolo latitudine minima e massima
if (amn > vlr) then amn = vlr end
if (amx < vlr) then amx = vlr end
else --calcolo longitudine minima e massima
else
if (bmn > vlr) then bmn = vlr end
if (bmx < vlr) then bmx = vlr end
Riga 24:
end
end
-- per evitare punti troppo vicini al margine
local dx = 1.05*(bmx-bmn)
local dy = 1.05*(amx-amn)
-- if (dimx>dimy) then dx = dx*dimy/dimx else dy = dy*dimx/dimy end
if (dx<180) then dx = dx*dimy/dimx end
else
if (dy<90) then dy = dy*dimx/dimy end
end
-- calcolo scale per coordinate
local scalax, scalay
if (dx == 0) then scalax = 18 else scalax = math.floor(math.log(360/dx)/math.log(2)) end
Riga 32 ⟶ 38:
local scala
if ((dx == 0) and (dy == 0)) then
scala = 10 --valore default per singolo punto
else
scala = math.max(0,math.min(18,scalax, scalay)) --calcolo scala minima compresa tra 0 e 18
end
return scala