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

From blackwiki
Jump to navigation Jump to search
imported>Yahia.barie
(bn:টেমপ্লেট:Infobox Settlement/densdisp)
imported>Zyxw
(update documentation and provide examples)
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 -->
 
This '''subtemplate of {{Tl|Infobox settlement}}''' displays a metric/imperial pair of population density values for a line in the main infobox.
 
This '''subtemplate of {{Tl|Infobox settlement}}''' displays a metric/imperial pair of population density values for a line in the main infobox.
 +
 +
=== Usage ===
 +
<nowiki>{{</nowiki>Infobox settlement/densdisp
 +
| /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 [[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)
 +
| pref  = preference to display /km2 or /sqmi (via ''unit_pref'')
 +
| name  = name of country (via ''subdivision_name'')
 +
}}
 +
 +
=== Examples of density as 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
 +
!Number<br/>(not rounded)
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=0.00023456}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=0.00023456}}
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2=auto|pop=10|km2=0.00023456}}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=0.0023456}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=0.0023456}}
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2=auto|pop=10|km2=0.0023456}}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=0.023456}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=0.023456}}
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2=auto|pop=10|km2=0.023456}}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=0.23456}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=0.23456}}
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2=auto|pop=10|km2=0.23456}}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=2.3456}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=2.3456}}
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2=auto|pop=10|km2=2.3456}}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=23.456}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=23.456}}
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2=auto|pop=10|km2=23.456}}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=234.56}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=234.56}}
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2=auto|pop=10|km2=234.56}}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=2345.6}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=2345.6}}
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2=auto|pop=10|km2=2345.6}}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=23456}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=23456}}
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/km2=auto|pop=10|km2=23456}}
 +
|}
 +
 +
{| class="wikitable"
 +
!Code
 +
!Result
 +
!Number<br/>(not rounded)
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|pref=Imperial|/sqmi=auto|pop=123,456|sqmi=10}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|pref=Imperial|/sqmi=auto|pop=123,456|sqmi=10}}
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/sqmi=auto|pop=123,456|sqmi=10}}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|pref=Imperial|/sqmi=auto|pop=12345|sqmi=10}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|pref=Imperial|/sqmi=auto|pop=12345|sqmi=10}}
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/sqmi=auto|pop=12345|sqmi=10}}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|pref=Imperial|/sqmi=auto|pop=1234|sqmi=10}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|pref=Imperial|/sqmi=auto|pop=1234|sqmi=10}}
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/sqmi=auto|pop=1234|sqmi=10}}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|pref=Imperial|/sqmi=auto|pop=123|sqmi=10}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|pref=Imperial|/sqmi=auto|pop=123|sqmi=10}}
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/sqmi=auto|pop=123|sqmi=10}}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|pref=Imperial|/sqmi=auto|pop=12|sqmi=10}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|pref=Imperial|/sqmi=auto|pop=12|sqmi=10}}
 +
|style="padding: 10px"|{{Infobox settlement/checkauto|/sqmi=auto|pop=12|sqmi=10}}
 +
|}
 +
 +
=== Examples of missing population or area ===
 +
As shown in the following examples, this template outputs nothing if density = auto, but either population or area is missing.
 +
 +
{| class="wikitable"
 +
!Code
 +
!Result
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|/km2=auto|pop=123,456|km2= }}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|/km2=auto|pop=123,456|km2= }}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|/km2=auto|pop= |km2=10}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|/km2=auto|pop= |km2=10}}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|/km2=auto|pop= |km2= }}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|/km2=auto|pop= |km2= }}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|/km2= |pop= |km2= }}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|/km2= |pop= |km2= }}
 +
|}
 +
 +
=== Examples of density as 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
 +
!Result
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|/km2=12,345.67}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|/km2=12,345.67}}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|/sqmi=12,345.67}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|/sqmi=12,345.67}}
 +
|-
 +
|style="padding: 10px"|<code><nowiki>{{Infobox settlement/densdisp|pref=Imperial|/sqmi=12,345.67}}</nowiki></code>
 +
|style="padding: 10px"|{{Infobox settlement/densdisp|pref=Imperial|/sqmi=12,345.67}}
 +
|}
  
 
=== See also ===
 
=== See also ===

Revision as of 14:03, 30 January 2013

This subtemplate of {{Infobox settlement}} displays a metric/imperial pair of population density values for a line in the main infobox.

Usage

{{Infobox settlement/densdisp
| /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)
| pref  = preference to display /km2 or /sqmi (via unit_pref)
| name  = name of country (via subdivision_name)
}}

Examples of density as 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 Number
(not rounded)
{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=0.00023456}} Template:Round/km2 (Template:Round/sq mi) 42633.015006821
{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=0.0023456}} Template:Round/km2 (Template:Round/sq mi) 4263.3015006821
{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=0.023456}} Template:Round/km2 (Template:Round/sq mi) 426.33015006821
{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=0.23456}} Template:Round/km2 (Template:Round/sq mi) 42.633015006821
{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=2.3456}} Template:Round/km2 (Template:Round/sq mi) 4.2633015006821
{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=23.456}} Template:Round/km2 (Template:Round/sq mi) 0.42633015006821
{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=234.56}} Template:Round/km2 (Template:Round/sq mi) 0.042633015006821
{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=2345.6}} Template:Round/km2 (Template:Round/sq mi) 0.0042633015006821
{{Infobox settlement/densdisp|/km2=auto|pop=10|km2=23456}} Template:Round/km2 (Template:Round/sq mi) 0.00042633015006821
Code Result Number
(not rounded)
{{Infobox settlement/densdisp|pref=Imperial|/sqmi=auto|pop=123,456|sqmi=10}} Template:Round/sq mi (Template:Round/km2) 12345.6
{{Infobox settlement/densdisp|pref=Imperial|/sqmi=auto|pop=12345|sqmi=10}} Template:Round/sq mi (Template:Round/km2) 1234.5
{{Infobox settlement/densdisp|pref=Imperial|/sqmi=auto|pop=1234|sqmi=10}} Template:Round/sq mi (Template:Round/km2) 123.4
{{Infobox settlement/densdisp|pref=Imperial|/sqmi=auto|pop=123|sqmi=10}} Template:Round/sq mi (Template:Round/km2) 12.3
{{Infobox settlement/densdisp|pref=Imperial|/sqmi=auto|pop=12|sqmi=10}} Template:Round/sq mi (Template:Round/km2) 1.2

Examples of missing population or area

As shown in the following examples, this template outputs nothing if density = auto, but either population or area is missing.

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

Examples of density as 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/densdisp|/km2=12,345.67}} 12,345.67/km2 (Template:Round/sq mi)
{{Infobox settlement/densdisp|/sqmi=12,345.67}} Template:Round/km2 (12,345.67/sq mi)
{{Infobox settlement/densdisp|pref=Imperial|/sqmi=12,345.67}} 12,345.67/sq mi (Template:Round/km2)

See also