Difference between revisions of "Template:Coord/dec2dms"
Jump to navigation
Jump to search
imported>Quarl (f) |
imported>Quarl (prec => 3) |
||
| Line 1: | Line 1: | ||
<includeonly>{{#ifexpr:{{{1}}} >= 0 | <includeonly>{{#ifexpr:{{{1}}} >= 0 | ||
| − | |{{#switch:{{{ | + | |{{#switch:{{{3}}} |
|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}}″}} {{{2}}} | + | |dms={{#expr:{{{1}}} mod 360}}°{{#expr:{{{1}}} * 60 mod 60}}′{{#expr:({{{1}}} * 36000 round 0) mod 600 / 10}}″ |
| − | |{{#switch:{{{ | + | |#default=ERROR, missing precision}} {{{2}}} |
| + | |{{#switch:{{{3}}} | ||
|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}}″}} {{{3}}}}}</includeonly><noinclude><!-- | + | |dms={{#expr:-{{{1}}} mod 360}}°{{#expr:-{{{1}}} * 60 mod 60}}′{{#expr:(-{{{1}}} * 36000 round 0) mod 600 / 10}}″ |
| + | |#default=ERROR, missing precision}} {{{3}}}}}</includeonly><noinclude><!-- | ||
The "mod 360" is necessary to truncate degrees. "round 0" is different because it rounds rather than truncates. | The "mod 360" is necessary to truncate degrees. "round 0" is different because it rounds rather than truncates. | ||
-->{{template doc}}</noinclude> | -->{{template doc}}</noinclude> | ||
Revision as of 06:04, 18 March 2007
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:
| d | Degrees (rounded to integer) |
| d1 | Degrees (rounded to 0.1 degrees) |
| dm | Degrees, minutes (rounded to integer) |
| dm1 | Degrees, minutes (rounded to 0.1 minutes) |
| dms | Degrees, minutes, seconds (rounded to integer) |
| dms1 | Degrees, minutes, seconds (rounded to 0.1 seconds) |
Examples
{{Coord/dec2dms|10.391944|N|S|d}} |
ERROR, missing precision N |
{{Coord/dec2dms|10.391944|N|S|d1}} |
ERROR, missing precision N |
{{Coord/dec2dms|10.390000|N|S|d}} |
ERROR, missing precision N |
{{Coord/dec2dms|10.390000|N|S|d1}} |
ERROR, missing precision N |
{{Coord/dec2dms|10.39|N|S|d}} |
ERROR, missing precision N |
{{Coord/dec2dms|10.39|N|S|d1}} |
ERROR, missing precision N |
{{Coord/dec2dms|-10.391944|N|S|dm}} |
ERROR, missing precision S |
{{Coord/dec2dms|-10.391944|N|S|dm1}} |
ERROR, missing precision S |
{{Coord/dec2dms|10.391944|E|W|dms}} |
ERROR, missing precision E |
{{Coord/dec2dms|10.391944|E|W|dms1}} |
ERROR, missing precision E |
{{Coord/dec2dms|10|N|S|d}} |
ERROR, missing precision N |
{{Coord/dec2dms|10|E|W|dm}} |
ERROR, missing precision E |
{{Coord/dec2dms|-10|E|W|dms}} |
ERROR, missing precision W |
{{Coord/dec2dms|-10|E|W|dms1}} |
ERROR, missing precision W |
Subroutines
Subroutines of Template:Coord/dec2dms (edit | talk | history | links | watch | logs):
- Template:Coord/dec2dms/d (edit | talk | history | links | watch | logs)
- Template:Coord/dec2dms/d1 (edit | talk | history | links | watch | logs)
- Template:Coord/dec2dms/dm (edit | talk | history | links | watch | logs)
- Template:Coord/dec2dms/dm1 (edit | talk | history | links | watch | logs)
- Template:Coord/dec2dms/dms (edit | talk | history | links | watch | logs)
- Template:Coord/dec2dms/dms1 (edit | talk | history | links | watch | logs)
| The above documentation is transcluded from Template:Coord/dec2dms/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (edit) pages. Please add categories to the /doc subpage. Subpages of this template. |