DMS display on MouseMove
william paul
williampaul28 at YAHOO.COM
Thu Feb 9 06:48:24 PST 2006
Well, As i sad before:
I am not having problems with theory about projections (I have some
experience in cartography...and I understand what is a projection), I am
having problems with CODING, here I am NEW. I just wanted to see some
examples, but I will find the solution
Thank you for your time
Puneet Kishor <punkish at eidesis.org> wrote:
On Feb 9, 2006, at 7:57 AM, william paul wrote:
> I replay to the email, I didn't thing that the list will not receive
> the email!!!
>
> My problem isn't how you transform from DD to DMS. I already know this.
>
> I want to make the transformation in such manner that the DMS are
> displayed ON MOUSEMOVE over the map, which means that the coordinates
> are changing with position of the cursor on the map
>
> I did that for DD using a script found on the list, but I can't make
> it work for DMS
>
> My code looks like:
>
> var x2 = event.offsetX; // mouse coordinates in pixels
> var y2 = event.offsetY; // mouse coordinates in pixels
> var res_dd = ([maxlon] - [minlon]) / [mapwidth]; // resolution in DD
> var x_dd = [minlon];
> var y_dd = [minlat];
> x1_dd = Math.round(((x2*res_dd) + x_dd)*1000000)/1000000;
> //coordinates in DD to be displayed on mousemove
> y1_dd = Math.round(((([mapheight] - y2)*res_dd) +
> y_dd)*1000000)/1000000; //coordinates in DD to be displayed on
> mousemove
>
> window.status="Latitude DD: " + y1_dd + " " + "Longitude DD: " + y1_dd;
>
> I tried for DMS:
>
> //for longitude in DMS
>
> var dd = Math.floor(x1_dd);
> var m = Math.floor((x1_dd - dd) * 60);
> var s = Math.ceil((((x1_dd - dd) * 60) - m) *60);
>
> I also have tried to break the resolution in DMS, but I don't know how
> to multiply the resolution with the coordinates in pixel and then add
> to minlon
I am not sure what the problem is. Do for DMS exactly the way you are
doing for DD. There is nothing conceptually different between DD and
DMS. They express the same thing in different ways -- it is like saying
1 lb of tomatoes versus 454 gms of tomatoes. Figure out your min, max
in DMS, and add them to your current mouse coordinates.
That said, look at Clint Johnson's email from yesterday. He recommends
reading about projections at
http://fisher.lib.virginia.edu/reference/help/esri/esri_pdfs_9.html,
and that should be the first thing that all MapServer users should read
before setting out making mapping websites. Ed McNierny also has
elaborated on this several times (in fact, I have been thinking of
taking all of Ed's emails and compiling them into a "must read"... note
to Ed -- if you save your MapServer-list emails, forward them to me and
I will do the rest).
Remember, that the pixel space is a rectangle, in that, opposite sides
are equal, while Lat/Long space is more like a trapezoid, in that, the
horizontal opposite sides are not equal, and in fact, at the poles, it
becomes a triangle. If you really want to be exact with your coordinate
display, project your map into a rectangular coordinate system and then
you will get what you want.
>
> 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
/* 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
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
--
Puneet Kishor
---------------------------------
Yahoo! Mail - Helps protect you from nasty viruses.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060209/984d46dc/attachment.htm>
More information about the MapServer-users
mailing list