mirror of
https://github.com/dotMorten/NmeaParser.git
synced 2025-12-06 07:12:04 +01:00
Fixes #53
This commit is contained in:
parent
d8cef4a3fc
commit
ee7d6ce1c7
|
|
@ -98,8 +98,10 @@ namespace NmeaParser.Nmea
|
|||
internal SatelliteVehicle(string[] message, int startIndex)
|
||||
{
|
||||
PrnNumber = int.Parse(message[startIndex], CultureInfo.InvariantCulture);
|
||||
Elevation = double.Parse(message[startIndex + 1], CultureInfo.InvariantCulture);
|
||||
Azimuth = double.Parse(message[startIndex + 2], CultureInfo.InvariantCulture);
|
||||
if (double.TryParse(message[startIndex + 1], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out double e))
|
||||
Elevation = e;
|
||||
if (double.TryParse(message[startIndex + 2], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out double a))
|
||||
Azimuth = a;
|
||||
int snr = -1;
|
||||
if (int.TryParse(message[startIndex + 3], out snr))
|
||||
SignalToNoiseRatio = snr;
|
||||
|
|
@ -111,15 +113,15 @@ namespace NmeaParser.Nmea
|
|||
/// <summary>
|
||||
/// Elevation in degrees, 90 maximum
|
||||
/// </summary>
|
||||
public double Elevation { get; }
|
||||
public double Elevation { get; } = double.NaN;
|
||||
/// <summary>
|
||||
/// Azimuth, degrees from true north, 000 to 359
|
||||
/// </summary>
|
||||
public double Azimuth { get; }
|
||||
public double Azimuth { get; } = double.NaN;
|
||||
/// <summary>
|
||||
/// Signal-to-Noise ratio, 0-99 dB (-1 when not tracking)
|
||||
/// </summary>
|
||||
public int SignalToNoiseRatio { get; }
|
||||
public int SignalToNoiseRatio { get; } = -1;
|
||||
|
||||
/// <summary>
|
||||
/// Satellite system
|
||||
|
|
|
|||
|
|
@ -343,6 +343,26 @@ namespace NmeaParser.Tests
|
|||
Assert.AreEqual(0, gsv.SVs.Count);
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
[WorkItem(53)]
|
||||
public void TestGpgsv_MissingElevationAndAzimuth()
|
||||
{
|
||||
string msgstr = "$GPGSV,3,1,12,02,06,225,16,04,,,40,05,65,251,27,07,40,057,43,0*51";
|
||||
var msg = NmeaMessage.Parse(msgstr);
|
||||
Assert.IsInstanceOfType(msg, typeof(Gsv));
|
||||
Gsv gsv = (Gsv)msg;
|
||||
Assert.AreEqual(3, gsv.TotalMessages);
|
||||
Assert.AreEqual(1, gsv.MessageNumber);
|
||||
Assert.AreEqual(12, gsv.SVsInView);
|
||||
Assert.IsNotNull(gsv.SVs);
|
||||
Assert.AreEqual(4, gsv.SVs.Count);
|
||||
Assert.AreEqual(4, gsv.SVs[1].PrnNumber);
|
||||
Assert.IsTrue(double.IsNaN(gsv.SVs[1].Elevation));
|
||||
Assert.IsTrue(double.IsNaN(gsv.SVs[1].Azimuth));
|
||||
Assert.AreEqual(40, gsv.SVs[1].SignalToNoiseRatio);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestGpgll()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue