local getArgs = require('Module:Arguments').getArgs
local p = {}
local function dataValue(frame, settlementName, parameterName, itemName)
return frame:expandTemplate{ title = 'Data '..settlementName..' municipality', args = {
parameterName,
itemName
}}
end
local function getNetValue(frame, argName)
local args = getArgs(frame)
local argType = args['arg_type']
local net = args['area_'..argType..'_'..argName] or dataValue(frame, args['subdivision_name'], 'area_'..argType..'_'..argName, args['name'])
return net
end
function p.nativeName(frame)
local val = frame.args[1]
if val then
local match = mw.ustring.match(val, "{{[Ii]nfobox (%a*)")
--if true then return match end
if match and match[1] then
return match[1]
end
end
return ""
end
function p.area(frame)
local args = getArgs(frame)
local km2 = getNetValue(frame, 'km2')
local ha = getNetValue(frame, 'ha')
local acre = getNetValue(frame, 'acre')
local sqmi = getNetValue(frame, 'sq_mi')
local dunam = getNetValue(frame, 'dunam')
if km2 or ha or acre or sqmi or dunam then
return frame:expandTemplate{ title = 'infobox_settlement/areadisp', args = {
['km2'] = km2,
['ha'] = ha,
['acre'] = acre,
['sqmi'] = sqmi,
['dunam'] = dunam,
['link'] = args['dunam_link'],
['pref'] = args['unit_pref'],
['name'] = args['subdivision_name'],
['mag'] = args['area_magnitude']
}}
else
return ""
end
end
return p