4 * This software is distributed under a zlib-style license.
\r
5 * See license.txt for more information.
\r
9 using System.Collections.Generic;
\r
12 namespace Yubeshi.Nmea
\r
15 /// Global Positioning System Fix Data
\r
17 public class GpGga : Packet
\r
19 #region type definitions
\r
20 public enum FixQualityClass
\r
33 private static readonly byte[] header;
\r
34 private const int elementNum = 14;
\r
38 #region constructors
\r
42 header = Encoding.ASCII.GetBytes("$GPGGA,");
\r
49 public GpGga(byte[] sentence)
\r
50 : this(sentence, GetElements(sentence, elementNum))
\r
54 private GpGga(byte[] sentence, Elements elements)
\r
56 Raw = new byte[elements.PacketLength];
\r
57 Array.Copy(sentence, Raw, elements.PacketLength);
\r
58 string[] v = elements.Values;
\r
59 TimeOfFix = ParseTime(v[0]);
\r
60 Position = new Coordinate(v[1], v[2], v[3], v[4]);
\r
61 FixQuality = (FixQualityClass)Int32.Parse(v[5]);
\r
62 TrackedSatellites = Int32.Parse(v[6]);
\r
63 Dilution = Decimal.Parse(v[7]);
\r
64 MslAltitude = GetLength(v[8], v[9]);
\r
65 GeoidSeparation = GetLength(v[10], v[11]);
\r
67 CheckSum = elements.CheckSum;
\r
74 public TimeSpan TimeOfFix
\r
80 public Coordinate Position
\r
86 public FixQualityClass FixQuality
\r
92 public int TrackedSatellites
\r
98 public decimal Dilution
\r
104 public decimal MslAltitude
\r
110 public decimal GeoidSeparation
\r
116 public int StationID
\r
124 public static bool TryParse(byte[] sentence, out Packet packet)
\r
126 return TryParse(sentence, out packet, header, elementNum, Build);
\r
129 private static Packet Build(byte[] sentence, Elements elements)
\r
131 return new GpGga(sentence, elements);
\r