code: def position_with_ref(msg, lat_ref, lon_ref):
      
  
      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")
docs: 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