The index it uses for the data in the Speed parsing is incorrect. It is using index 5 for knows when it should use index 4. For Km/H it uses 7 when it should be using 6. Here is the code fixed:
if (wordCount > 5 && words[4].Length != 0)
{
_speed = new Speed(
// Parse the numeric portion
double.Parse(words[4], NmeaCultureInfo),
// Use knots
SpeedUnit.Knots);
}
else if (wordCount > 7 && words[6].Length != 0)
{
_speed = new Speed(
// Parse the numeric portion
double.Parse(words[6], NmeaCultureInfo),
// Use knots
SpeedUnit.KilometersPerHour);
}
This may have been caused because of the documentation. It states everything base 1 when it should be base 0. You could change the comments also to be base 0 to make it a little more clear for the future.
if (wordCount > 5 && words[4].Length != 0)
{
_speed = new Speed(
// Parse the numeric portion
double.Parse(words[4], NmeaCultureInfo),
// Use knots
SpeedUnit.Knots);
}
else if (wordCount > 7 && words[6].Length != 0)
{
_speed = new Speed(
// Parse the numeric portion
double.Parse(words[6], NmeaCultureInfo),
// Use knots
SpeedUnit.KilometersPerHour);
}
This may have been caused because of the documentation. It states everything base 1 when it should be base 0. You could change the comments also to be base 0 to make it a little more clear for the future.