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

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

 2010-02-21 22:52:00 来源:WEB开发网   
核心提示:19 Public Function Parse(ByVal sentence As String) As Boolean20 ' Discard the sentence if its checksum does not match our calculated21 ' checksum22 If N

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

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

21 ' checksum

22 If Not IsValid(sentence) Then Return False

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

24 Select Case GetWords(sentence)(0)

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

26 Return ParseGPRMC(sentence)

27 Case Else

28 ' Indicate that the sentence was not recognized

29 Return False

30 End Select

31 End Function

32 ' Divides a sentence into individual words

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

34 Return sentence.Split(","c)

35 End Function

36 ' Interprets a $GPRMC message

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

38 ' Divide the sentence into words

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

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

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

42 Words(6) <> "" Then

43 ' Yes. Extract latitude and longitude

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

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

46 Latitude = Latitude & Words(4) ' Append the hemisphere

47 Dim Longitude As String = Words(5).Substring(0, 3) & "°" ' Append hours

48 Longitude = Longitude & Words(5).Substring(3) & """" ' Append minutes

49 Longitude = Longitude & Words(6) ' Append the hemisphere

50 ' Notify the calling application of the change

51 RaiseEvent PositionReceived(Latitude, Longitude)

52 End If

上一页  8 9 10 11 12 13 14 15 16 17 18  下一页

Tags:WM 平台 开发

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