Exemple #1
0
def position_with_ref(msg, lat_ref, lon_ref):
    """Decode position with only one message.

    A reference position is required, which can be previously
    calculated location, ground station, or airport location.
    The function works with both airborne and surface position messages.
    The reference position shall be with in 180NM (airborne) or 45NM (surface)
    of the true position.

    Args:
        msg (str): even message (28 hexdigits)
        lat_ref: previous known latitude
        lon_ref: previous known longitude

    Returns:
        (float, float): (latitude, longitude) of the aircraft
    """

    tc = typecode(msg)

    if 5 <= tc <= 8:
        return surface_position_with_ref(msg, lat_ref, lon_ref)

    elif 9 <= tc <= 18 or 20 <= tc <= 22:
        return airborne_position_with_ref(msg, lat_ref, lon_ref)

    else:
        raise RuntimeError("incorrect or inconsistent message types")
Exemple #2
0
def position_with_ref(msg, lat_ref, lon_ref):
    """Decode position with only one message,
    knowing reference nearby location, such as previously
    calculated location, ground station, or airport location, etc.
    Works with both airborne and surface position messages.
    The reference position shall be with in 180NM (airborne) or 45NM (surface)
    of the true position.

    Args:
        msg (string): even message (28 bytes hexadecimal string)
        lat_ref: previous known latitude
        lon_ref: previous known longitude

    Returns:
        (float, float): (latitude, longitude) of the aircraft
    """

    tc = typecode(msg)

    if 5 <= tc <= 8:
        return surface_position_with_ref(msg, lat_ref, lon_ref)

    elif 9 <= tc <= 18 or 20 <= tc <= 22:
        return airborne_position_with_ref(msg, lat_ref, lon_ref)

    else:
        raise RuntimeError("incorrect or inconsistant message types")