Modulo:Sandbox/Laurentius
Vai alla navigazione
Vai alla ricerca
-- Modulo per gestire le liste di monumenti di Wiki Loves Monuments
require('strict')
local getArgs = require('Module:Arguments').getArgs
local mWikidata = require('Modulo:Wikidata')
local p = {}
function p.map_point(qid)
local data = {}
local desc = ''
desc = desc .. '{{WLM-link-2019|' .. qid .. '}}'
local img = mWikidata._getProperty({'P18', from = qid, snaktype = 'value', n=1, pattern="[[File:$1|200px]]"})
if img then
desc = desc .. '<br/>' .. img
end
data.type = "Feature"
data.properties = {
title = mWikidata._getLink({qid}),
description = desc,
["marker-color"] = "#B80000"
}
data.geometry = {
type = "Point",
coordinates = {
tonumber(mWikidata._getProperty({'P625', from = qid, snaktype = 'value', coord='longitude', n=1})),
tonumber(mWikidata._getProperty({'P625', from = qid, snaktype = 'value', coord='latitude', n=1}))
}
}
return data
end
function p._map_data(args)
local points = {}
if args.area then
local shape = {
type = "ExternalData",
service = "geoshape",
ids = args.area,
service = "geomask"
}
table.insert(points, shape)
end
for _, qid in ipairs(args) do
if mWikidata._getProperty({'P625', from = qid, snaktype = 'value'}) then
table.insert(points, p.map_point(qid))
end
end
return mw.text.jsonEncode(points)
end
function p.map_data(frame)
local args = getArgs(frame)
return p._map_data(args)
end
return p