import ctypes
import math

ICD1553_GEOPOS_SC_LSB = 4.65661E-10
GC_K_PI = math.pi
ICD1553_GEOPOS_RAD_LSB = ICD1553_GEOPOS_SC_LSB * GC_K_PI

class LatLong(ctypes.Union):
    _fields_ = [
        ("raw", ctypes.c_int32),
        ("ppos_lat", ctypes.c_int32),
        ("ppos_lon", ctypes.c_int32),
        ("spoi_lat", ctypes.c_int32),
        ("spoi_lon", ctypes.c_int32),
        ]

    def get(self):
        return self.raw * ICD1553_GEOPOS_RAD_LSB

    def set(self, value):
        self.raw = int(value / ICD1553_GEOPOS_RAD_LSB)