DMS display on MouseMove

P Kishor punkish at EIDESIS.ORG
Wed Feb 8 11:58:03 EST 2006


william paul wrote:
> Hi:
>
> I know this, my problem is other, but...I will solve it

Please send all replies to the list as well. In the meantime, would
the following help --

//(0) Grab the dd value
var dd = obj.value;

// (1) The Degrees are simply the numbers to the left of the decimal
// (using 42.36824 as an example, the degrees would be 42)
var d = Math.floor(dd);

// (2) To determine the Minutes, multiply the number to the right of
// the decimal point by 60 (example: .36824 x 60 = 22.0944)
// (3) The Minutes are the numbers to the left of the decimal point
// (in this example, 22)
var m = Math.floor((dd - d) * 60);

// (4) To determine the Seconds, multiply the number to the right of
// the decimal point by 60 (example: .0944 x 60 = 5.664)
// (5) The Seconds are the numbers to the left of the decimal point,
// rounded up (in this example, 06)
var s = Math.ceil((((dd - d) * 60) - m) * 60);

// display it
var dms = d + ' deg, ' + m + ' min, ' + s + ' sec';

>
> */Puneet Kishor <punkish at EIDESIS.ORG>/* wrote:
>
>     william paul wrote:
>      > Hi:
>      >
>      > I display the coordinates on mousemove over the map. The
>     coordinates are
>      > in DD and UTM, but I would like display them also in DMS.
>      >
>
>      From the very first hit on Google --
>
>     (1) The Degrees are simply the numbers to the left of the decimal
>     (using 42.36824 as an example, the degrees would be 42)
>     (2) To determine the Minutes, multiply the number to the right of
>     the decimal point by 60 (example: .36824 x 60 = 22.0944)
>     (3) The Minutes are the numbers to the left of the decimal point
>     (in this example, 22)
>     (4) To determine the Seconds, multiply the number to the right of
>     the decimal point by 60 (example: .0944 x 60 = 5.664)
>     (5) The Seconds are the numbers to the left of the decimal point,
>     rounded up (in this example, 06)
>
>     Implementing it in Js is left as an exercise for the reader...
>
>


--
Puneet Kishor



More information about the mapserver-users mailing list