Module:Location map: Difference between revisions

Jump to navigation Jump to search
m (1 revision imported)
m (1 revision imported)
 
(One intermediate revision by the same user not shown)
Line 28: Line 28:
else
else
return mapData[name]
return mapData[name]
end
end
elseif mw.title.new('Template:Location map ' .. map).exists then
local cache = {}
if type(frame) ~= 'table' or type(frame.expandTemplate) ~= 'function' then
error('A frame must be provided when using a legacy location map')
end
return function(name, params)
if params then
return frame:expandTemplate{title = 'Location map ' .. map, args = { name, unpack(params) }}
else
if name == nil then
return 'Template:Location map ' .. map
elseif cache[name] == nil then
cache[name] = frame:expandTemplate{title = 'Location map ' .. map, args = { name }}
end
return cache[name]
end
end
end
end
else
else
error('Unable to find the specified location map definition. Neither "Module:Location map/data/' .. map .. '" nor "Template:Location map ' .. map .. '" exists', 2)
error('Unable to find the specified location map definition: "Module:Location map/data/' .. map .. '" does not exist', 2)
end
end
end
end
Line 400: Line 383:
end
end
local builder = mw.html.create()
if args.coordinates then
if args.coordinates then
-- Temporarily removed to facilitate infobox conversion. See [[Wikipedia:Coordinates in infoboxes]]
-- Temporarily removed to facilitate infobox conversion. See [[Wikipedia:Coordinates in infoboxes]]
Line 414: Line 398:
local value = entity.claims.P625[1].mainsnak.datavalue.value
local value = entity.claims.P625[1].mainsnak.datavalue.value
longitude, latitude = value.longitude, value.latitude
longitude, latitude = value.longitude, value.latitude
end
if args.link then
builder:wikitext('[[Category:Location maps with linked markers with coordinates from Wikidata]]')
end
end
end
end
Line 421: Line 408:
error('No value was provided for latitude')
error('No value was provided for latitude')
end
end
local builder = mw.html.create()
if (not args.lon_deg) ~= (not args.lat_deg) then
if (not args.lon_deg) ~= (not args.lat_deg) then
builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Degrees]]')
builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Degrees]]')