diff --git a/src/NmeaParser/Nmea/Gps/GPVTG.cs b/src/NmeaParser/Nmea/Gps/GPVTG.cs
new file mode 100644
index 0000000..96eb2d7
--- /dev/null
+++ b/src/NmeaParser/Nmea/Gps/GPVTG.cs
@@ -0,0 +1,64 @@
+//
+// 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.Text;
+
+namespace NmeaParser.Nmea.Gps
+{
+ ///
+ /// Course over ground and ground speed
+ ///
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "GPVTG")]
+ [NmeaMessageType("GPVTG")]
+ public class Gpvtg : NmeaMessage
+ {
+ ///
+ /// Called when the message is being loaded.
+ ///
+ /// The NMEA message values.
+ protected override void OnLoadMessage(string[] message)
+ {
+ if (message == null || message.Length < 7)
+ throw new ArgumentException("Invalid Gpvtg", "message");
+ TrueCourseOverGround = NmeaMessage.StringToDouble(message[0]);
+ MagneticCourseOverGround = NmeaMessage.StringToDouble(message[2]);
+ SpeedInKnots = NmeaMessage.StringToDouble(message[4]);
+ SpeedInKph = NmeaMessage.StringToDouble(message[6]);
+ }
+
+ ///
+ /// Course over ground relative to true north
+ ///
+ public double TrueCourseOverGround { get; private set; } = double.NaN;
+
+ ///
+ /// Course over ground relative to magnetic north
+ ///
+ public double MagneticCourseOverGround { get; private set; } = double.NaN;
+
+ ///
+ /// Speed over ground in knots
+ ///
+ public double SpeedInKnots { get; private set; } = double.NaN;
+
+ ///
+ /// Speed over ground in kilometers/hour
+ ///
+ public double SpeedInKph { get; private set; } = double.NaN;
+ }
+}
\ No newline at end of file
diff --git a/src/UnitTests/NmeaParser.Tests/NmeaMessages.cs b/src/UnitTests/NmeaParser.Tests/NmeaMessages.cs
index ec9155e..ef6da1e 100644
--- a/src/UnitTests/NmeaParser.Tests/NmeaMessages.cs
+++ b/src/UnitTests/NmeaParser.Tests/NmeaMessages.cs
@@ -588,5 +588,31 @@ namespace NmeaParser.Tests
Assert.AreEqual(0.020, gst.SigmaLongitudeError);
Assert.AreEqual(0.031, gst.SigmaHeightError);
}
+
+ [TestMethod]
+ public void TestGpvtg()
+ {
+ string input = "$GPVTG,103.85,T,92.79,M,0.14,N,0.25,K,D*1E";
+ var msg = NmeaMessage.Parse(input);
+ Assert.IsInstanceOfType(msg, typeof(Gpvtg));
+ Gpvtg vtg = (Gpvtg)msg;
+ Assert.AreEqual(103.85, vtg.TrueCourseOverGround);
+ Assert.AreEqual(92.79, vtg.MagneticCourseOverGround);
+ Assert.AreEqual(0.14, vtg.SpeedInKnots);
+ Assert.AreEqual(0.25, vtg.SpeedInKph);
+ }
+
+ [TestMethod]
+ public void TestGpvtg_Empty()
+ {
+ string input = "$GPVTG,,T,,M,0.00,N,0.00,K*4E";
+ var msg = NmeaMessage.Parse(input);
+ Assert.IsInstanceOfType(msg, typeof(Gpvtg));
+ Gpvtg vtg = (Gpvtg)msg;
+ Assert.IsTrue(double.IsNaN(vtg.TrueCourseOverGround));
+ Assert.IsTrue(double.IsNaN(vtg.MagneticCourseOverGround));
+ Assert.AreEqual(0.0, vtg.SpeedInKnots);
+ Assert.AreEqual(0.0, vtg.SpeedInKph);
+ }
}
}