WEB开发网
开发学院手机开发Windows Mobile 开发 在 WM 平台上开发 GPS 导航系统 阅读

在 WM 平台上开发 GPS 导航系统

 2010-02-21 22:52:00 来源:WEB开发网   
核心提示:代码片段:1 ***23 '** Listing 1-3. Detecting and handling NMEA errors45 '***67 Public Class NmeaInterpreter8 ' Raised when the current location has chang

代码片段:

1 *******************************************************

2

3 '** Listing 1-3. Detecting and handling NMEA errors

4

5 '*******************************************************

6

7 Public Class NmeaInterpreter

8 ' Raised when the current location has changed

9 Public Event PositionReceived(ByVal latitude As String, _

10 ByVal longitude As String)

11 ' Processes information from the GPS receiver

12 Public Function Parse(ByVal sentence As String) As Boolean

13 ' Discard the sentence if its checksum does not match our calculated

14 'checksum

15 If Not IsValid(sentence) Then Return False

16 ' Look at the first word to decide where to go next

17 Select Case GetWords(sentence)(0)

18 Case "$GPRMC" ' A "Recommended Minimum" sentence was found!

19 Return ParseGPRMC(sentence)

20 Case Else

21 ' Indicate that the sentence was not recognized

22 Return False

23 End Select

24 End Function

25 ' Divides a sentence into individual words

26 Public Function GetWords(ByVal sentence As String) As String()

27 Return sentence.Split(","c)

28 End Function

29 ' Interprets a $GPRMC message

30 Public Function ParseGPRMC(ByVal sentence As String) As Boolean

31 ' Divide the sentence into words

32 Dim Words() As String = GetWords(sentence)

33 ' Do we have enough values to describe our location?

34 If Words(3) <> "" And Words(4) <> "" And Words(5) <> "" And _

35 Words(6) <> "" Then

36 ' Yes. Extract latitude and longitude

37 Dim Latitude As String = Words(3).Substring(0, 2) & "°" ' Append hours

38 Latitude = Latitude & Words(3).Substring(2) & """" ' Append

上一页  1 2 3 4 5 6 7 8 9  下一页

Tags:WM 平台 开发

编辑录入:coldstar [复制链接] [打 印]
赞助商链接