Jump to content

Template:Coord/dec2dms: Difference between revisions

From IdeaWazaWiki
wikademia>Quarl
f
wikademia>Quarl
prec => 3
Line 1: Line 1:
<includeonly>{{#ifexpr:{{{1}}} >= 0
<includeonly>{{#ifexpr:{{{1}}} >= 0
   |{{#switch:{{{prec}}}
   |{{#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:{{{prec}}}
    |#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