public override bool Parse(String nmea) { if (base.Parse(nmea)) { IsValid = false; String[] tokens = nmea.Substring(0, nmea.IndexOf("*")).Split(','); if (tokens.Length > 14 && tokens[1].Length > 0) { try { FixTime = DateTime.ParseExact(tokens[1], GGATimeFormatters, CultureInfo.InvariantCulture, DateTimeStyles.None); Latitude = Latitude.fromDecimalDMS( Double.Parse(tokens[2]), GeoSpatialTypes.ParseNorthSouth(tokens[3]) ); Longitude = Longitude.fromDecimalDMS( Double.Parse(tokens[4]), GeoSpatialTypes.ParseEastWest(tokens[5]) ); FixQuality = GpsFixTypeExtensions.Parse(tokens[6]); TrackedSatellitesCount = Int32.Parse(tokens[7]); HorizDilution = Double.Parse(tokens[8]); Elevation = Double.Parse(tokens[9]); UomElevation = GeoSpatialTypes.ParseUomElevation(tokens[10]); GeoidHeight = Double.Parse(tokens[11]); GeoUom = GeoSpatialTypes.ParseUomElevation(tokens[12]); IsValid = true; } catch { // } } } return(IsValid); }
public override bool Parse(string nmea) { if (base.Parse(nmea)) { IsValid = false; String[] tokens = nmea.Substring(0, nmea.IndexOf("*")).Split(','); if (tokens.Length > 12 && tokens[1].Length > 0) { try { FixTime = DateTime.ParseExact( $"{tokens[1]} {tokens[9]}", RMCTimeFormatters, CultureInfo.InvariantCulture, DateTimeStyles.None); Status = StatusExtensions.Parse(tokens[2]); Latitude = Latitude.fromDecimalDMS( Double.Parse(tokens[3]), GeoSpatialTypes.ParseNorthSouth(tokens[4]) ); Longitude = Longitude.fromDecimalDMS( Double.Parse(tokens[5]), GeoSpatialTypes.ParseEastWest(tokens[6]) ); String token = tokens[7]; if (!String.IsNullOrEmpty(token)) { GroundSpeed = Double.Parse(token); } token = tokens[8]; if (!String.IsNullOrEmpty(token)) { TrackAngle = Double.Parse(token); } token = tokens[10]; if (!String.IsNullOrEmpty(token)) { MagVar = Double.Parse(token); } token = tokens[11]; if (!String.IsNullOrEmpty(token)) { MagVarDir = GeoSpatialTypes.ParseEastWest(token); } IsValid = true; } catch { // } } } return(IsValid); }