Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 2 of 2

Converting XY to Lat Long

This is a discussion on Converting XY to Lat Long within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi All Can any body tell me that how can I convert XY in to Lat Long. I m using ...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    Converting XY to Lat Long

    Hi All

    Can any body tell me that how can I convert XY in to Lat Long.
    I m using the fallowing code butit gave me correct Lattitude and wrong Longitude.Please help me.

    private void CalculateLatLong(MapPoint.Map objMap,MapPoint.Location objLoc)
    {
    MapPoint.Location locNorthPole=null,locSantaCruz=null ;
    double dblHalfEarth=0,dblQuarterEarth=0,dblLat,dblLong,db lI,dblD;
    if (locNorthPole == null)
    {
    locNorthPole = objMap.GetLocation(90,0,0d);
    locSantaCruz = objMap.GetLocation(0,-90,0d);
    dblHalfEarth = objMap.Distance(locNorthPole, objMap.GetLocation(-90, 0,0d));
    dblQuarterEarth = dblHalfEarth / 2;
    }
    dblLat = 90 - 180 * objMap.Distance(locNorthPole, objLoc) / dblHalfEarth;
    dblI = objMap.Distance(objMap.GetLocation(dblLat, 0,0d), objLoc);
    dblD = (dblLat / 180) * Math.PI;
    dblLong = 180 * Math.Acos((Math.Cos((dblD * 2 * Math.PI) / (2 * dblHalfEarth)) - Math.Sin(dblI) * Math.Sin(dblI)) / (Math.Cos(dblI) * Math.Cos(dblI))) / Math.PI;
    if(objMap.Distance(locSantaCruz, objLoc) < dblQuarterEarth )
    dblLong = -dblLong ;
    lblLat.Text = dblLat.ToString()+ "LAT";
    lblLong.Text = dblLong.ToString()+ "LONG";



    }

  2. #2
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Hi,

    > dblI = objMap.Distance(objMap.GetLocation(dblLat, 0,0d), objLoc);
    > dblD = (dblLat / 180) * Math.PI;

    I _think_ this has to be:

    Code:
    dblD = objMap.Distance&#40;objMap.GetLocation&#40;dblLat, 0,0d&#41;, objLoc&#41;; 
    dblI = &#40;dblLat / 180&#41; * Math.PI;
    rgds, Wilfried
    http://www.mestdagh.biz

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Converting to PDF for large printing
    By jhnywall in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 09-14-2010, 09:44 AM
  2. converting lat lon to x y
    By Dazzer in forum MapPoint Desktop Discussion
    Replies: 7
    Last Post: 02-10-2009, 11:12 PM
  3. Converting my Windows app. to ASP
    By BobFromBoston in forum MapPoint Desktop Discussion
    Replies: 7
    Last Post: 10-17-2005, 01:43 PM
  4. Converting Lat/Long to x,y Pixels
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 09-08-2004, 05:24 PM
  5. Converting Zip Codes to Lat/Long
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 06-01-2003, 01:27 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96