Difference between revisions of "Template:Infobox settlement/checkauto/doc"

From blackwiki
Jump to navigation Jump to search
imported>MSGJ
(notice)
imported>Zyxw
(update out-of-date documentation)
Line 2: Line 2:
 
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
 
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
 
{{notice|'''This subtemplate is not intended to be used directly'''}}
 
{{notice|'''This subtemplate is not intended to be used directly'''}}
This '''subtemplate of {{Tl|Infobox settlement}}''' checks the inputs passed to {{Tl|Infobox settlement/densdisp}} when the ''auto'' option is used.
+
This '''subtemplate of {{Tl|Infobox settlement}}''' checks the inputs that will be passed to {{Tl|Infobox settlement/densdisp}} if there is a density to be displayed. This template outputs the density either as provided or as calculated (if set to auto). The automatic calculation requires both the population and area; if either is not provided then this template generates no output.
  
 
=== Usage ===
 
=== Usage ===
:<code><nowiki>{{Infobox settlement/checkauto|DENSsqmi|POP|AREAsqmi}}</nowiki></code>
+
<nowiki>{{</nowiki>Infobox settlement/checkauto
or
+
| /km2  = ''auto'' or population density per [[km2]] (via ''population_density_km2'' and others)
:<code><nowiki>{{Infobox settlement/checkauto|DENSkm2|POP|AREAkm2}}</nowiki></code>
+
| /sqmi = ''auto'' or population density per [[sqmi]] (via ''population_density_sq_mi'' and others)
 +
| pop  = population (via ''population_total'' and others)
 +
| km2  = area in square kilometres (via ''area_total_km2'' and others)
 +
| sqmi  = area in square miles (via ''area_total_sq_mi'' and others)
 +
| ha    = area in [[hectare]]s (via ''area_total_ha'' and others)
 +
| acre  = area in [[acre]]s (via ''area_total_acre'' and others)
 +
| dunam = area in [[dunam]]s (via ''area_total_dunam'' and others)
 +
}}
  
where ''DENSsqmi'' is the density per square mile, ''DENSkm2'' is the density per square kilometer, ''POP'' is the population, ''AREAsqmi'' is the area in square miles, and ''AREAkm2'' is the area in square kilometers. See {{Tl|Infobox settlement/densdisp}} for more details.
+
=== Examples with density auto ===
 +
As shown in the following examples, this template calculates the density if all three of the following conditions are met: /km2 (or /sqmi) is set to auto, a number if given for population, and a number is given for area. It also strips any formatting from the numbers, such as population with commas in the examples, which would otherwise cause an error in the calculation (see [[mw:Help:Magic words#Formatting]]).
 +
{| class="wikitable"
 +
!Code
 +
!Result
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/checkauto|/km2=auto|pop=123,456|km2=10}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2=auto|pop=123,456|km2=10}}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/checkauto|/km2=auto|pop= |km2=10}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2=auto|pop= |km2=10}}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/checkauto|/km2=auto|pop=123,456|km2= }}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2=auto|pop=123,456|km2= }}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/checkauto|/km2=auto|pop= |km2= }}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2=auto|pop= |km2= }}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/checkauto|/km2= |pop= |km2= }}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2= |pop= |km2= }}
 +
|}
  
{| class="wikitable" border=1
+
=== Examples with density number ===
 +
As shown in the following examples, this template always displays the density if given as a number, regardless of whether the population and area are defined. It also strips any formatting in the number, such as the commas in the examples.
 +
{| class="wikitable"
 
!Code
 
!Code
 
!Result
 
!Result
 
|-
 
|-
|style="padding: 20px"|<code><nowiki>{{Infobox settlement/checkauto|2|30|15}}</nowiki></code>
+
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/checkauto|/km2=12,345.6|pop=123,456|km2=10}}</nowiki></code>
|style="padding: 20px"|{{Infobox settlement/checkauto|2|30|15}}
+
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2=12,345.6|pop=123,456|km2=10}}
 
