require('strict')local getArgs = require('Module:Arguments').getArgs
local patterns =
local params = ; -- template paramters
----------------------------< I S _ S E T >------------------------------------------------------------------
Whether variable is set or not. A variable is set when it is not nil and not empty.
local function is_set(var) return not (var
);end
--from=Q...}} 2 = coordinate parameters; see Template:Coord Also takes the named parameters |display=, |format=, |name=, |notes= which it passes on to
Reformats the Wikidata coordinate string into unnamed parameters for
local function main (frame) local args = getArgs(frame); local lat_long = ; -- table of lat/long coords extracted from wikidata return if not is_set (args[1]) then -- in case wikidata returns nothing (happens when Q... is wrong) return '
– missing coordinate data'; -- error message and quit else for _, pattern in ipairs (patterns) do lat_long[1], lat_long[2], lat_long[3], lat_long[4], lat_long[5], lat_long[6], lat_long[7], lat_long[8] = mw.ustring.match (args[1], pattern) if lat_long[1] then break; end end endif not lat_long[1] then return '
– malformed coordinate data'; -- wikidata returned something else end if is_set (args[2]) then -- coordinate parameters are in second unnammed positional parameter table.insert (lat_long, args[2]); -- add coordinate parameters as next positional parameter after coordnates endfor _, param in ipairs (params) do if is_set (args[param]) then lat_long[param] = args[param]; -- add the named parameters if they have a value end end
if args._debug then return table.concat ; end return frame:expandTemplate ; -- invoke template with wikidata lat/longend
----------------------------< E X P O R T E D F U N C T I O N >--------------------------------------------
return