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

## 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. 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. 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

##### Users Browsing this Thread

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

#### Posting Permissions

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