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