Beispiel #1
0
 /// <summary>
 ///     Process the data from a GGA message.
 /// </summary>
 /// <param name="data">String array of the message components for a CGA message.</param>
 public override void Process(string[] data)
 {
     if (OnPositionCourseAndTimeReceived != null)
     {
         var position = new PositionCourseAndTime();
         position.TimeOfReading = NMEAHelpers.TimeOfReading(data[9], data[1]);
         if (data[2].ToLower() == "a")
         {
             position.Valid = true;
         }
         else
         {
             position.Valid = false;
         }
         position.Latitude  = NMEAHelpers.DegreesMinutesDecode(data[3], data[4]);
         position.Longitude = NMEAHelpers.DegreesMinutesDecode(data[5], data[6]);
         position.Speed     = double.Parse(data[7]);
         position.Course    = double.Parse(data[8]);
         if (data[10].ToLower() == "e")
         {
             position.MagneticVariation = DirectionIndicator.East;
         }
         else
         {
             position.MagneticVariation = DirectionIndicator.West;
         }
         OnPositionCourseAndTimeReceived(this, position);
     }
 }
 /// <summary>
 ///     Process the data from a GGA message.
 /// </summary>
 /// <param name="data">String array of the message components for a CGA message.</param>
 public override void Process(string[] data)
 {
     if (OnPositionReceived != null)
     {
         var invalidFieldCount = 0;
         for (var index = 1; index <= 9; index++)
         {
             if ((data[index] == null) || (data[index] == ""))
             {
                 invalidFieldCount++;
             }
         }
         if (invalidFieldCount == 0)
         {
             var location = new GPSLocation();
             location.ReadingTime                   = NMEAHelpers.TimeOfReading(null, data[1]);
             location.Latitude                      = NMEAHelpers.DegreesMinutesDecode(data[2], data[3]);
             location.Longitude                     = NMEAHelpers.DegreesMinutesDecode(data[4], data[5]);
             location.FixQuality                    = (FixType)Converters.Integer(data[6]);
             location.NumberOfSatellites            = Converters.Integer(data[7]);
             location.HorizontalDilutionOfPrecision = Converters.Double(data[8]);
             location.Altitude                      = Converters.Double(data[9]);
             OnPositionReceived(this, location);
         }
     }
 }
 /// <summary>
 ///     Process the data from a GLL message.
 /// </summary>
 /// <param name="data">String array of the message components for a GLL message.</param>
 public override void Process(string[] data)
 {
     if (OnGeographicLatitudeLongitudeReceived != null)
     {
         //
         //  Status is stored in element 7 (position 6), A = valid, V = not valid.
         //
         if (data[6] == "A")
         {
             var location = new GPSLocation();
             location.Latitude    = NMEAHelpers.DegreesMinutesDecode(data[1], data[2]);
             location.Longitude   = NMEAHelpers.DegreesMinutesDecode(data[3], data[4]);
             location.ReadingTime = NMEAHelpers.TimeOfReading(null, data[5]);
             OnGeographicLatitudeLongitudeReceived(this, location);
         }
     }
 }