阅读:3234回复:10
[分享]编写你自己的gps应用程序
<P>从codeguru转过来的,和大家一起学习下</P>
<P>Writing Your Own GPS Applications: Part I </P> <P><b>Environment:</b> C#, VB.NET, Visual Studio 2002/2003/2005, .NET Framework, .NET Compact Framework </P> <P><IMG src="http://www.codeguru.com/dbfiles/get_image.php?id=8079;lbl=GPSPOCKETPC3_JPG;ds=20040901"></P> <P>"I am continually amazed by how little code is required to use atomic clocks in satellites 11,000 miles above my head."</P> <P>What is it that GPS applications need to be good enough to handle in-car navigation? Also, how does the process of interpreting GPS data actually work? In this two-part series, I will cover both topics and give you the skills you need to write a commercial-grade GPS application that works with a majority of GPS devices in the industry today.</P> <H3>One Powerful Sentence</H3> <P>This first part in the series will explore the task of interpreting raw GPS data. Fortunately, the task is simplified thanks to the National Marine Electronics Association (www.nmea.org), which introduced a standard for the industry now in use by a vast majority of GPS devices. To give developers a head start, I chose to use some Visual Studio.NET source code from my "GPS.NET Global Positioning SDK" component. (The code is stripped of features like multithreading and error handling for brevity.)</P> <P>NMEA data is sent as comma-delimited "sentences" that contain information based on the first word of the sentence. There are over fifty kinds of sentences, yet an interpreter really only needs to handle a few to get the job done. The most common NMEA sentence of all is the "Recommended Minimum" sentence, which begins with "$GPRMC." Here is an example:</P><PRE>$GPRMC,040302.663,A,3939.7,N,10506.6,W,0.27,358.86,200804,,*1A</PRE> <P>This one sentence contains nearly everything a GPS application needs: latitude, longitude, speed, bearing, satellite-derived time, fix status, and magnetic variation.</P> <H3>The Core of An Interpreter</H3> <P>The first step in making an NMEA interpreter is writing a method that does two things: separating each sentence into its individual words and then examining the first word to figure out what information is available to extract. Listing 1-1 shows the start of the interpreter class.</P> <P><B>Listing 1-1:</B> The core of an NMEA interpreter is a function which divides NMEA sentences into individual words.</P><PRE>'******************************************************* '** Listing 1-1. The core of an NMEA interpreter '******************************************************* 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 </PRE> <P><B>About the Author</B> Jon Person is the author of the award-winning "<a href="http://www.gpsdotnet.com/" target="_blank" >GPS.NET Global Positioning SDK</A>" component and has consulted for military companies and the Forest Service on GPS solutions. Jon frequently writes about GPS application development and welcomes all questions and comments at <a href="mailtinfo@gpsdotnet.com" target="_blank" >info@gpsdotnet.com</A>. </P> <P>第一部分的代码:</P> <P><B>Downloads</B> <LI><a href="http://www.codeguru.com/dbfiles/get_file/PartOneListings.zip?id=8079;lbl=PARTONELISTINGS_ZIP;ds=20040901" target="_blank" >PartOneListings.zip</A> - Listings for Part One (Visual Basic.NET) </LI> |
|
|
1楼#
发布于:2004-10-16 22:07
<img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em02.gif" />
|
|
2楼#
发布于:2004-10-14 09:39
<img src="images/post/smile/dvbbs/em02.gif" /><img src="images/post/smile/dvbbs/em04.gif" />
|
|
3楼#
发布于:2004-09-23 11:22
<img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em01.gif" />
|
|
|
4楼#
发布于:2004-09-21 15:25
<img src="images/post/smile/dvbbs/em05.gif" />kanbudong!
|
|
5楼#
发布于:2004-09-21 09:27
<img src="images/post/smile/dvbbs/em02.gif" />
|
|
|
6楼#
发布于:2004-09-18 08:40
<img src="images/post/smile/dvbbs/em02.gif" />
|
|
|
7楼#
发布于:2004-09-17 23:37
<P><img src="images/post/smile/dvbbs/em01.gif" /></P><img src="images/post/smile/dvbbs/em07.gif" />
|
|
|
8楼#
发布于:2004-09-17 16:42
顶~
|
|
9楼#
发布于:2004-09-17 15:58
<P>贴在这里不太好看,还是把地址贴出来,大家自己去看吧</P>
<P><a href="http://www.codeguru.com/vb/mobile/pocketpc/article.php/c8079__1/" target="_blank" >http://www.codeguru.com/vb/mobile/pocketpc/article.php/c8079__1/</A></P> [此贴子已经被作者于2004-9-17 16:00:52编辑过]
|
|
|
上一页
下一页