Modulo:Coord: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
aggiorno dms2dec/dec2dms alle classi
+local, miglioro params in geohackParams, -controllo su card
Riga 179:
function DecCoord:__tostring()
return self.deg .. "°" .. self.card
end
 
-- Ritorna i gradi con segno
function DecCoord:getDeg()
return self.deg * ((self.card == "N" or self.card =="E") and 1 or -1)
end
 
Riga 200 ⟶ 205:
 
return DmsCoord:new(deg, min, sec, self.card)
end
 
-- Ritorna i gradi con segno
function DecCoord:getDeg()
return self.deg * ((self.card == "N" or self.card =="E") and 1 or -1)
end
 
Riga 227:
(self.min and (padleft0(self.min) .. "′") or "") ..
(self.sec and (padleft0(self.sec) .. "″") or "") ..
(self.card and self.card or "")
end
 
Riga 261:
 
-- Crea l'HTML ritornato da Coord
local function buildHTML(decLat, decLong, dmsLat, dmsLong, paramgeohackParams, defaultFormat)
local root, text, url, displayInline, displayTitle, htmlTitle
 
Riga 267:
url = cfg.geohackUrl ..
"&pagename=" .. mw.uri.encode(mw.title.getCurrentTitle().prefixedText, "WIKI") ..
"&params=" .. paramgeohackParams ..
(args["name"] and ("&title=" .. mw.uri.encode(args["name"])) or "")
 
Riga 329:
-- contenente le coordinate in formato dec e dms come collegamento esterno a geohack.php.
local function coord()
local paramdecLat, defaultFormatdegLong, dmsFormatdmsLat, reqFormatdmsLong
local reqFormat, dmsFormat, defaultFormat, geohackParams
 
reqFormat = paramsParse()
Riga 376 ⟶ 377:
-- crea la stringa param per geohack.php
if reqFormat == "dec" then
paramgeohackParams = args[1] .. "_N_" .. args[2] .. "_E" .. (args[3] and ("_" .. args[3]) or "")
else
-- concatena solo i posizionali
paramgeohackParams = table.concat(args, "_")
end
 
return args["display"] == "debug" and
(decLat .. " " .. decLong .. " " .. dmsLat .. " " .. dmsLong) or
buildHTML(decLat, decLong, dmsLat, dmsLong, paramgeohackParams, defaultFormat)
end