Skip to content

Commit

Permalink
Add DMS to decimal conversion to NMEA utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
duduita committed May 22, 2024
1 parent 17403d3 commit b8c625e
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,20 @@ public override string ToString()
};
return $"{Degrees:f2}° {Minutes:f2}' {Seconds:f2}\"{direction}";
}

/// <summary>
/// Converts the geographical position from degrees, minutes, and seconds (DMS) to a decimal format for latitude or longitude.
/// </summary>
/// <returns>A double value representing the converted decimal position.</returns>
public double ConvertDegreesMinutesSecondsToDecimal()
{
double result = Degrees + (double)Minutes / 60 + (double)Seconds / 3600;

if (Direction == CardinalDirection.South || Direction == CardinalDirection.West)
{
result = -result;
}

return result;
}
}

0 comments on commit b8c625e

Please sign in to comment.