在 WM 平台上开发 GPS 导航系统
2010-02-21 22:52:00 来源:WEB开发网32 End Function
33 ' Interprets a $GPRMC message
34 Public Function ParseGPRMC(ByVal sentence As String) As Boolean
35 ' Divide the sentence into words
36 Dim Words() As String = GetWords(sentence)
37 ' Do we have enough values to describe our location?
38 If Words(3) <> "" And Words(4) <> "" And Words(5) <> "" And _
39 Words(6) <> "" Then
40 ' Yes. Extract latitude and longitude
41 Dim Latitude As String = Words(3).Substring(0, 2) & "°" ' Append hours
42 Latitude = Latitude & Words(3).Substring(2) & """" ' Append minutes
43 Latitude = Latitude & Words(4) ' Append the hemisphere
44 Dim Longitude As String = Words(5).Substring(0, 3) & "°" ' Append hours
45 Longitude = Longitude & Words(5).Substring(3) & """" ' Append minutes
46 Longitude = Longitude & Words(6) ' Append the hemisphere
47 ' Notify the calling application of the change
48 RaiseEvent PositionReceived(Latitude, Longitude)
49 End If
50 ' Do we have enough values to parse satellite-derived time?
51 If Words(1) <> "" Then
52 ' Yes. Extract hours, minutes, seconds and milliseconds
53 Dim UtcHours As Integer = CType(Words(1).Substring(0, 2), Integer)
54 Dim UtcMinutes As Integer = CType(Words(1).Substring(2, 2), Integer)
55 Dim UtcSeconds As Integer = CType(Words(1).Substring(4, 2), Integer)
56 Dim UtcMilliseconds As Integer
57 ' Extract milliseconds if it is available
58 If Words(1).Length > 7 Then UtcMilliseconds = _
59 CType(Single.Parse(Words(1).Substring(6), _
60 CultureInfo.InvariantCulture) * 1000, Integer)
61 ' Now build a DateTime object with all values
62 Dim Today As DateTime = System.DateTime.Now.ToUniversalTime
更多精彩
赞助商链接