Difference between revisions of "Template:Coord/dec2dms"

From blackwiki
Jump to navigation Jump to search
imported>Quarl
(prec => 3)
imported>Quarl
(prec=>4)
Line 1: Line 1:
 
<includeonly>{{#ifexpr:{{{1}}} >= 0
 
<includeonly>{{#ifexpr:{{{1}}} >= 0
   |{{#switch:{{{3}}}
+
   |{{#switch:{{{4}}}
 
     |d={{#expr:{{{1}}} round 1}}°
 
     |d={{#expr:{{{1}}} round 1}}°
 
     |dm={{#expr:{{{1}}} mod 360}}°{{#expr:({{{1}}} * 600 round 0) mod 600 / 10}}′
 
     |dm={{#expr:{{{1}}} mod 360}}°{{#expr:({{{1}}} * 600 round 0) mod 600 / 10}}′
 
     |dms={{#expr:{{{1}}} mod 360}}°{{#expr:{{{1}}} * 60 mod 60}}′{{#expr:({{{1}}} * 36000 round 0) mod 600 / 10}}″
 
     |dms={{#expr:{{{1}}} mod 360}}°{{#expr:{{{1}}} * 60 mod 60}}′{{#expr:({{{1}}} * 36000 round 0) mod 600 / 10}}″
 
     |#default=ERROR, missing precision}} {{{2}}}
 
     |#default=ERROR, missing precision}} {{{2}}}
   |{{#switch:{{{3}}}
+
   |{{#switch:{{{4}}}
 
     |d={{#expr:-{{{1}}} round 1}}°
 
     |d={{#expr:-{{{1}}} round 1}}°
 
     |dm={{#expr:-{{{1}}} mod 360}}°{{#expr:(-{{{1}}} * 600 round 0) mod 600 / 10}}′
 
     |dm={{#expr:-{{{1}}} mod 360}}°{{#expr:(-{{{1}}} * 600 round 0) mod 600 / 10}}′

Revision as of 06:06, 18 March 2007

Template documentation[view] [edit] [history] [purge]

Given a decimal coordinate, two cardinal directions, and precision, render a coordinate in degrees/minutes/seconds.

Usage

{{coord/dec2dms|coord|N|S|precision}}
{{coord/dec2dms|coord|E|W|precision}}

Precision codes:

dDegrees (rounded to integer)
d1Degrees (rounded to 0.1 degrees)
dmDegrees, minutes (rounded to integer)
dm1Degrees, minutes (rounded to 0.1 minutes)
dmsDegrees, minutes, seconds (rounded to integer)
dms1Degrees, minutes, seconds (rounded to 0.1 seconds)

Examples

{{Coord/dec2dms|10.391944|N|S|d}} 10.4° N
{{Coord/dec2dms|10.391944|N|S|d1}} ERROR, missing precision N
{{Coord/dec2dms|10.390000|N|S|d}} 10.4° N
{{Coord/dec2dms|10.390000|N|S|d1}} ERROR, missing precision N
{{Coord/dec2dms|10.39|N|S|d}} 10.4° N
{{Coord/dec2dms|10.39|N|S|d1}} ERROR, missing precision N
{{Coord/dec2dms|-10.391944|N|S|dm}} 10°23.5′ S
{{Coord/dec2dms|-10.391944|N|S|dm1}} ERROR, missing precision S
{{Coord/dec2dms|10.391944|E|W|dms}} 10°23′31″ E
{{Coord/dec2dms|10.391944|E|W|dms1}} ERROR, missing precision E
{{Coord/dec2dms|10|N|S|d}} 10° N
{{Coord/dec2dms|10|E|W|dm}} 10°0′ E
{{Coord/dec2dms|-10|E|W|dms}} 10°0′0″ W
{{Coord/dec2dms|-10|E|W|dms1}} ERROR, missing precision W

Subroutines

Subroutines of Template:Coord/dec2dms (edit | talk | history | links | watch | logs):