1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

calculate x & y from lat & long

Discussion in 'MFC' started by answerme, Apr 29, 2010.

  1. answerme

    answerme New Member

    I am getting GPS data on my window
    Actual GPS DATA is stored in these 2 variables
    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
    xPos = 1415.7537		
    yPos = -167.81079
    the width & height of my window is
    The formula which iam using to calclulate x & y cordinates is

    xPos = (landlong - m_fMinLon) * (m_WndWidth / (m_fMaxLon - m_fMinLon)) ;
    yPos = (landlat - m_fMinLat)  * (m_WndHeight / (m_fMaxLat - m_fMinLat)) ;
    m_fMaxLat = 12.581369; //MAX lat value	
    m_fMaxLon = 77.383798;// Max long value
    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
  2. chandu004

    chandu004 New Member

    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.

Share This Page