Module:Sandbox/InneswAustralian place map-upgrade explained

-- This module implements the selection of the location map in and

-- Re-written to ensure values of the map_type parameter take precedence over 'legacy' parameters alternative_location_map, force_national_map and use_lga_map.-- Also takes 'no' as a value in these legacy parameters to mean 'no' (the same as ), not 'yes'.

require('strict')local p =

local function isnotblank(s) return s and s ~= end

local function isnot_blankorno(s) if s

'no' then return false else return isnotblank(s) endend

local statenames =

local mapwidths =

function p.main(frame) local largs = frame:getParent.args local place_type = (largs.type or ):lower local map_type = (largs.map_type or 'auto'):lower local state_abbr = (largs.state or ):lower local map_width = 270 local coords = largs.coordinates or local coordsa = largs.coordinates_a or local coordsb = largs.coordinates_b or local map_name if isnotblank(coords) or isnotblank(coordsa) then else map_type = 'nomap' end -- the valid normal values for map_type are 'national', 'australia', 'state', 'lga', 'nomap' and 'auto'. and mean the same as 'auto'. -- any other value is assumed to be a valid map name, or a series of valid map names separated by '#' -- if map_type = 'auto' or equivalent: -- alternative_location_map is assumed to be a valid map name (or names) -- force_national_map substitutes for map_type = 'national' -- use_lga_map substitutes for map_type = 'lga' -- if none of the above: -- if |type = 'lga', no map is shown -- otherwise the state map is shown

if map_type

'national' or map_type

'australia' then map_name = 'Australia' elseif map_type

'state' then map_name = 'Australia ' .. (statenames[state_abbr] or ) map_width = mapwidths[state_abbr] or 270 elseif map_type

'lga' then map_name = 'Australia ' .. (statenames[state_abbr] or ) .. ' ' .. (largs.lga or ) map_width = mapwidths[state_abbr] or 270 elseif map_type

'nomap' then -- no map! elseif map_type

'auto' or map_type

then -- legacy parameters, or defaults if isnot_blankorno(largs.alternative_location_map) then map_name = largs.alternative_location_map elseif isnot_blankorno(largs.force_national_map) then map_name = 'Australia' elseif isnot_blankorno(largs.use_lga_map) then map_name = 'Australia ' .. (statenames[state_abbr] or ) .. ' ' .. (largs.lga or ) map_width = mapwidths[state_abbr] or 270 elseif place_type

'lga' then -- default for LGAs is no map map_type = 'nomap' else -- default for all other place types is the state map map_name = 'Australia ' .. (statenames[state_abbr] or ) map_width = mapwidths[state_abbr] or 270 end else -- map_type assumed to be a valid map name, or a series of valid map names separated by '#' map_name = map_type map_type = 'altmap' end -- Build the map if map_type ~= 'nomap' then local caption = largs.pushpin_map_caption or if caption ~= then caption = '

' .. caption .. '

' end if isnotblank(coordsa) then -- a map for Infobox_Australian_road return frame:expandTemplate else -- a map for Infobox_Australian_place return frame:expandTemplate end end return end

return p