模板:Infobox Settlement

来自悠日計画 維基百科 ~ Yuuni Wiki
103.136.127.220留言2022年9月21日 (三) 03:43的版本 (创建页面,内容为“-- -- This template will implement {{Infobox settlement}} -- local p = {} local math_module = require( "Module:Math" ) local precision = math_module._precision local infobox_module = require('Module:Infobox') local image_module = require('Module:InfoboxImage') local locationmap_module = require('Module:Location map') local function isnotempty(s) return s and s:match( '^%s*(.-)%s*$' ) ~= '' end local function firstnonempty(s) for i=1,#s do if (s[i] and s[i…”)

--

-- This template will implement <templatestyles src="Module:Infobox/styles.css"></templatestyles><templatestyles src="Infobox settlement/styles.css"></templatestyles>

Infobox Settlement
模板:Ifnoerror then show
Population
模板:Fix comma category

-- local p = {} local math_module = require( "Module:Math" ) local precision = math_module._precision local infobox_module = require('Module:Infobox') local image_module = require('Module:InfoboxImage') local locationmap_module = require('Module:Location map')

local function isnotempty(s) return s and s:match( '^%s*(.-)%s*$' ) ~= end

local function firstnonempty(s) for i=1,#s do if (s[i] and s[i]:match( '^%s*(.-)%s*$' ) ~= ) then return s[i] end end return end

local function yesno(s, yes, no, ukn, blank) -- this function implements yesno local vals = {['yes'] = 1, ['y'] = 1, ['1'] = 1, ['no'] = 0, ['n'] = 0, ['0'] = 0} if( s and s:match( '^%s*(.-)%s*$' ) ~= ) then local outval = vals(s:lower()) if( outval == nil ) then return ukn else return (outval == 1) and yes or no end else return blank end end

local function rnd(num, digits) -- This function implements Formatting error: invalid input when rounding return math_module._precision_format(tostring(num), tostring(digits)) end

local function order_of_magnitude(num) -- This function partially implements 0

   if( num ) then

num = math.abs(num) if( num == 0 ) then return 0 else return math.floor( math.log10(num) ) end else return 0 end end

local function page_exists( title )

   -- This function implements #ifexist
   local noError, titleObject = pcall(mw.title.new, title)
   if not noError then
       return false
   else
       if titleObject then
           return titleObject.exists
       else
           return false
       end
   end

end

local function link(pagelink, linktext, name)

   -- This function implements {{{type}}}
   pagelink = pagelink or 
   linktext = linktext or 
   name     = name or 
   
   if( pagelink ~=  ) then
       -- use "linktext"
       return string.format('%s', pagelink, linktext)
   else
       -- try "linktext"
       pagelink = string.format('%s of %s',linktext, mw.title.getCurrentTitle().text)
       if( page_exists( pagelink ) ) then
           return string.format('%s', pagelink, linktext)
       elseif( name ~=  ) then
           -- try "linktext"
           pagelink = string.format('%s of %s', linktext, name)
           if( page_exists(pagelink) ) then
              return string.format('%s', pagelink, linktext)
           end
       end
   end
   return linktext

end

local function columns(cell1, cell2, cell3, cell4)

   --- This function implements <templatestyles src="Infobox settlement/columns/styles.css"/>

with no cell0

   local function makecell( c1 )
       if isnotempty(c1) then

local root = mw.html.create('td') root:attr('align', 'center') :css('vertical-align', 'middle') :wikitext(c1)

           return tostring(root)
       end
       return 
   end
   
   local function makerow( c1, c2 )
       local root = mw.html.create()
       if isnotempty(c1) then
           if isnotempty(c2) then
           	root:tag('td')

:attr('align', 'center') :css('vertical-align', 'middle') :wikitext(c1) root:tag('td') :attr('align', 'center') :css('vertical-align', 'middle') :wikitext(c2)

           else
           	root:tag('td')

:attr('colspan', '2') :attr('align', 'center') :css('vertical-align', 'middle') :wikitext(c1)

           end
       elseif isnotempty(c2) then

root:tag('td') :attr('colspan', '2') :attr('align', 'center') :css('vertical-align', 'middle') :wikitext(c2)

       end
       return tostring(root)
   end
   
   local count = 0
   count = count + (isnotempty(cell1) and 1 or 0)
   count = count + (isnotempty(cell2) and 1 or 0)
   count = count + (isnotempty(cell3) and 1 or 0)
   count = count + (isnotempty(cell4) and 1 or 0)
   if(count > 0) then

local root = mw.html.create('table') root:css('width', '100%') :css('background', 'transparent') if(count > 2) then root:tag('tr') :wikitext(makerow(cell1, cell2)) root:tag('tr') :wikitext(makerow(cell3, cell4)) else root:tag('tr') :wikitext(makecell(cell1)) :wikitext(makecell(cell2)) :wikitext(makecell(cell3)) :wikitext(makecell(cell4)) end return tostring(root) else return end end

local function columns2(cell0, cell1, cell2, cell3, cell4, cell5)

   -- This function implements <templatestyles src="Infobox settlement/columns/styles.css"/>

with cell0

   local function makerow( c1 )

if isnotempty(c1) then local root = mw.html.create('tr') root:tag('td') :attr('align', 'center') :css('style', 'vertical-align:middle') :wikitext(c1) return tostring(root) else return end end

local count = 0 count = count + (isnotempty(cell1) and 1 or 0) count = count + (isnotempty(cell2) and 1 or 0) count = count + (isnotempty(cell3) and 1 or 0) count = count + (isnotempty(cell4) and 1 or 0) count = count + (isnotempty(cell5) and 1 or 0)

if(count > 0) then local root = mw.html.create('table') root:css('width', '100%') :css('background', 'transparent') local row = root:tag('tr') row :tag('td') :tag('table') :css('width', '100%') :css('background', 'transparent') :wikitext(makerow(cell1)) :wikitext(makerow(cell2)) :wikitext(makerow(cell3)) :wikitext(makerow(cell4)) :wikitext(makerow(cell5))

       if isnotempty(cell0) then

row :tag('td') :attr('align', 'center') :css('vertical-align', 'top') :wikitext(cell0) end return tostring(root) else return cell0 end end

local function translitlangbox(transtype, transinfo) local args = {} args['child'] = 'yes' local count = 0 for i=0,6 do if(isnotempty(transinfo[i]) and isnotempty(transtype[i])) then args['rowclass' .. tostring(i+1)] = isnotempty(transtype[i+1]) and 'mergedrow' or 'mergedbottomrow' args['label' .. tostring(i+1)] = ' • ' .. transtype[i] args['data' .. tostring(i+1)] = transinfo[i] count = count + 1 end end return ( count > 0 ) and args or nil end

local function unitpref(pref, region, unit_type)

   -- This function implements metric
   local pref_impus = { ['imperial'] = 1, ['english'] = 1, ['uk'] = 1, ['us'] = 1, 
       ['u.s.'] = 1, ['standard'] = 1, ['us customary'] = 1, ['u.s. customary'] = 1}
   local pr = (pref and pref:lower()) or 
   local r = region or 
   local u = unit_type or 
   pr = mw.ustring.gsub(pr, '^%s*([a-z].*[a-z\.])%s*$','%1')
   if( pref_impus[pr] ) then
       return 'impus'
   end
   if( mw.ustring.match( r, 'United States' ) ) then
       return 'impus'
   end
   if( mw.ustring.match( r, 'United Kingdom' ) ) then
       return 'impus'
   end
   if( (u .. '_' .. pr ) == 'area_dunam' ) then
       return 'dunam'
   end
   
   return 'metric'

end

local function areadisp(frame, pref, name, mag, ha, km2, sqmi, acre, dunam, percent, link)

   -- This function implements Formatting error: invalid input when rounding km2 (表达式错误:无法识别标点符号“{”。 acres)
   local function formatnum(num)
       return frame:callParserFunction{ name = 'formatnum', args = num }
   end
   
   local metv, metu = , 
   local impv, impu = , 
   local dunv, dunu = , 
   local lstr1, lstr2 = , 
   local rndv = 0
   
   pref = pref or 
   name = name or 
   mag = mag or 
   ha = ha or 
   km2 = km2 or 
   sqmi = sqmi or 
   acre = acre or 
   dunam = dunam or 
   percent = percent or 
   link = link or 
   
   if ( ha ~=  ) then
       metv = formatnum( ha )
       metu = 'ha'
   elseif ( km2 ~=  ) then
       metv = formatnum( km2 )
       metu = 'km2'
   elseif ( dunam ~=  ) then
       if (tonumber(dunam) < 1E3) then
           -- convert dunams to hectares
           metv = dunam/10
           metu = 'ha'
           rndv = precision(dunam)+1
           metv = rnd(metv,rndv)
       else
           -- convert dunams to square kilometers
           metv = dunam/1000
           metu = 'km2'
           rndv = precision(dunam)+3
           metv = rnd(metv,rndv)
       end
   elseif( acre ~=  ) then 
       -- convert acres to hectares
       metv = acre*0.4046856422
       metu = 'ha'
       rndv = math.max(precision(acre),-1*order_of_magnitude(metv))
       metv = rnd(metv,rndv)
   elseif( sqmi ~=  ) then
       -- convert sqmi to km2
       metv = sqmi*2.589988110336
       metu = 'km2'
       rndv = math.max(precision(sqmi)-1,-1*order_of_magnitude(metv))
       metv = rnd(metv,rndv)
   end
   if ( acre ~=  ) then
       impv = formatnum( acre )
       impu = 'acre'
   elseif ( sqmi ~=  ) then
       impv = formatnum( sqmi )
       impu = 'sq mi'
   elseif (ha ~=  ) then
       -- convert hectares to acres
       impv = ha/0.4046856422
       impu = 'acre'
       rndv = precision(ha)
       impv = rnd(impv,rndv)
   elseif (km2 ~=  ) then
       -- convert square kilometres to square miles
       impv = km2/2.589988110336
       impu = 'sq mi'
       rndv = math.max(precision(km2),-1*order_of_magnitude(impv))
       impv = rnd(impv,rndv)
   elseif (dunam ~=  ) then
       if (tonumber(dunam) < 2589) then
           -- convert dunams to acres
           impv = dunam/4.046856422
           impu = 'acre'
           rndv = math.max(precision(dunam),-1*order_of_magnitude(impv))
           impv = rnd(impv,rndv)
       else
           -- convert dunams to square miles
           impv = dunam/2589.988110336
           impu = 'sq mi'
           rndv = math.max(precision(dunam)+3,-1*order_of_magnitude(impv))
           impv = rnd(impv,rndv)
       end
   end
   if( mw.ustring.match(pref:lower(), '^%s*dunam%s*$') and (dunam == ) ) then
       if( km2 ~=  ) then
           -- convert square kilometres to dunams
           dunv = km2*1000
           rndv = precision(km2)-3
           dunv = rnd(dunv,rndv)
       elseif( ha ~=  ) then
           -- convert hectares to dunams
           dunv = ha*10
           rndv = precision(ha)-1
           dunv = rnd(dunv,rndv)
       elseif( sqmi ~=  ) then
           -- convert square miles to dunams
           dunv = sqmi*2589.988110336
           rndv = math.max(precision(sqmi)-4,-1*order_of_magnitude(dunv))
           dunv = rnd(dunv,rndv)
       elseif( acre ~=  ) then
           -- convert acres to dunams
           dunv = acre*4.046856422
           rndv = math.max(precision(acre)-1,-1*order_of_magnitude(dunv))
           dunv = rnd(dunv,rndv)
       end
   else
       dunv = formatnum( dunam )
   end
   if( link ~=  ) then
       dunu = 'dunum'
   else
       dunu = 'dunam'
   end
   
   if( (impu == 'acre') and (tonumber(impv) ~= 1) ) then
       impu = impu .. 's'
   end    
   if( tonumber(dunv) ~= 1 ) then
       dunu = dunu .. 's'
   end
   
   if( metv ~=  and impv ~=  ) then
       pref = unitpref(pref, name, 'area')
       if( percent ~=  ) then
           percent = '  ' .. percent .. '%'
       end
       
       if( mag ~=  ) then
           if( metu == 'ha' ) then
               lstr1 = tostring( order_of_magnitude( metv * 1E4 ) ) 
           else
               lstr1 = tostring( order_of_magnitude( metv * 1E6 ) )
           end
           lstr1 = ''
            lstr2 = ''
        end
  
        if( pref == 'impus' ) then
            return string.format('%s %s (%s%s %s%s)%s', 
                impv, impu, lstr1, metv, metu, lstr2, percent)
        elseif ( pref == 'dunam' ) then
            return string.format('%s %s (%s%s %s%s or %s %s)%s', 
                dunv, dunu, lstr1, metv, metu, lstr2, impv, impu, percent)
        else
            return string.format('%s%s %s%s (%s %s)%s', 
                lstr1, metv, metu, lstr2, impv, impu, percent)
        end
    end

end

local function densdisp(frame, pref, name, perkm2, persqmi, pop, ha, km2, sqmi, acre, dunam)

   -- This function implements 
   local function numorzero( num )
       num = num or 
       num = tonumber(frame:callParserFunction{ name = 'formatnum', args = {num, 'R'}})
       if( num == nil ) then
           return 0
       else
           return num
       end
   end
   local function formatnum(num)
       return frame:callParserFunction{ name = 'formatnum', args = num }
   end
   
   local function formatnumR(num)
       return frame:callParserFunction{ name = 'formatnum', args = {num, 'R'} }
   end
   local metv, metu = , 'km2'
   local impv, impu = , 'sq mi'
   local rndv = 0
   local perkm2num = tonumber(formatnumR(perkm2 or ))
   local persqminum = tonumber(formatnumR(persqmi or ))
   local popnum = tonumber(formatnumR(pop or ))
   pref = pref or 
   name = name or 
   perkm2 = perkm2 or 
   persqmi = persqmi or 
   pop = pop or 
   ha = numorzero(ha)
   km2 = numorzero(km2)
   acre = numorzero(acre)
   sqmi = numorzero(sqmi)
   dunam = numorzero(dunam)
   
   if( (perkm2num == nil) and (persqminum == nil) ) then
      if( mw.ustring.match(perkm2:lower(), '^%s*auto%s*$') or mw.ustring.match(persqmi:lower(), '^%s*auto%s*$') ) then
          if( popnum ~= nil ) then
              if( km2 > 0 ) then
                  metv = popnum/km2
                  rndv = 1 - order_of_magnitude(metv)
                  metv = rnd(metv,rndv)
              elseif( ha > 0 ) then
                  metv = 100*popnum/ha
                  rndv = 1 - order_of_magnitude(metv)
                  metv = rnd(metv,rndv)
              elseif( dunam > 0 ) then
                  metv = 1000*popnum/dunam
                  rndv = 1 - order_of_magnitude(metv)
                  metv = rnd(metv,rndv)
              elseif( acre > 0 ) then
                  metv = (popnum/acre)/0.004046856422
                  rndv = 1 - order_of_magnitude(metv)
                  metv = rnd(metv,rndv)
              elseif( sqmi > 0 ) then
                  metv = (popnum/sqmi)/2.589988110336
                  rndv = 1 - order_of_magnitude(metv)
                  metv = rnd(metv,rndv)
              end
              if( sqmi > 0 ) then
                  impv = popnum/sqmi
                  rndv = 1 - order_of_magnitude(impv)
                  impv = rnd(impv,rndv)
              elseif( acre > 0 ) then
                  impv = 640*popnum/acre
                    rndv = 1 - order_of_magnitude(impv)
                  impv = rnd(impv,rndv)
              elseif( km2 > 0 ) then
                  impv = 2.589988110336*popnum/km2
                  rndv = 1 - order_of_magnitude(impv)
                  impv = rnd(impv,rndv)
              elseif( ha > 0 ) then
                  impv = 258.9988110336*popnum/ha
                  rndv = 1 - order_of_magnitude(impv)
                  impv = rnd(impv,rndv)
              elseif( dunam > 0 ) then
                  impv = 2589.988110336*popnum/dunam
                  rndv = 1 - order_of_magnitude(impv)
                  impv = rnd(impv,rndv)
              end
          end
      end
  elseif( perkm2num ~= nil ) then
      if( persqminum ~= nil ) then
          metv = formatnum( perkm2 )
          impv = formatnum( persqmi )
      else
          metv = formatnum( perkm2 )
          impv = perkm2num*2.589988110336
          rndv = math.max(precision(perkm2num)-1,-1*order_of_magnitude(impv)) 
          impv = rnd(impv,rndv)
      end
   elseif( persqminum ~= nil ) then
       metv = persqminum/2.589988110336
       rndv = math.max(precision(persqminum),-1*order_of_magnitude(metv))
       metv = rnd(metv,rndv)
       impv = formatnum( persqmi )
   end
   if( metv ~=  and impv ~= ) then
     pref = unitpref(pref, name, 'area')
     if( pref == 'impus' ) then
        return string.format('%s/%s (%s/%s)', impv, impu, metv, metu)
     else
        return string.format('%s/%s (%s/%s)', metv, metu, impv, impu)
     end
   else
     return 
   end  

end

local function lengthdisp(frame, pref, name, km, m, mi, ft)

   -- This function implements Formatting error: invalid input when rounding m (模板:HidFormatting error: invalid input when rounding ft)
   local function formatnum(num)
       return frame:callParserFunction{ name = 'formatnum', args = num }
   end
   
   local metv, metu = , 
   local impv, impu = , 
   local rndv = 0
   pref = pref or 
   name = name or 
   m = m or 
   km = km or 
   ft = ft or 
   mi = mi or 
   
   if ( km ~=  ) then
       metv = formatnum( km )
       metu = 'km'
   elseif ( m ~=  ) then
       metv = formatnum( m )
       metu = 'm'
   elseif ( mi ~=  ) then
       metv = mi*1.609344
       metu = 'km'
       rndv = precision(mi)
       metv = rnd(metv,rndv)
   elseif ( ft ~=  ) then
       metv = ft*0.3048
       metu = 'm'
       rndv = math.max(precision(ft),-1*order_of_magnitude(metv))
       metv = rnd(metv,rndv)
   end
   
   if ( mi ~=  ) then
       impv = formatnum( mi )
       impu = 'mi'
   elseif ( ft ~=  ) then
       impv = formatnum( ft )
       impu = 'ft'
   elseif ( km ~=  ) then
       impv = km/1.609344
       impu = 'mi'
       rndv = math.max(precision(km),-1*order_of_magnitude(impv))
       impv = rnd(impv,rndv)
   elseif ( m ~=  ) then
       impv = m/0.3048
       impu = 'ft'
       rndv = precision(m)
       impv = rnd(impv,rndv)
   end
   
   if( impv ~=  and metv ~=  ) then
       pref = unitpref(pref, name, 'length')
       if( pref == 'impus' ) then
          return string.format('%s %s (%s %s)', impv, impu, metv, metu)
       else
          return string.format('%s %s (%s %s)', metv, metu, impv, impu)
       end
   else
       return 
   end    

end

function p.areadisp(frame)

   local args = frame.args
   return areadisp(frame, args['pref'], args['name'], args['mag'], 
       args['ha'], args['km2'], args['sqmi'], args['acre'], args['dunam'], args['percent'], args['link'])

end

function p.densdisp(frame)

   local args = frame.args
   return densdisp(frame, args['pref'], args['name'], 
       args['/km2'], args['/sqmi'], args['pop'], args['ha'], args['km2'], args['sqmi'], args['acre'], args['dunam'])

end

function p.lengthdisp(frame)

   local args = frame.args
   return lengthdisp(frame, args['pref'], args['name'], args['km'], args['m'], args['mi'], args['ft'])

end

function p.link(frame)

   local args = frame.args
   return link(args['link'], args['type'], args['name'])

end

function p.columns(frame)

   local args = frame.args
   if( args[0] and args[0] ~=  ) then
     return columns2(args[0], args[1], args[2], args[3], args[4], args[5])
   else
     return columns(args[1], args[2], args[3], args[4])
   end

end

function p.infobox(frame)

   local args = {}
   local oargs = frame:getParent().args
   local pname = firstnonempty({oargs['name'], oargs['official_name'], mw.title.text})
   local narrowmap = isnotempty(oargs['pushpin_map_narrow']) and isnotempty(oargs['pushpin_map'])
   args['bodyclass'] = 'geography vcard'
   args['bodystyle'] = 'width:23em'
   args['headerstyle'] = 'text-align:left'
   args['abovestyle'] = 'font-size:1.25em; white-space:nowrap'
   -- build the names, type, and transliterations subbox
   local sargs = {}
   local scount = 0
   sargs['child'] = 'yes'
   if( (isnotempty(oargs['name']) or isnotempty(oargs['official_name']) ) and
   	(isnotempty(oargs['settlement_type']) or isnotempty(oargs['type']) ) ) then

sargs['subheaderstyle'] = 'background-color:#cddeff; font-weight:bold;'

   	sargs['subheader'] = ''
   		.. firstnonempty(oargs['settlement_type'], oargs['type']) .. ''
   	scount = scount + 1
   end
   if( isnotempty(oargs['name']) and isnotempty(oargs['official_name']) ) then
   	sargs['rowclass1'] = 'mergedtoprow'
   	sargs['header1'] = oargs['official_name']
   	scount = scount + 1
   end
   if( isnotempty(oargs['translit_lang1']) ) then
   	local targs = translitlangbox(
   		{oargs['translit_lang1_type'],
   		 oargs['translit_lang1_type1'],
   		 oargs['translit_lang1_type2'],
   		 oargs['translit_lang1_type3'],
   		 oargs['translit_lang1_type4'],
   		 oargs['translit_lang1_type5'],
   		 oargs['translit_lang1_type6']},
   		{oargs['translit_lang1_info'],
   		 oargs['translit_lang1_info1'],
   		 oargs['translit_lang1_info2'],
   		 oargs['translit_lang1_info3'],
   		 oargs['translit_lang1_info4'],
   		 oargs['translit_lang1_info5'],
   		 oargs['translit_lang1_info6']})
   	if( targs ) then
   		sargs['rowclass2'] = 'mergedtoprow'
   		sargs['header2'] = oargs['translit_lang1'] .. ' transcription(s)' .. infobox_module._infobox(targs)

scount = scount + 1

   	end
   end
   if( isnotempty(oargs['translit_lang2']) ) then
   	local targs = translitlangbox(
   		{oargs['translit_lang2_type'],
   		 oargs['translit_lang2_type1'],
   		 oargs['translit_lang2_type2'],
   		 oargs['translit_lang2_type3'],
   		 oargs['translit_lang2_type4'],
   		 oargs['translit_lang2_type5'],
   		 oargs['translit_lang2_type6']},
   		{oargs['translit_lang2_info'],
   		 oargs['translit_lang2_info1'],
   		 oargs['translit_lang2_info2'],
   		 oargs['translit_lang2_info3'],
   		 oargs['translit_lang2_info4'],
   		 oargs['translit_lang2_info5'],
   		 oargs['translit_lang2_info6']})
   	if( targs ) then
   		sargs['rowclass3'] = 'mergedtoprow'
   		sargs['header3'] = oargs['translit_lang2'] .. ' transcription(s)' .. infobox_module._infobox(targs)

scount = scount + 1

   	end

end

   -- End of names, type, and transliterations
   args['above'] =  '' .. pname .. ''
   if(isnotempty(oargs['native_name'])) then
   	args['above'] = args['above'] .. '
' .. oargs['native_name'] .. '' end if(isnotempty(oargs['other_name'])) then args['above'] = args['above'] .. '
' .. oargs['other_name'] .. '' end if( scount > 0 ) then

args['above'] = args['above'] .. infobox_module._infobox(sargs) end -- Skyline image if( isnotempty(oargs['image_skyline']) ) then args['imagestyle'] = 'padding:0.7em 0.8em' args['image'] = image_module._InfoboxImage( {['image'] = oargs['image_skyline'], ['size'] = oargs['imagesize'], ['sizedefault'] = '250px', ['alt'] = oargs['image_alt'], ['title'] = oargs['image_caption'] or ('Skyline of ' .. pname) }) if( isnotempty(oargs['image_caption']) ) then args['image'] = args['image'] .. '
' .. oargs['image_caption'] .. '' end end -- Other image if( isnotempty(oargs['image']) ) then args['image2'] = oargs['image'] end -- Primary map local image_map = nil if( isnotempty(oargs['image_map']) ) then local msize = narrowmap and '100px' or '250px'

image_map = image_module._InfoboxImage({ ['image'] = oargs['image_map'], ['size'] = oargs['mapsize'], ['sizedefault'] = msize, ['alt'] = oargs['map_alt'], ['title'] = oargs['map_caption'] or 'Location of ' .. pname, }) if( isnotempty(oargs['map_caption'])) then image_map = image_map .. '
' .. oargs['map_caption'] .. '' end end -- Primary pushpin map local pushpin_map = nil if( isnotempty(oargs['pushpin_map']) and isnotempty(oargs['latd']) and isnotempty(oargs['longd'])) then local plabel if(oargs['pushpin_label_position'] and oargs['pushpin_label_position']:lower() == 'none') then plabel = else if( isnotempty(oargs['pushpin_label']) ) then plabel = oargs['pushpin_label'] else plabel = pname end local pwidth = if(narrowmap) then pwidth = firstnonempty(oargs['pushpin_mapsize'], '150') end local lat, lat_deg, lat_min, lat_sec if(isnotempty(oargs['latm']) or isnotempty(oargs['latNS'])) then lat = lat_deg = oargs['latd'] or lat_min = oargs['latm'] or lat_sec = oargs['lats'] or else lat = oargs['latd'] or end local long, lon_deg, lon_min, lon_sec if(isnotempty(oargs['longm']) or isnotempty(oargs['longEW'])) then long = lon_deg = oargs['longd'] or lon_min = oargs['longm'] or lon_sec = oargs['longs'] or else long = oargs['longd'] or end local caption = firstnonempty({oargs['pushpin_map_caption'], oargs['map_caption']})

pushpin_map = '

' .. locationmap_module._main({

['1'] = oargs['pushpin_map'], ['border'] = 'none', ['alt'] = oargs['pushpin_map_alt'], ['caption'] = , ['float'] = 'none', ['width'] = pwidth, ['default_width'] = '250', ['relief'] = oargs['pushpin_relief'], ['AlternativeMap'] = oargs['pushpin_image'], ['label'] = plabel, ['lat'] = lat, ['long'] = long, ['lat_deg'] = lat_deg, ['lat_min'] = lat_min, ['lat_sec'] = lat_sec, ['lat_dir'] = oargs['latNS'] or , ['lon_deg'] = lon_deg, ['lon_min'] = lon_min, ['lon_sec'] = lon_sec, ['lon_dir'] = oargs['lonEW'] or , ['marksize'] = '6', ['position'] = oargs['pushpin_label_position'] or }) if( caption ) then pushpin_map = pushpin_map .. '' .. caption .. '' end

