Difference between revisions of "Template:Decdeg/doc"

From blackwiki
Jump to navigation Jump to search
imported>Droll
(→‎Purpose: tweak)
imported>Droll
(→‎Usage: rewrite)
Line 11: Line 11:
 
{| class="wikitable"
 
{| class="wikitable"
 
|- width="50%" valign="top" style="vertical-align:top;"
 
|- width="50%" valign="top" style="vertical-align:top;"
! Fields !! Description
+
! Parameter !! Description
 
|- width="50%" valign="top" style="vertical-align:top;"
 
|- width="50%" valign="top" style="vertical-align:top;"
| style="vertical-align:top;padding:1ex;" |<pre>
+
| style="vertical-align:top;padding:1ex;" |<pre style="margin:0; border-color:transparent">
 
{{decdeg
 
{{decdeg
 
| deg =  
 
| deg =  
Line 21: Line 21:
 
| rnd =
 
| rnd =
 
}}</pre>
 
}}</pre>
| style="vertical-align:top;padding:1ex;" |<pre>
+
| style="vertical-align:top;padding:1ex;" |<pre style="margin:0; border-color:transparent">
 
&nbsp;
 
&nbsp;
 
Degrees
 
Degrees
Line 31: Line 31:
 
|}
 
|}
  
{| class="wikitable"
+
Input degrees can be signed in which case the hemisphere is not required. A negative value implies a value in the western or southern hemisphere. Minutes and seconds need not be specified. If no degrees are specified then a value of zero is assumed. This template does not attempt to trap invalid values and results in this case might be undefined.
|- width="50%" valign="top" style="vertical-align:top;"
 
| style="vertical-align:top;padding:1ex;" |<pre>
 
{{decdeg|deg|min|sec|hem|rnd}}</pre>
 
|}
 
  
Input degrees can be signed in which case the hemisphere is not required. A negative value implies a value in the western or southern hemisphere. Minutes and seconds need not be specified. If no degrees are specified then a value of zero is assumed. This template does not attempt to trap invalid values and results in this case will be undefined.
+
The decimal precision of the result is determined by the value assigned <tt>rnd</tt>, which defaults to 7.
  
If {{para|rnd}} is not specified then the default value is {{para|rnd|7}}.
+
Currently this template does not attempt to trap invalid values.
  
 
=== Examples ===
 
=== Examples ===

Revision as of 01:36, 26 July 2010

This helper template provides a way to convert geographic coordinates from degree, minute, second format to decimal degrees. It is intended for use in building infobox templates.

Usage

The template can be use with named or unnamed parameters as shown.

Parameter Description
{{decdeg
| deg = 
| min =
| sec = 
| hem = 
| rnd =
}}
 
Degrees
Minutes
Seconds
Hemisphere
Round
 

Input degrees can be signed in which case the hemisphere is not required. A negative value implies a value in the western or southern hemisphere. Minutes and seconds need not be specified. If no degrees are specified then a value of zero is assumed. This template does not attempt to trap invalid values and results in this case might be undefined.

The decimal precision of the result is determined by the value assigned rnd, which defaults to 7.

Currently this template does not attempt to trap invalid values.

Examples

{{decdeg|deg=37|min=51|sec=00|hem=N}} → 37.85
{{decdeg|deg=119|min=34|sec=04|hem=W}} → -119.5677778

When using unnamed parameters, the hemisphere must be the forth parameter:

{{decdeg|37|51||N}} → 37.85
{{decdeg|119|34||W}} → -119.5666667

Input can be signed or unsigned decimal degrees:

{{decdeg|37.85|||N}} → 37.85
{{decdeg|119.5666667|||W}} → -119.5666667
{{decdeg|37.85}} → 37.85
{{decdeg|-119.5666667}} → -119.5666667

When using rounding, the factor must be the fifth parameter:

{{decdeg|37.85||||1}} → 37.9
{{decdeg|-119.5666667||||1}} → -119.6

If a value is undefined then zero is presumed:

{{decdeg||51||N}} → 0.85
{{decdeg||34||W}} → -0.5666667

Negative zero values are accommodated:

{{decdeg|0|51}} → 0.85
{{decdeg|-0|34}} → -0.5666667

See also