Modulo:Maplink: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
mNessun oggetto della modifica
Nessun 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 = (bmx - bmn)
local dydx = 1.05*(amx bmx- amnbmn)
local dxdy = 1.05*(bmx amx- bmnamn)
-- if (dimx>dimy) then dx = dx*dimy/dimx else dy = dy*dimx/dimy end
-- calcolo scale per coordinate
local scala = 10
local scalax, scalay
if (dx == 0) then
if (dx == 0) scalathen scalax = 18 else scalax = math.floor(math.log(360/dx)/math.log(2)) end
if (dy == 0) then
if (dy == 0) scalathen scalay = 18 else scalay = math.floor(math.log(180/dy)/math.log(2)) end
-- default
local scala = 10
else
if ((dx == 0) and (dy == 0)) then
scala = math.floor(math.log(180/dy)/math.log(2))
scala = 10 --valore default per singolo punto
end
else
scala = math.max(0,math.min(18,scalax, scalay)) --calcolo scala minima compresa tra 0 e 18
if (dy == 0) then
elseend
scala = math.floor(math.log(360/dx)/math.log(2))
else
scala = math.min( math.floor(math.log(360/dx)/math.log(2)), math.floor(math.log(180/dy)/math.log(2)) )
end
end
if (scala < 0) then scala = 0 end
if (scala > 17) then scala = 18 end
return scala
end