Skip to content

LAT LON conversion to decimals appears to ignore compass ref #1

@stjagu

Description

@stjagu
def gps_to_decimal(coord, ref):
    """
    Converts GPS coordinates to decimal degrees.

    Args:
        coord (tuple): A tuple containing the GPS coordinates.
        ref (str): The reference direction (e.g., N, S, E, W).

    Returns:
        float: The GPS coordinates in decimal degrees.
    """
    decimal = coord[0][0] / coord[0][1] + coord[1][0] / (60 * coord[1][1]) + coord[2][0] / (3600 * coord[2][1])
    if ref in ['S', 'W']:
        decimal *= -1
    return decimal

If I change S to N and W to E the results are the same, positive Coords rather than negative for N or E.

I added gps lat lon ref to see if it was reading, it returns b'N' and b'W'

'gps_latitude': gps_latitude_decimal,
'gps_latitude_ref': gps_latitude_ref,
'gps_longitude': gps_longitude_decimal,
'gps_longitude_ref': gps_longitude_ref,

Are you seeing same behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions