如何使用.net编写GPS应用程序

来源:互联网 发布:手机照片涂鸦软件 编辑:程序博客网 时间:2024/05/24 07:09

究竟什么是GPS应用程序需要在商业环境中使用,如车载导航?
另外,如何处理GPS数据的实际工作?在这
两部分的系列,我将介绍这两个主题,让你可以写一个商业级的GPS应用,使其可以应用于与大多数的GPS设备.

本系列的第一部分将探讨如何处理原始的GPS数据。幸运的是,由于这个任务是简化
这要感谢美国国家海洋电子协会,它提供了
为由现在绝大多数的GPS设备的使用行业标准。为了
为开发人员提供一个良好的开端,我选择使用一些源代码的Visual Studio.NET
从我GPS.NET全球定位SDK组件http://www.runmei.net(为了简洁这个代码剥离了如多线程功能和错误处理等功能。)NMEA数据被逗号分隔
其中载有关于第一个字为基础的信息
句子。有超过五十种句子,尚未翻译
然而只需要处理一些就可以完成这项工作。最常见的
NMEA语句使用$ GPRMC作为前缀
$GPRMC,040302.663,A,3939.7,N,10506.6,W,0.27,358.86,200804,,*1A

这条语言包含几乎GPS应用程序需要的所有的东西:经度,纬度,速度,方向,卫星获取的
时间,固定的状态和磁性的变化。

解释器的核心 ,要生成一个NMEA解释器第一步是写一个方法,该方法是做两件事情:分离每条句子成为单词,并检查第一个单词,找出哪些信息是可用来提取。

Public Class NmeaInterpreter
 ' Processes information from the GPS receiver
 Public Function Parse(ByVal sentence As String) As Boolean
 ' Divide the sentence into words
 Dim Words() As String = GetWords(sentence)
 ' Look at the first word to decide where to go next
 Select Case Words(0)
Case "$GPRMC"' A "Recommended Minimum" sentence was found!
' Indicate that the sentence was recognized
Return True
Case Else
' Indicate that the sentence was not recognized
Return False
 End Select
 End Function
 ' Divides a sentence into individual words
 Public Function GetWords(ByVal sentence As String) As String()
 Return sentence.Split(","c)
 End Function
End Class

原创粉丝点击