diff --git a/src/NmeaParser/Nmea/Gga.cs b/src/NmeaParser/Nmea/Gga.cs new file mode 100644 index 0000000..7e2772f --- /dev/null +++ b/src/NmeaParser/Nmea/Gga.cs @@ -0,0 +1,122 @@ +// +// Copyright (c) 2014 Morten Nielsen +// +// Licensed under the Microsoft Public License (Ms-PL) (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://opensource.org/licenses/Ms-PL.html +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NmeaParser.Nmea +{ + /// + /// Global Positioning System Fix Data + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpgga")] + public class Gga : NmeaMessage + { + /// + /// Called when the message is being loaded. + /// + /// The NMEA message values. + protected override void OnLoadMessage(string[] message) + { + if (message == null || message.Length < 14) + throw new ArgumentException("Invalid GPGGA", "message"); + FixTime = StringToTimeSpan(message[0]); + Latitude = NmeaMessage.StringToLatitude(message[1], message[2]); + Longitude = NmeaMessage.StringToLongitude(message[3], message[4]); + Quality = (Gps.Gpgga.FixQuality)int.Parse(message[5], CultureInfo.InvariantCulture); + NumberOfSatellites = int.Parse(message[6], CultureInfo.InvariantCulture); + Hdop = NmeaMessage.StringToDouble(message[7]); + Altitude = NmeaMessage.StringToDouble(message[8]); + AltitudeUnits = message[9]; + HeightOfGeoid = NmeaMessage.StringToDouble(message[10]); + HeightOfGeoidUnits = message[11]; + var timeInSeconds = StringToDouble(message[12]); + if (!double.IsNaN(timeInSeconds)) + TimeSinceLastDgpsUpdate = TimeSpan.FromSeconds(timeInSeconds); + else + TimeSinceLastDgpsUpdate = TimeSpan.MaxValue; + if (message[13].Length > 0) + DgpsStationId = int.Parse(message[13], CultureInfo.InvariantCulture); + else + DgpsStationId = -1; + } + + /// + /// Time of day fix was taken + /// + public TimeSpan FixTime { get; private set; } + + /// + /// Latitude + /// + public double Latitude { get; private set; } + + /// + /// Longitude + /// + public double Longitude { get; private set; } + + /// + /// Fix Quality + /// + public Gps.Gpgga.FixQuality Quality { get; private set; } + + /// + /// Number of satellites being tracked + /// + public int NumberOfSatellites { get; private set; } + + /// + /// Horizontal Dilution of Precision + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hdop")] + public double Hdop { get; private set; } + + /// + /// Altitude + /// + public double Altitude { get; private set; } + + /// + /// Altitude units ('M' for Meters) + /// + public string AltitudeUnits { get; private set; } + + /// + /// Height of geoid (mean sea level) above WGS84 + /// + public double HeightOfGeoid { get; private set; } + + /// + /// Altitude units ('M' for Meters) + /// + public string HeightOfGeoidUnits { get; private set; } + + /// + /// Time since last DGPS update + /// + public TimeSpan TimeSinceLastDgpsUpdate { get; private set; } + + /// + /// DGPS Station ID Number + /// + public int DgpsStationId { get; private set; } + } +} diff --git a/src/NmeaParser/Nmea/Gnss/Gngga.cs b/src/NmeaParser/Nmea/Gnss/Gngga.cs new file mode 100644 index 0000000..448eb0d --- /dev/null +++ b/src/NmeaParser/Nmea/Gnss/Gngga.cs @@ -0,0 +1,34 @@ +// +// Copyright (c) 2014 Morten Nielsen +// +// Licensed under the Microsoft Public License (Ms-PL) (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://opensource.org/licenses/Ms-PL.html +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NmeaParser.Nmea.Gnss +{ + /// + /// Global Positioning System Fix Data + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpgga")] + [NmeaMessageType("GNGGA")] + public class Gngga : Gga + { + } +} diff --git a/src/NmeaParser/Nmea/Gnss/Gngst.cs b/src/NmeaParser/Nmea/Gnss/Gngst.cs index c195448..f25a849 100644 --- a/src/NmeaParser/Nmea/Gnss/Gngst.cs +++ b/src/NmeaParser/Nmea/Gnss/Gngst.cs @@ -7,74 +7,7 @@ namespace NmeaParser.Nmea.Gnss /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gngst")] [NmeaMessageType("GNGST")] - public class Gngst : NmeaMessage + public class Gngst : Gst { - /// - /// Called when the message is being loaded. - /// - /// The NMEA message values. - protected override void OnLoadMessage(string[] message) - { - if (message == null || message.Length < 8) - throw new ArgumentException("Invalid GNGST", "message"); - FixTime = StringToTimeSpan(message[0]); - Rms = NmeaMessage.StringToDouble(message[1]); - SemiMajorError = NmeaMessage.StringToDouble(message[2]); - SemiMinorError = NmeaMessage.StringToDouble(message[3]); - ErrorOrientation = NmeaMessage.StringToDouble(message[4]); - SigmaLatitudeError = NmeaMessage.StringToDouble(message[5]); - SigmaLongitudeError = NmeaMessage.StringToDouble(message[6]); - SigmaHeightError = NmeaMessage.StringToDouble(message[7]); - } - - /// - /// UTC of position fix - /// - public TimeSpan FixTime { get; private set; } - - /// - /// RMS value of the pseudorange residuals; includes carrier phase residuals during periods of RTK (float) and RTK (fixed) processing - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rms")] - public double Rms { get; private set; } - - /// - /// Error ellipse semi-major axis 1 sigma error, in meters - /// - public double SemiMajorError { get; private set; } - - /// - /// Error ellipse semi-minor axis 1 sigma error, in meters - /// - public double SemiMinorError { get; private set; } - - /// - /// Error ellipse orientation, degrees from true north - /// - public double ErrorOrientation { get; private set; } - - /// - /// Latitude 1 sigma error, in meters - /// - /// - /// The error expressed as one standard deviation. - /// - public double SigmaLatitudeError { get; private set; } - - /// - /// Longitude 1 sigma error, in meters - /// - /// - /// The error expressed as one standard deviation. - /// - public double SigmaLongitudeError { get; private set; } - - /// - /// Height 1 sigma error, in meters - /// - /// - /// The error expressed as one standard deviation. - /// - public double SigmaHeightError { get; private set; } } } diff --git a/src/NmeaParser/Nmea/Gnss/Gnrmc.cs b/src/NmeaParser/Nmea/Gnss/Gnrmc.cs new file mode 100644 index 0000000..b0bb136 --- /dev/null +++ b/src/NmeaParser/Nmea/Gnss/Gnrmc.cs @@ -0,0 +1,34 @@ +// +// Copyright (c) 2014 Morten Nielsen +// +// Licensed under the Microsoft Public License (Ms-PL) (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://opensource.org/licenses/Ms-PL.html +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NmeaParser.Nmea.Gnss +{ + /// + /// Recommended Minimum + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gprmc")] + [NmeaMessageType("GNRMC")] + public class Gnrmc : Rmc + { + } +} diff --git a/src/NmeaParser/Nmea/Gps/GPGGA.cs b/src/NmeaParser/Nmea/Gps/GPGGA.cs index f355f1b..42d2a44 100644 --- a/src/NmeaParser/Nmea/Gps/GPGGA.cs +++ b/src/NmeaParser/Nmea/Gps/GPGGA.cs @@ -28,7 +28,7 @@ namespace NmeaParser.Nmea.Gps /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpgga")] [NmeaMessageType("GPGGA")] - public class Gpgga : NmeaMessage + public class Gpgga : Gga { /// /// Fix quality @@ -58,95 +58,5 @@ namespace NmeaParser.Nmea.Gps /// Simulation Simulation = 8 } - - /// - /// Called when the message is being loaded. - /// - /// The NMEA message values. - protected override void OnLoadMessage(string[] message) - { - if (message == null || message.Length < 14) - throw new ArgumentException("Invalid GPGGA", "message"); - FixTime = StringToTimeSpan(message[0]); - Latitude = NmeaMessage.StringToLatitude(message[1], message[2]); - Longitude = NmeaMessage.StringToLongitude(message[3], message[4]); - Quality = (FixQuality)int.Parse(message[5], CultureInfo.InvariantCulture); - NumberOfSatellites = int.Parse(message[6], CultureInfo.InvariantCulture); - Hdop = NmeaMessage.StringToDouble(message[7]); - Altitude = NmeaMessage.StringToDouble(message[8]); - AltitudeUnits = message[9]; - HeightOfGeoid = NmeaMessage.StringToDouble(message[10]); - HeightOfGeoidUnits = message[11]; - var timeInSeconds = StringToDouble(message[12]); - if (!double.IsNaN(timeInSeconds)) - TimeSinceLastDgpsUpdate = TimeSpan.FromSeconds(timeInSeconds); - else - TimeSinceLastDgpsUpdate = TimeSpan.MaxValue; - if (message[13].Length > 0) - DgpsStationId = int.Parse(message[13], CultureInfo.InvariantCulture); - else - DgpsStationId = -1; - } - - /// - /// Time of day fix was taken - /// - public TimeSpan FixTime { get; private set; } - - /// - /// Latitude - /// - public double Latitude { get; private set; } - - /// - /// Longitude - /// - public double Longitude { get; private set; } - - /// - /// Fix Quality - /// - public FixQuality Quality { get; private set; } - - /// - /// Number of satellites being tracked - /// - public int NumberOfSatellites { get; private set; } - - /// - /// Horizontal Dilution of Precision - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hdop")] - public double Hdop { get; private set; } - - /// - /// Altitude - /// - public double Altitude { get; private set; } - - /// - /// Altitude units ('M' for Meters) - /// - public string AltitudeUnits { get; private set; } - - /// - /// Height of geoid (mean sea level) above WGS84 - /// - public double HeightOfGeoid { get; private set; } - - /// - /// Altitude units ('M' for Meters) - /// - public string HeightOfGeoidUnits { get; private set; } - - /// - /// Time since last DGPS update - /// - public TimeSpan TimeSinceLastDgpsUpdate { get; private set; } - - /// - /// DGPS Station ID Number - /// - public int DgpsStationId { get; private set; } } } diff --git a/src/NmeaParser/Nmea/Gps/GPGST.cs b/src/NmeaParser/Nmea/Gps/GPGST.cs index d1a19d4..5262d68 100644 --- a/src/NmeaParser/Nmea/Gps/GPGST.cs +++ b/src/NmeaParser/Nmea/Gps/GPGST.cs @@ -28,74 +28,7 @@ namespace NmeaParser.Nmea.Gps /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpgst")] [NmeaMessageType("GPGST")] - public class Gpgst : NmeaMessage + public class Gpgst : Gst { - /// - /// Called when the message is being loaded. - /// - /// The NMEA message values. - protected override void OnLoadMessage(string[] message) - { - if (message == null || message.Length < 8) - throw new ArgumentException("Invalid GPGST", "message"); - FixTime = StringToTimeSpan(message[0]); - Rms = NmeaMessage.StringToDouble(message[1]); - SemiMajorError = NmeaMessage.StringToDouble(message[2]); - SemiMinorError = NmeaMessage.StringToDouble(message[3]); - ErrorOrientation = NmeaMessage.StringToDouble(message[4]); - SigmaLatitudeError = NmeaMessage.StringToDouble(message[5]); - SigmaLongitudeError = NmeaMessage.StringToDouble(message[6]); - SigmaHeightError = NmeaMessage.StringToDouble(message[7]); - } - - /// - /// UTC of position fix - /// - public TimeSpan FixTime { get; private set; } - - /// - /// RMS value of the pseudorange residuals; includes carrier phase residuals during periods of RTK (float) and RTK (fixed) processing - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rms")] - public double Rms { get; private set; } - - /// - /// Error ellipse semi-major axis 1 sigma error, in meters - /// - public double SemiMajorError { get; private set; } - - /// - /// Error ellipse semi-minor axis 1 sigma error, in meters - /// - public double SemiMinorError { get; private set; } - - /// - /// Error ellipse orientation, degrees from true north - /// - public double ErrorOrientation { get; private set; } - - /// - /// Latitude 1 sigma error, in meters - /// - /// - /// The error expressed as one standard deviation. - /// - public double SigmaLatitudeError { get; private set; } - - /// - /// Longitude 1 sigma error, in meters - /// - /// - /// The error expressed as one standard deviation. - /// - public double SigmaLongitudeError { get; private set; } - - /// - /// Height 1 sigma error, in meters - /// - /// - /// The error expressed as one standard deviation. - /// - public double SigmaHeightError { get; private set; } } } diff --git a/src/NmeaParser/Nmea/Gps/GPRMC.cs b/src/NmeaParser/Nmea/Gps/GPRMC.cs index d99fd1f..1b99ae8 100644 --- a/src/NmeaParser/Nmea/Gps/GPRMC.cs +++ b/src/NmeaParser/Nmea/Gps/GPRMC.cs @@ -28,69 +28,7 @@ namespace NmeaParser.Nmea.Gps /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gprmc")] [NmeaMessageType("GPRMC")] - public class Gprmc : NmeaMessage + public class Gprmc : Rmc { - /// - /// Called when the message is being loaded. - /// - /// The NMEA message values. - protected override void OnLoadMessage(string[] message) - { - if (message == null || message.Length < 11) - throw new ArgumentException("Invalid GPRMC", "message"); - - if (message[8].Length == 6 && message[0].Length >= 6) - { - FixTime = new DateTime(int.Parse(message[8].Substring(4, 2), CultureInfo.InvariantCulture) + 2000, - int.Parse(message[8].Substring(2, 2), CultureInfo.InvariantCulture), - int.Parse(message[8].Substring(0, 2), CultureInfo.InvariantCulture), - int.Parse(message[0].Substring(0, 2), CultureInfo.InvariantCulture), - int.Parse(message[0].Substring(2, 2), CultureInfo.InvariantCulture), - 0, DateTimeKind.Utc).AddSeconds(double.Parse(message[0].Substring(4), CultureInfo.InvariantCulture)); - } - Active = (message[1] == "A"); - Latitude = NmeaMessage.StringToLatitude(message[2], message[3]); - Longitude = NmeaMessage.StringToLongitude(message[4], message[5]); - Speed = NmeaMessage.StringToDouble(message[6]); - Course = NmeaMessage.StringToDouble(message[7]); - MagneticVariation = NmeaMessage.StringToDouble(message[9]); - if (!double.IsNaN(MagneticVariation) && message[10] == "W") - MagneticVariation *= -1; - } - - /// - /// Fix Time - /// - public DateTime FixTime { get; private set; } - - /// - /// Gets a value whether the device is active - /// - public bool Active { get; private set; } - - /// - /// Latitude - /// - public double Latitude { get; private set; } - - /// - /// Longitude - /// - public double Longitude { get; private set; } - - /// - /// Speed over the ground in knots - /// - public double Speed { get; private set; } - - /// - /// Track angle in degrees True - /// - public double Course { get; private set; } - - /// - /// Magnetic Variation - /// - public double MagneticVariation { get; private set; } } } diff --git a/src/NmeaParser/Nmea/Gst.cs b/src/NmeaParser/Nmea/Gst.cs new file mode 100644 index 0000000..cc38c35 --- /dev/null +++ b/src/NmeaParser/Nmea/Gst.cs @@ -0,0 +1,100 @@ +// +// Copyright (c) 2014 Morten Nielsen +// +// Licensed under the Microsoft Public License (Ms-PL) (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://opensource.org/licenses/Ms-PL.html +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NmeaParser.Nmea +{ + /// + /// Position error statistics + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpgst")] + public abstract class Gst : NmeaMessage + { + /// + /// Called when the message is being loaded. + /// + /// The NMEA message values. + protected override void OnLoadMessage(string[] message) + { + if (message == null || message.Length < 8) + throw new ArgumentException("Invalid GPGST", "message"); + FixTime = StringToTimeSpan(message[0]); + Rms = NmeaMessage.StringToDouble(message[1]); + SemiMajorError = NmeaMessage.StringToDouble(message[2]); + SemiMinorError = NmeaMessage.StringToDouble(message[3]); + ErrorOrientation = NmeaMessage.StringToDouble(message[4]); + SigmaLatitudeError = NmeaMessage.StringToDouble(message[5]); + SigmaLongitudeError = NmeaMessage.StringToDouble(message[6]); + SigmaHeightError = NmeaMessage.StringToDouble(message[7]); + } + + /// + /// UTC of position fix + /// + public TimeSpan FixTime { get; private set; } + + /// + /// RMS value of the pseudorange residuals; includes carrier phase residuals during periods of RTK (float) and RTK (fixed) processing + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rms")] + public double Rms { get; private set; } + + /// + /// Error ellipse semi-major axis 1 sigma error, in meters + /// + public double SemiMajorError { get; private set; } + + /// + /// Error ellipse semi-minor axis 1 sigma error, in meters + /// + public double SemiMinorError { get; private set; } + + /// + /// Error ellipse orientation, degrees from true north + /// + public double ErrorOrientation { get; private set; } + + /// + /// Latitude 1 sigma error, in meters + /// + /// + /// The error expressed as one standard deviation. + /// + public double SigmaLatitudeError { get; private set; } + + /// + /// Longitude 1 sigma error, in meters + /// + /// + /// The error expressed as one standard deviation. + /// + public double SigmaLongitudeError { get; private set; } + + /// + /// Height 1 sigma error, in meters + /// + /// + /// The error expressed as one standard deviation. + /// + public double SigmaHeightError { get; private set; } + } +} diff --git a/src/NmeaParser/Nmea/Rmc.cs b/src/NmeaParser/Nmea/Rmc.cs new file mode 100644 index 0000000..8ef289a --- /dev/null +++ b/src/NmeaParser/Nmea/Rmc.cs @@ -0,0 +1,95 @@ +// +// Copyright (c) 2014 Morten Nielsen +// +// Licensed under the Microsoft Public License (Ms-PL) (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://opensource.org/licenses/Ms-PL.html +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NmeaParser.Nmea +{ + /// + /// Recommended Minimum + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gprmc")] + public abstract class Rmc : NmeaMessage + { + /// + /// Called when the message is being loaded. + /// + /// The NMEA message values. + protected override void OnLoadMessage(string[] message) + { + if (message == null || message.Length < 11) + throw new ArgumentException("Invalid GPRMC", "message"); + + if (message[8].Length == 6 && message[0].Length >= 6) + { + FixTime = new DateTime(int.Parse(message[8].Substring(4, 2), CultureInfo.InvariantCulture) + 2000, + int.Parse(message[8].Substring(2, 2), CultureInfo.InvariantCulture), + int.Parse(message[8].Substring(0, 2), CultureInfo.InvariantCulture), + int.Parse(message[0].Substring(0, 2), CultureInfo.InvariantCulture), + int.Parse(message[0].Substring(2, 2), CultureInfo.InvariantCulture), + 0, DateTimeKind.Utc).AddSeconds(double.Parse(message[0].Substring(4), CultureInfo.InvariantCulture)); + } + Active = (message[1] == "A"); + Latitude = NmeaMessage.StringToLatitude(message[2], message[3]); + Longitude = NmeaMessage.StringToLongitude(message[4], message[5]); + Speed = NmeaMessage.StringToDouble(message[6]); + Course = NmeaMessage.StringToDouble(message[7]); + MagneticVariation = NmeaMessage.StringToDouble(message[9]); + if (!double.IsNaN(MagneticVariation) && message[10] == "W") + MagneticVariation *= -1; + } + + /// + /// Fix Time + /// + public DateTime FixTime { get; private set; } + + /// + /// Gets a value whether the device is active + /// + public bool Active { get; private set; } + + /// + /// Latitude + /// + public double Latitude { get; private set; } + + /// + /// Longitude + /// + public double Longitude { get; private set; } + + /// + /// Speed over the ground in knots + /// + public double Speed { get; private set; } + + /// + /// Track angle in degrees True + /// + public double Course { get; private set; } + + /// + /// Magnetic Variation + /// + public double MagneticVariation { get; private set; } + } +} diff --git a/src/NmeaParser/NmeaParser.csproj b/src/NmeaParser/NmeaParser.csproj index d63f9c3..4afa43d 100644 --- a/src/NmeaParser/NmeaParser.csproj +++ b/src/NmeaParser/NmeaParser.csproj @@ -11,7 +11,7 @@ An NMEA stream parser for serial port, bluetooth and file-based nmea simulation. nmea winrt wpf win8 win8.1 wp8.1 uwp xamarin gps serialport bluetooth SharpGIS.NmeaParser - 1.7.0 + 1.8.0 http://opensource.org/licenses/ms-pl.html https://github.com/dotMorten/NmeaParser https://github.com/dotMorten/NmeaParser diff --git a/src/UnitTests/NmeaParser.Tests/NmeaMessages.cs b/src/UnitTests/NmeaParser.Tests/NmeaMessages.cs index 624f449..60a486f 100644 --- a/src/UnitTests/NmeaParser.Tests/NmeaMessages.cs +++ b/src/UnitTests/NmeaParser.Tests/NmeaMessages.cs @@ -103,7 +103,24 @@ namespace NmeaParser.Tests Assert.AreEqual(-11.516666666666667, rmc.Longitude, 0.0000000001); } - [TestMethod] + [TestMethod] + public void TestGnrmc() + { + string input = "$GNRMC,231011.00,A,3403.47163804,N,11711.80926595,W,0.019,11.218,201217,12.0187,E,D*01"; + var msg = NmeaMessage.Parse(input); + Assert.IsInstanceOfType(msg, typeof(Gnrmc)); + Gnrmc rmc = (Gnrmc)msg; + Assert.AreEqual("GNRMC", rmc.MessageType); + Assert.AreEqual(new DateTime(2017, 12, 20, 23, 10, 11, DateTimeKind.Utc), rmc.FixTime); + Assert.AreEqual(34.057860634, rmc.Latitude, 0.0000000001); + Assert.AreEqual(-117.19682109916667, rmc.Longitude, 0.0000000001); + Assert.AreEqual(true, rmc.Active); + Assert.AreEqual(11.218, rmc.Course); + Assert.AreEqual(12.0187, rmc.MagneticVariation); + Assert.AreEqual(0.019, rmc.Speed); + } + + [TestMethod] public void TestGpgga() { string input = "$GPGGA,235236,3925.9479,N,11945.9211,W,1,10,0.8,1378.0,M,-22.1,M,,*46"; @@ -124,7 +141,28 @@ namespace NmeaParser.Tests Assert.AreEqual(TimeSpan.MaxValue, gga.TimeSinceLastDgpsUpdate); } - [TestMethod] + [TestMethod] + public void TestGngga() + { + string input = "$GNGGA,231011.00,3403.47163804,N,11711.80926595,W,5,13,0.9,403.641,M,-32.133,M,1.0,0000*6D"; + var msg = NmeaMessage.Parse(input); + Assert.IsInstanceOfType(msg, typeof(Gngga)); + Gngga gga = (Gngga)msg; + Assert.AreEqual(new TimeSpan(23, 10, 11), gga.FixTime); + Assert.AreEqual(34.057860634, gga.Latitude); + Assert.AreEqual(-117.19682109916667, gga.Longitude, 0.0000000001); + Assert.AreEqual(NmeaParser.Nmea.Gps.Gpgga.FixQuality.FloatRtk, gga.Quality); + Assert.AreEqual(13, gga.NumberOfSatellites); + Assert.AreEqual(.9, gga.Hdop); + Assert.AreEqual(403.641, gga.Altitude); + Assert.AreEqual("M", gga.AltitudeUnits); + Assert.AreEqual(-32.133, gga.HeightOfGeoid); + Assert.AreEqual("M", gga.HeightOfGeoidUnits); + Assert.AreEqual(0, gga.DgpsStationId); + Assert.AreEqual(TimeSpan.FromSeconds(1), gga.TimeSinceLastDgpsUpdate); + } + + [TestMethod] public void TestPtlna() { string input = "$PTNLA,HV,002.94,M,288.1,D,008.6,D,002.98,M*74"; @@ -359,7 +397,6 @@ namespace NmeaParser.Tests Assert.AreEqual("BW-198", gsv.Waypoints[8]); } - [TestMethod] public void TestGpgst() {