$GPRMC解析

由于$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 DataRMC)推荐最小定位信息

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

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

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

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

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

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

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

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

          字段 9UTC日期,DDMMYY格式

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

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

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

          字段13:校验值

对应的程序代码如下:

 

     //运输定位数据
            private bool GPRMC_Parse(string data)
            {
                string[] source = Split(data, "$GPRMC");
                if (source != null && source.Length >= 12)
                {
                    //状态
                    this.AnchorState = source[2];
                    //纬度
                    if (source[4].Length > 0 && source[3].Length > 2)
                    {
                        this.Latitude = string.Format("{0}{1},{2}", source[4], source[3].Substring(0, 2), source[3].Substring(2));
                    }
                    else
                    {
                        this.Latitude = "";
                    }
                    //经度
                    if (source[6].Length > 0 && source[5].Length > 3)
                    {
                        this.Longitude = string.Format("{0}{1},{2}", source[6], source[5].Substring(0, 3), source[5].Substring(3));
                    }
                    else
                    {
                        this.Longitude = "";
                    }
                    //速度
                    if (source[7].Length > 0)
                    {
                        this.NSpeed = double.Parse(source[7]);
                    }
                   else
                    {
                        this.NSpeed = 0;
                    }
                    //方位
                    if (source[8].Length > 0)
                    {
                        this.Track = double.Parse(source[8]);
                    }
                    else
                    {

                       this.Track = 0;
                    }
                    //磁偏角和方位
                    if (source[10].Length > 0 && source[11].Length > 0)
                    {
                        this.Magnetic = string.Format("{0} {1}", source[11], source[10]);
                    }
                    else
                    {
                        this.Magnetic = "";
                    }
                    //模式
                    if (source.Length >= 13)
                    {
                        this.WorkMode = source[12];
                    }
                    //时间
                    try
                    {
                        if (source[9].Length == 6 && source[1].Length >= 6)
                        {
                            string dtString = string.Format("{0}-{1}-{2} {3}:{4}:{5}",
                                source[9].Substring(4),
                                source[9].Substring(2, 2),
                                source[9].Substring(0, 2),
                                source[1].Substring(0, 2),
                                source[1].Substring(2, 2),
                                source[1].Substring(4));
                            this.UTCDateTime = DateTime.Parse(dtString);
                        }
                    }
                    catch { return false; }
                    return true;
                }
                return false;
            }

  • 7
    点赞
  • 39
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值