Module:Geonotice map
Appearance
Helps admins visualize geonotices. See the output at Wikipedia:Geonotice/Map.
-- If the "country": "GB" feature is used instead of "corners", we need the Wikidata ID of the country for the map to use
local countries = {
GB = "Q145"
}
local p = {}
function p.main(frame)
local data = mw.text.jsonDecode(mw.title.new("Wikipedia:Geonotice/list.json"):getContent())
local geojson = {}
for name, info in pairs(data) do
local properties = {
title = name,
description = info.text .. "<br>(Start: " .. info.begin .. ", end: " .. info["end"] .. ")"
}
local feature
if info.country ~= nil then
feature = {
type = "ExternalData",
service = "geoshape",
ids = countries[info.country],
properties = properties
}
else
feature = {
type = "Feature",
properties = properties,
geometry = {
type = "Polygon",
-- note that GeoJSON is lon, lat while Geonotice is lat, lon. sigh.
coordinates = { {
{ info.corners[1][2], info.corners[1][1] },
{ info.corners[2][2], info.corners[1][1] },
{ info.corners[2][2], info.corners[2][1] },
{ info.corners[1][2], info.corners[2][1] },
{ info.corners[1][2], info.corners[1][1] }
} }
}
}
end
table.insert(geojson, feature)
end
local width = frame.args.width or "full"
local height = frame.args.height or "500"
return frame:extensionTag{ name = 'mapframe', content = mw.text.jsonEncode(geojson), args = { width = width, height = height } }
end
return p