现在的位置: 首页 > 综合 > 正文

GPRMC

2013年10月09日 ⁄ 综合 ⁄ 共 3580字 ⁄ 字号 评论关闭

由于$GPRMC比较重要,所以重点讲解:

$GPRMC(Recommended Minimum Specific GPS/TRANSIT Data)

 

帧头

UTC时间

状态

纬度

北纬/南纬

经度

东经/西经

速度

$GPRMC

hhmmss.sss

A/V

ddmm.mmmm

N/S

dddmm.mmmm

E/W

 

方位角

UTC日期

磁偏角

磁偏角方向

模式

校验

回车换行

ddmmyy

000 - 180

E/W

A/D/E/N

*hh

CR+LF

 

格 式: $GPRMC,<1>,<2>,<3>,<4>,<5>,<6>,<7>,<8>,<9>,<10>,<11>,<12>*hh<CR><LF>

$GPRMC,024813.640,A,3158.4608,N,11848.3737,E,10.05,324.27,150706,,,A*50

说 明:

字段 0:$GPRMC,语句ID,表明该语句为Recommended Minimum Specific GPS/TRANSIT Data(RMC)推荐最小定位信息

          字段 1:UTC时间,hhmmss.sss格式

          字段 2:状态,A=定位,V=未定位

          字段 3:纬度ddmm.mmmm,度分格式(前导位数不足则补0)

          字段 4:纬度N(北纬)或S(南纬)

          字段 5:经度dddmm.mmmm,度分格式(前导位数不足则补0)

          字段 6:经度E(东经)或W(西经)

          字段 7:速度,节,Knots(一节也是1.852千米/小时)

          字段 8:方位角,度(二维方向指向,相当于二维罗盘)

          字段 9:UTC日期,DDMMYY格式

          字段10:磁偏角,(000 - 180)度(前导位数不足则补0)

          字段11:磁偏角方向,E=东,W=西

          字段12:模式,A=自动,D=差分,E=估测,N=数据无效(3.0协议内容)

          字段13:校验值

对应的程序代码如下:

 

  1. //运输定位数据  
  2.        private bool GPRMC_Parse(string data)  
  3.        {  
  4.            string[] source = Split(data, "$GPRMC");  
  5.            if (source != null && source.Length >= 12)  
  6.            {  
  7.                //状态  
  8.                this.AnchorState = source[2];  
  9.                //纬度  
  10.                if (source[4].Length > 0 && source[3].Length > 2)  
  11.                {  
  12.                    this.Latitude = string.Format("{0}{1},{2}", source[4], source[3].Substring(0, 2), source[3].Substring(2));  
  13.                }  
  14.                else  
  15.                {  
  16.                    this.Latitude = "";  
  17.                }  
  18.                //经度  
  19.                if (source[6].Length > 0 && source[5].Length > 3)  
  20.                {  
  21.                    this.Longitude = string.Format("{0}{1},{2}", source[6], source[5].Substring(0, 3), source[5].Substring(3));  
  22.                }  
  23.                else  
  24.                {  
  25.                    this.Longitude = "";  
  26.                }  
  27.                //速度  
  28.                if (source[7].Length > 0)  
  29.                {  
  30.                    this.NSpeed = double.Parse(source[7]);  
  31.                }  
  32.               else  
  33.                {  
  34.                    this.NSpeed = 0;  
  35.                }  
  36.                //方位  
  37.                if (source[8].Length > 0)  
  38.                {  
  39.                    this.Track = double.Parse(source[8]);  
  40.                }  
  41.                else  
  42.                {  
  43.   
  44.                   this.Track = 0;  
  45.                }  
  46.                //磁偏角和方位  
  47.                if (source[10].Length > 0 && source[11].Length > 0)  
  48.                {  
  49.                    this.Magnetic = string.Format("{0} {1}", source[11], source[10]);  
  50.                }  
  51.                else  
  52.                {  
  53.                    this.Magnetic = "";  
  54.                }  
  55.                //模式  
  56.                if (source.Length >= 13)  
  57.                {  
  58.                    this.WorkMode = source[12];  
  59.                }  
  60.                //时间  
  61.                try  
  62.                {  
  63.                    if (source[9].Length == 6 && source[1].Length >= 6)  
  64.                    {  
  65.                        string dtString = string.Format("{0}-{1}-{2} {3}:{4}:{5}",  
  66.                            source[9].Substring(4),  
  67.                            source[9].Substring(2, 2),  
  68.                            source[9].Substring(0, 2),  
  69.                            source[1].Substring(0, 2),  
  70.                            source[1].Substring(2, 2),  
  71.                            source[1].Substring(4));  
  72.                        this.UTCDateTime = DateTime.Parse(dtString);  
  73.                    }  
  74.                }  
  75.                catch { return false; }  
  76.                return true;  
  77.            }  
  78.            return false;  
  79.        }  

抱歉!评论已关闭.