dd_to_dms

ssapy.utils.dd_to_dms(degree_decimal)[source][source]

Converts a Decimal Degree (DD) value to Degree-Minute-Second (DMS) format.

Parameters:

degree_decimal (float): A single decimal degree value to be converted to DMS format.

Positive values represent north/east, and negative values represent south/west.

Returns:

str: A string representing the DMS format (e.g., “12:34:56”). The format includes:
  • Degrees as an integer.

  • Minutes as an integer.

  • Seconds as a float (rounded to 4 decimal places if necessary).

Notes:

  • Handles negative decimal degree values correctly, ensuring the DMS format reflects the correct sign for degrees, minutes, and seconds.

  • Ensures seconds are properly rounded and handles edge cases where seconds reach 60, incrementing minutes accordingly.

  • Returns seconds as an integer if the value is a whole number.

Example:

>>> dd_to_dms(12.582222222222223)
'12:34:56'
>>> dd_to_dms(-45.50416666666667)
'-45:30:15'
>>> dd_to_dms(0.0002777777777777778)
'0:0:1'