Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   calculate x & y from lat & long (http://www.go4expert.com/forums/calculate-x-y-lat-long-t21941/)

calculate x & y from lat & long

I am getting GPS data on my window
Actual GPS DATA is stored in these 2 variables
Code:

```float landlong= 77.384547E //Realtime Longtitude float landlat = 12.583857N  //RealTime Latitude```
But it seems the lat & long which iam getting from GPS is not coming inside window, its out of window .I checked x & y cordinates it is
Code:

```xPos = 1415.7537                yPos = -167.81079```
the width & height of my window is
Code:

```m_WndWidth=1099 m_WndHeight=673```
The formula which iam using to calclulate x & y cordinates is

Code:

```xPos = (landlong - m_fMinLon) * (m_WndWidth / (m_fMaxLon - m_fMinLon)) ; yPos = (landlat - m_fMinLat)  * (m_WndHeight / (m_fMaxLat - m_fMinLat)) ;```
Code:

```BOTTOM RIGHT CORDINATES m_fMaxLat = 12.581369; //MAX lat value        m_fMaxLon = 77.383798;// Max long value TOP LEFT CORDINATES m_fMinLat = 12.583361;//Min lat value        m_fMinLon = 77.381506;//min long value```
Does anyone has the proper formula to calculate X & Y cordinates