古詩詞大全網 - 成語解釋 - GPS模塊的數據怎麽轉化為經緯度!

GPS模塊的數據怎麽轉化為經緯度!

if (ch == 'C') /// 如果第五個字符是C,($GPRMC)

{

if (status == 'A') /// 如果數據有效,則分析已經定位

{

GPS -> NS = buf[GetComma(4, buf)]; //判斷為N緯

GPS -> EW = buf[GetComma(6, buf)]; //判斷為E緯

GPS->latitude = Get_Double_Number(&buf[GetComma(3, buf)]);//獲取緯度數

GPS->longitude = Get_Double_Number(&buf[GetComma( 5, buf)]); //獲取經度數

GPS->latitude_Degree = (int)GPS->latitude / 100; /// 分離緯度,緯度數除以100取整,到度

lati_cent_tmp = (GPS->latitude - GPS->latitude_Degree * 100); /// 分離緯度,到分,含有小數

GPS->latitude_Cent = (int)lati_cent_tmp;//取整得到分

lati_second_tmp = (lati_cent_tmp - GPS->latitude_Cent) * 60; //取秒

GPS->latitude_Second = (int)lati_second_tmp; //對小數化成的秒取整