$GNGGA,074011.000,3412.691484,N,10856.562217,E,1,05,2.674,500.159,M,0,M,,*68
$--GGA,time,Lat,N,Lon,E,FS,NoSV,HDOP,msl,M,Altref,M,DiffAge,DiffStation*cs
$GNRMC,074011.000,A,3412.691484,N,10856.562217,E,0.215,225.504,080413,,E,A*37
$--RMC,time,status,Lat,N,Lon,E,spd,cog,date,mv,mvE,mode*cs
纬度和经度都是度分格式,需要转换为度分秒格式,一般秒后保留几位小数。
度分转换为度分秒程序:
for(i = 0;i < 3;i++)
{
n++;
sum_E_dd = sum_E_dd*10 + (UART3Buffer[n] - '0');//度
}
for(i = 0;i < 2;i++)
{
n++;
sum_E_mm = sum_E_mm*10 + (UART3Buffer[n] - '0');//分
}
n++;
for(i = 0;i < 6;i++)
{
n++;
sum_E = sum_E*10 + (UART3Buffer[n] - '0');
}
sum_E = (BOOL)sum_E*60;
sum_E_ss = sum_E/1000000; //秒的整数
sum_E = (sum_E%1000000)/1000;
sum_E_sss = (sum_E+5)/10; //秒后保留2位小数,四舍五入
主要涉及到字符转整数,以及四舍五入的算法。