messageboard-2020-07-01-1736.py
01234567890123456789012345678901234567890123456789012345678901234567890123456789









149114921493149414951496149714981499150015011502150315041505150615071508150915101511 1512151315141515151615171518151915201521152215231524152515261527152815291530153115321533











                            <----SKIPPED LINES---->




  json_desc_dict = {}
  json_desc_dict['now'] = parsed['now']

  aircraft = [a for a in parsed['aircraft'] if a['seen'] < PERSISTENCE_SECONDS]
  json_desc_dict['radio_range_flights'] = len(aircraft)

  aircraft_with_pos = [a for a in aircraft if 'lat' in a and 'lon' in a]
  current_distances = [HaversineDistanceMeters(
      HOME, (a['lat'], a['lon'])) for a in aircraft_with_pos]
  current_distances = [
      d * FEET_IN_METER / FEET_IN_MILE
      for d in current_distances if d is not None]
  if current_distances:
    json_desc_dict['radio_range_miles'] = max(current_distances)

  return json_desc_dict


def SameFlight(f1, f2):
  """True if these two flights are likely the same flight, False otherwise."""
  if f1['flight_number'] == f2['flight_number']:

    return True
  if f1['squawk'] == f2['squawk']:
    return True
  return False


def MergedIdentifier(proposed_id, existing_ids):
  """Identifies what identifier to use for a flight.

  While most flights have both a squawk and a flight number, enough are missing
  one only for it to appear later to want to use a 2-tuple of both as an
  identifier, merging flights if they share a common non-null flight number and/
  or squawk, as the persistent identifier across time.

  Additionally, in very limited circumstances, a squawk may change mid-flight;
  in that case, the first alpha squawk is used.

  This function identifies which identifier to use, and which - if any - should
  be merged into that one identifier from a group of existing identifiers.

  Args:
    proposed_id: The 2-tuple of (flight_number, squawk) of the identified




                            <----SKIPPED LINES---->





01234567890123456789012345678901234567890123456789012345678901234567890123456789









14911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534











                            <----SKIPPED LINES---->




  json_desc_dict = {}
  json_desc_dict['now'] = parsed['now']

  aircraft = [a for a in parsed['aircraft'] if a['seen'] < PERSISTENCE_SECONDS]
  json_desc_dict['radio_range_flights'] = len(aircraft)

  aircraft_with_pos = [a for a in aircraft if 'lat' in a and 'lon' in a]
  current_distances = [HaversineDistanceMeters(
      HOME, (a['lat'], a['lon'])) for a in aircraft_with_pos]
  current_distances = [
      d * FEET_IN_METER / FEET_IN_MILE
      for d in current_distances if d is not None]
  if current_distances:
    json_desc_dict['radio_range_miles'] = max(current_distances)

  return json_desc_dict


def SameFlight(f1, f2):
  """True if these two flights are likely the same flight, False otherwise."""
  f1_flight_number = f1.get('flight_number')
  if f1_flight_number and f1_flight_number == f2.get('flight_number'):
    return True
  if f1.get('squawk') and f1.get('squawk') == f2.get('squawk'):
    return True
  return False


def MergedIdentifier(proposed_id, existing_ids):
  """Identifies what identifier to use for a flight.

  While most flights have both a squawk and a flight number, enough are missing
  one only for it to appear later to want to use a 2-tuple of both as an
  identifier, merging flights if they share a common non-null flight number and/
  or squawk, as the persistent identifier across time.

  Additionally, in very limited circumstances, a squawk may change mid-flight;
  in that case, the first alpha squawk is used.

  This function identifies which identifier to use, and which - if any - should
  be merged into that one identifier from a group of existing identifiers.

  Args:
    proposed_id: The 2-tuple of (flight_number, squawk) of the identified




                            <----SKIPPED LINES---->