pushpin_map = pushpin_map .. '

'

end end -- Flag, Seal, Shield and Coat of arms if( isnotempty(oargs['image_flag']) or isnotempty(oargs['image_seal']) or isnotempty(oargs['image_shield']) or isnotempty(oargs['image_blank_emblem']) or narrowmap) then args['rowclass1'] = 'mergedtoprow' args['class1'] = 'maptable' local isize = (isnotempty(oargs['pushpin_map_narrow']) and isnotempty(oargs['pushpin_map'])) and '85px' or '100px' local targs = {} if( isnotempty(oargs['image_flag']) ) then local iborder = yesno(oargs['flag_border'], 'yes', , 'yes', 'yes') targs[1] = image_module._InfoboxImage({ ['image'] = oargs['image_flag'], ['size'] = oargs['flag_size'], ['sizedefault'] = isize, ['border'] = iborder, ['alt'] = oargs['flag_alt'], ['title'] = 'Flag of ' .. pname, }) .. '
\'\'\ .. link(oargs['flag_link'], 'Flag', oargs['official_name']) .. '\'\'\'' end if( isnotempty(oargs['image_seal']) ) then targs[2] = image_module._InfoboxImage({ ['image'] = oargs['image_seal'], ['size'] = oargs['seal_size'], ['sizedefault'] = isize, ['alt'] = oargs['seal_alt'], ['title'] = 'Official seal of ' .. pname, }) .. '
\'\'\ .. link(oargs['seal_link'], firstnonempty(oargs['seal_type'], 'Seal'), oargs['official_name']) .. '\'\'\'' end if( isnotempty(oargs['image_shield']) ) then targs[3] = image_module._InfoboxImage({ ['image'] = oargs['image_shield'], ['size'] = oargs['shield_size'], ['sizedefault'] = isize, ['alt'] = oargs['shield_alt'], ['title'] = 'Coat of arms of ' .. pname, }) .. '
\'\'\ .. link(oargs['shield_link'], 'Coat of arms', oargs['official_name']) .. '\'\'\'' end if( isnotempty(oargs['image_blank_emblem']) ) then targs[4] = image_module._InfoboxImage({ ['image'] = oargs['image_blank_emblem'], ['size'] = oargs['blank_emblem_size'], ['sizedefault'] = isize, ['alt'] = oargs['blank_emblem_alt'], ['title'] = 'Official logo of ' .. pname, }) .. '
\'\'\ .. link(oargs['blank_emblem_link'], firstnonempty(oargs['blank_emblem_type'], 'Logo'), oargs['official_name']) .. '\'\'\'' end targs[5] = image_map if( narrowmap and pushpin_map) then args['data1'] = columns2(pushpin_map, targs[1], targs[2], targs[3], targs[4], targs[5]) else args['data1'] = columns(targs[1], targs[2], targs[3], targs[4]) end end -- Nickname if( isnotempty(oargs['nickname']) ) then args['rowclass2'] = 'mergedrow' args['data2'] = 'Nickname(s): ' .. oargs['nickname'] .. '' end -- Motto if( isnotempty(oargs['motto']) ) then args['rowclass3'] = 'mergedrow' args['data3'] = 'Motto: ' .. oargs['motto'] end -- Anthem if( isnotempty(oargs['anthem']) ) then args['rowclass4'] = 'mergedrow' args['data4'] = 'Anthem: ' .. oargs['anthem'] end -- Map if( narrowmap and image_map ) then args['rowclass5'] = mergedrow args['data5'] = image_map end if( isnotempty(oargs['image_map1']) ) then args['rowclass6'] = mergedrow args['data6'] = image_module._InfoboxImage({ ['image'] = oargs['image_map1'], ['size'] = oargs['mapsize1'], ['sizedefault'] = '250px', ['alt'] = oargs['map_alt1'], ['title'] = oargs['map_caption1'] or 'Location of ' .. pname, }) if( isnotempty(oargs['map_caption1'])) then image_map = image_map .. '
' .. oargs['map_caption1'] .. '' end end -- Dot map if( isnotempty(oargs['image_dot_map']) ) then args['rowclass7'] = 'mergedrow'

args['data7'] = '

Dot maps not supported!

'

end

   -- Pushpin map

if( narrowmap == nil and pushpin_map) then args['rowclass8'] = 'mergedtoprow' args['data8'] = pushpin_map end

   return infobox_module._infobox(args)

end

return p