Go4Expert

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/)

answerme 29Apr2010 12:24

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

Thanks in advance

chandu004 22May2010 14:17

Re: calculate x & y from lat & long
 
your formula seems to be alright. but your point is getting displayed beyond the screen display area. to solve this, you need to map (or scale in other words) the start and end co ordinates of your map with your display area, and also you should scale every gps point you are displaying wrt the screen co ordinates.
long back, i also faced the same problem, and i solved it this way.
feel free to mail me, for any further queries.
chandu004@yahoo.com


All times are GMT +5.5. The time now is 00:21.