-- mw.log(p.test( { args = { "test" , "cucu" } } ))
local p = {}
-- ids degli elementi delle comunità di valle
local comunita = { "Q1123817", "Q3685385", "Q3685509", "Q3685510", "Q3685526", "Q3685528", "Q3685546", "Q3685547", "Q3685548", "Q3685550", "Q3685551", "Q3685552", "Q3685557", "Q3685880", "Q3843316", "Q1974020" }
local colors = {}
colors.default = "#FDFBEA"
colors.focus = "#C12838"
colors.one = "#a6b2e7" -- blue
colors.two = "#dba6e7" -- red
colors.three = "#e7dba6" -- yellow
colors.four = "#b2e7a6" -- green
local single_map = {}
local res = {}
--
-- COMUNITA DI VALLE
--
local json_string = [[{
"type":"ExternalData",
"service":"geoshape",
"ids":"",
"properties":{
"fill":"",
"fill-opacity":0.7,
"stroke-opacity":1,
"stroke-width":2,
"stroke":"#555555"
}
}]]
function p._oneElementMap ( qid, col )
single_map = mw.text.jsonDecode( json_string )
single_map.ids = qid
single_map.properties.fill = col
return single_map
end
function p.getData ( frame )
for i, qid in ipairs( comunita ) do
if frame.args[1] == qid then
el = p._oneElementMap ( qid, colors.focus )
else
el = p._oneElementMap ( qid, colors.default )
end
table.insert(res, el)
end
j = mw.text.jsonEncode ( res )
res = {}
return j
end
--
-- REGIONI ITALIANE
--
local regioni_wikidata_sparql_query = [[
SELECT
?id
( concat( ']] .. "[[" ..[[', ?regionLabel, ']] .. "]]" .. [[' ) as ?title )
( if(?idString = 'http://www.wikidata.org/entity/Q1237', '#C12838', '#FDFBEA') as ?fill )
WHERE {
?id wdt:P31/wdt:P279* wd:Q16110 .
BIND( STR(?id) AS ?idString ) .
SERVICE wikibase:label {
bd:serviceParam wikibase:language 'it' .
?id rdfs:label ?regionLabel .
}
}]]
p.regioni_json = [[{
"type": "ExternalData",
"service": "geoshape",
"query": "]] .. regioni_wikidata_sparql_query .. [["
}]]
return p