Modulo:Mapframe: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
aggiunta table defaults per i valori predefiniti, fix minori |
m modulo no globals obsoleto |
||
(5 versioni intermedie di un altro utente non mostrate) | |||
Riga 1:
require('
local getArgs = require('Module:Arguments').getArgs
local mWikidata = require('Module:Wikidata')
Riga 14 ⟶ 15:
local function getLegenda(points, ncols)
local divStyle = {
['-webkit-column-count'] = ncols
}
local divNode = mw.html.create('div'):css(divStyle)
Riga 23 ⟶ 25:
for _, point in ipairs(points) do
local pNode = mw.html.create('p')
:css('font-size', '90%') :css('margin-top', '0')
local codeNode = mw.html.create('code')
:css('font-weight', 'bold')
Riga 30 ⟶ 34:
:css('border', '2px solid ' .. point.col)
:css('background', point.col)
if not point.simb
codeNode:wikitext(' ')
elseif point.simb:find('-number') == 1 then
codeNode:wikitext(currNum)
currNum = currNum + 1
Riga 53 ⟶ 59:
function p._mappa(args)
local points = {}
local geo = args.dati or -1▼
local sinottico = tonumber(args.sinottico) or 0
local colore = args.colore or '#b80000'
local simbolo = args.simbolo or
local gruppo = args.gruppo or ''
local autozoom = args.autozoom or 's'
Riga 63 ⟶ 68:
local cornice = tonumber(args.cornice) or 1
local lat1, lat2, lon1, lon2 = 400, -400, 400, -400
local
width = args.larghezza or (sinottico == 1 and 260 or 350),
height = args.altezza or (sinottico == 1 and 260 or 300),
align = args.allinea or (sinottico == 1 and 'center' or 'right'),
}
-- =================================
-- popola la sequence points
-- =================================
local num = 1
if sinottico == 1 and args.lat1 == nil and args.lon1 == nil then
Riga 99 ⟶ 109:
end
num = num + 1
end
-- non utilizza nessun simbolo con un solo punto e args.simbolo e args.simbolo1 non definiti
if #points == 1 and args.simbolo == nil and args.simbolo1 == nil then
points[1].simb = nil
end
end
-- =================================
-- popola la table m_args
-- =================================
▲ -- elimina cornice per cornice = 0 e per sinottico = 1
▲ if cornice ~= 1 or sinottico == 1 then m_args.frameless = 1 end
-- valore ingrandimento
if args.zoom then
m_args.zoom = tonumber(args.zoom)
elseif
if #points == 1 then
m_args.zoom = 10 -- valore predefinito per singolo punto
Riga 141 ⟶ 149:
if args.centro_lon then
m_args.longitude = tonumber(args.centro_lon)
elseif
if #points == 1 then
m_args.longitude = points[1].lon
Riga 151 ⟶ 159:
if args.centro_lat then
m_args.latitude = tonumber(args.centro_lat)
elseif
if #points == 1 then
m_args.latitude = points[1].lat
Riga 163 ⟶ 171:
end
-- =================================
-- popola la table m_dati
-- =================================
local m_dati
if
m_dati = args.dati
else▼
m_dati = { type = 'FeatureCollection', features = {} }
for i, point in ipairs(points) do
Riga 183 ⟶ 196:
end
m_dati = mw.text.jsonEncode(m_dati)
▲ else
end
|