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
55 : base(sentence, elements.PacketLength)
\r
57 string[] v = elements.Values;
\r
58 TimeOfFix = ParseTime(v[0]);
\r
59 Position = new GeodeticCoordinate(
\r
60 Degree.FromNmeaFormat(v[1], v[2]),
\r
61 Degree.FromNmeaFormat(v[3], v[4]));
\r
62 FixQuality = (FixQualityClass)Int32.Parse(v[5]);
\r
63 TrackedSatellites = Int32.Parse(v[6]);
\r
64 HorizontalDop = ParseDouble(v[7]);
\r
65 MslAltitude = new Height(GetLength(v[8], v[9]),
\r
66 Height.Base.MeanSeaLevel);
\r
67 GeoidSeparation = new Height(GetLength(v[10], v[11]),
\r
68 Height.Base.Wgs84Ellipsoid);
\r
69 double age = ParseDouble(v[12]);
\r
71 AgeOfDgpsCorrections = Double.IsNaN(age)?
\r
72 TimeSpan.MinValue :TimeSpan.FromSeconds(age);
\r
73 DgpsStation = ParseInt(v[13], -1);
\r
74 CheckSum = elements.CheckSum;
\r
81 public TimeSpan TimeOfFix
\r
87 public GeodeticCoordinate Position
\r
93 public FixQualityClass FixQuality
\r
99 public int TrackedSatellites
\r
105 public double HorizontalDop
\r
111 public Height MslAltitude
\r
117 public Height GeoidSeparation
\r
123 public TimeSpan AgeOfDgpsCorrections
\r
129 public int DgpsStation
\r
137 public static bool TryParse(byte[] sentence, out UnknownPacket packet)
\r
139 return TryParse(sentence, out packet, header, elementNum, Build);
\r
142 private static Packet Build(byte[] sentence, Elements elements)
\r
144 return new GpGga(sentence, elements);
\r