|-
 
|-
|style="padding: 20px"|<code><nowiki>{{Infobox settlement/checkauto|auto|30|15}}</nowiki></code>
+
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/checkauto|/km2=12,345.6|pop= |km2=10}}</nowiki></code>
|style="padding: 20px"|{{Infobox settlement/checkauto|auto|30|15}}
+
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2=12,345.6|pop= |km2=10}}
 
|-
 
|-
|style="padding: 20px"|<code><nowiki>{{Infobox settlement/checkauto|auto| |15}}</nowiki></code>
+
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/checkauto|/km2=12,345.6|pop=123,456|km2= }}</nowiki></code>
|style="padding: 20px"|{{Infobox settlement/checkauto|auto| |15}}
+
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2=12,345.6|pop=123,456|km2= }}
 
|-
 
|-
|style="padding: 20px"|<code><nowiki>{{Infobox settlement/checkauto|auto|30| }}</nowiki></code>
+
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/checkauto|/km2=12,345.6|pop= |km2= }}</nowiki></code>
|style="padding: 20px"|{{Infobox settlement/checkauto|auto|30| }}
+
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2=12,345.6|pop= |km2= }}
|-
 
|style="padding: 20px"|<code><nowiki>{{Infobox settlement/checkauto|auto| | }}</nowiki></code>
 
|style="padding: 20px"|{{Infobox settlement/checkauto|auto| | }}
 
 
|}
 
|}
  
Line 43: Line 69:
 
*{{TL|Infobox settlement/link}}
 
*{{TL|Infobox settlement/link}}
 
*{{TL|Infobox settlement cleaner}}
 
*{{TL|Infobox settlement cleaner}}
 
  
 
<includeonly>
 
<includeonly>

Revision as of 12:45, 30 January 2013

This subtemplate of {{Infobox settlement}} checks the inputs that will be passed to {{Infobox settlement/densdisp}} if there is a density to be displayed. This template outputs the density either as provided or as calculated (if set to auto). The automatic calculation requires both the population and area; if either is not provided then this template generates no output.

Usage

{{Infobox settlement/checkauto
| /km2  = auto or population density per km2 (via population_density_km2 and others)
| /sqmi = auto or population density per sqmi (via population_density_sq_mi and others)
| pop   = population (via population_total and others)
| km2   = area in square kilometres (via area_total_km2 and others)
| sqmi  = area in square miles (via area_total_sq_mi and others)
| ha    = area in hectares (via area_total_ha and others)
| acre  = area in acres (via area_total_acre and others)
| dunam = area in dunams (via area_total_dunam and others)
}}

Examples with density auto

As shown in the following examples, this template calculates the density if all three of the following conditions are met: /km2 (or /sqmi) is set to auto, a number if given for population, and a number is given for area. It also strips any formatting from the numbers, such as population with commas in the examples, which would otherwise cause an error in the calculation (see mw:Help:Magic words#Formatting).

Code Result
{{Infobox settlement/checkauto|/km2=auto|pop=123,456|km2=10}} 12345.6
{{Infobox settlement/checkauto|/km2=auto|pop= |km2=10}}
{{Infobox settlement/checkauto|/km2=auto|pop=123,456|km2= }}
{{Infobox settlement/checkauto|/km2=auto|pop= |km2= }}
{{Infobox settlement/checkauto|/km2= |pop= |km2= }}

Examples with density number

As shown in the following examples, this template always displays the density if given as a number, regardless of whether the population and area are defined. It also strips any formatting in the number, such as the commas in the examples.

Code Result
{{Infobox settlement/checkauto|/km2=12,345.6|pop=123,456|km2=10}} 12345.6
{{Infobox settlement/checkauto|/km2=12,345.6|pop= |km2=10}} 12345.6
{{Infobox settlement/checkauto|/km2=12,345.6|pop=123,456|km2= }} 12345.6
{{Infobox settlement/checkauto|/km2=12,345.6|pop= |km2= }} 12345.6

See also