void parse_GPS_msg() { string temp = currentMsg.ToString(); string[] tempArray = new string[100]; tempArray = temp.Split(delims); switch (tempArray[0]) { case "$GPGGA": try { if (tempArray[9] == "") tempArray[9] = "0"; if (tempArray[7] == "") tempArray[7] = "0"; time = new GPSTime(tempArray[1]); lastFix = fix; fix = (tempArray[6] != "0"); altitude = Convert.ToDouble(tempArray[9]); lastLatitude = latitude; lastLongitude = longitude; latitude = Math.Round(((Convert.ToDouble(tempArray[2].Remove(0, 2)) / 60) + (Convert.ToDouble(tempArray[2].Remove(2)))), 6); longitude = Math.Round(((Convert.ToDouble(tempArray[4].Remove(0, 3)) / 60) + (Convert.ToDouble(tempArray[4].Remove(3)))), 6); if (tempArray[3] == "S") latitude = -latitude; if (tempArray[5] == "W") longitude = -longitude; } catch { } if(lastLongitude != longitude) OnPositionChange(new PositionChangeEventArgs(latitude, longitude)); else if(lastLatitude != latitude) OnPositionChange(new PositionChangeEventArgs(latitude, longitude)); if(lastFix != fix) OnPositionFixChange(new PositionFixChangeEventArgs(fix)); break; case "$GPGSA": break; case "$GPGSV": break; case "$GPRMC": try { if (tempArray[7] == "") tempArray[7] = "0"; if (tempArray[8] == "") tempArray[8] = "0"; if (tempArray[9] == "") tempArray[9] = "0"; date = new GPSDate(tempArray[9]); velocity = (Convert.ToDouble(tempArray[7]))/0.5399568; heading = Convert.ToDouble(tempArray[8]); } catch { } break; case "$GPVTG": break; case "$GPGLL": break; default: break; } }
void parse_GPS_msg() { string temp = currentMsg.ToString(); string[] tempArray = new string[100]; tempArray = temp.Split(delims); switch (tempArray[0]) { case "$GPGGA": try { if (tempArray[9] == "") { tempArray[9] = "0"; } if (tempArray[7] == "") { tempArray[7] = "0"; } time = new GPSTime(tempArray[1]); lastFix = fix; fix = (tempArray[6] != "0"); altitude = Convert.ToDouble(tempArray[9]); lastLatitude = latitude; lastLongitude = longitude; latitude = Math.Round(((Convert.ToDouble(tempArray[2].Remove(0, 2)) / 60) + (Convert.ToDouble(tempArray[2].Remove(2)))), 6); longitude = Math.Round(((Convert.ToDouble(tempArray[4].Remove(0, 3)) / 60) + (Convert.ToDouble(tempArray[4].Remove(3)))), 6); if (tempArray[3] == "S") { latitude = -latitude; } if (tempArray[5] == "W") { longitude = -longitude; } } catch { } if (lastLongitude != longitude) { OnPositionChange(new PositionChangeEventArgs(latitude, longitude)); } else if (lastLatitude != latitude) { OnPositionChange(new PositionChangeEventArgs(latitude, longitude)); } if (lastFix != fix) { OnPositionFixChange(new PositionFixChangeEventArgs(fix)); } break; case "$GPGSA": break; case "$GPGSV": break; case "$GPRMC": try { if (tempArray[7] == "") { tempArray[7] = "0"; } if (tempArray[8] == "") { tempArray[8] = "0"; } if (tempArray[9] == "") { tempArray[9] = "0"; } date = new GPSDate(tempArray[9]); velocity = (Convert.ToDouble(tempArray[7])) / 0.5399568; heading = Convert.ToDouble(tempArray[8]); } catch { } break; case "$GPVTG": break; case "$GPGLL": break; default: break; } }