Beispiel #1
0
    def parse_flightdata_json(json_data, time):
        aircraft_list = []
        for a in json_data["aircraft"]:

            alt = a["altitude"] if "altitude" in a else 0
            if alt == "ground":
                alt = 0
            dist = -1
            az = 0
            el = 0
            if "lat" in a and "lon" in a:
                dist = geomath.distance(myLoc, (a["lat"], a["lon"]))
                az = geomath.bearing(myLoc, (a["lat"], a["lon"]))
                el = math.degrees(math.atan(alt / (dist * 5280)))
            speed = 0
            if "speed" in a:
                speed = geomath.knot2mph(a["speed"])

            aircraftdata = AirCraftData(
                a["hex"] if "hex" in a else None,
                a["squawk"] if "squawk" in a else None,
                a["flight"] if "flight" in a else "N/A",
                a["lat"] if "lat" in a else None,
                a["lon"] if "lon" in a else None, alt,
                a["vert_rate"] if "vert_rate" in a else 0,
                a["track"] if "track" in a else None, speed,
                a["messages"] if "messages" in a else None,
                a["seen"] if "seen" in a else None,
                a["mlat"] if "mlat" in a else None,
                a["nucp"] if "nucp" in a else None,
                a["seen_pos"] if "seen_pos" in a else None,
                a["rssi"] if "rssi" in a else None, dist, az, el, time)

            aircraft_list.append(aircraftdata)
        return aircraft_list
Beispiel #2
0
 def _parse_aircraft_data(self, a, time):
     alt = a.get('Alt', 0)
     dist = -1
     az = 0
     el = 0
     if 'Lat' in a and 'Long' in a:
         rec_pos = (receiver_latitude, receiver_longitude)
         ac_pos = (a['Lat'], a['Long'])
         dist = geomath.distance(rec_pos, ac_pos)
         az = geomath.bearing(rec_pos, ac_pos)
         el = math.degrees(math.atan(alt / (dist * 5280)))
     speed = 0
     if 'Spd' in a:
         speed = geomath.knot2mph(a['Spd'])
     if 'PosTime' in a:
         last_seen_time = datetime.fromtimestamp(a['PosTime'] / 1000.0)
         seen = (time - last_seen_time).total_seconds()
     else:
         seen = 0
     ac_data = AirCraftData(
         a.get('Icao', None).upper(),
         a.get('Sqk', None),
         a.get('Call', None),
         a.get('Reg', None),
         a.get('Lat', None),
         a.get('Long', None),
         alt,
         a.get('Vsi', 0),
         a.get('Trak', None),
         speed,
         a.get('CMsgs', None),
         seen,
         a.get('Mlat', False),
         None,  # NUCP
         None,  # Seen pos
         10.0 * math.log10(a.get('Sig', 0) / 255.0 + 1e-5),
         dist,
         az,
         el,
         time)
     return ac_data
Beispiel #3
0
    def aircraft_data(self, json_data, time):
        aircraft_list = []
        for a in json_data["aircraft"]:

            alt = a["altitude"] if "altitude" in a else 0
            alt = a["alt_baro"] if "alt_baro" in a else 0
            if alt == "ground":
                alt = 0
            dist = -1
            az = 0
            el = 0
            if "lat" in a and "lon" in a:
                dist = geomath.distance(
                    (receiver_latitude, receiver_longitude),
                    (a["lat"], a["lon"]))
                az = geomath.bearing((receiver_latitude, receiver_longitude),
                                     (a["lat"], a["lon"]))
                el = math.degrees(math.atan(alt / (dist * 5280)))
            speed = 0
            if "speed" in a:
                speed = geomath.knot2mph(a["speed"])
            if "mach" in a:
                speed = geomath.mach2mph(a["mach"])

            aircraftdata = AirCraftData(
                a["hex"].upper() if "hex" in a else None,
                a["squawk"] if "squawk" in a else None,
                a["flight"] if "flight" in a else None, None,
                a["lat"] if "lat" in a else None,
                a["lon"] if "lon" in a else None, alt,
                a["vert_rate"] if "vert_rate" in a else 0,
                a["track"] if "track" in a else None, speed,
                a["messages"] if "messages" in a else None,
                a["seen"] if "seen" in a else None,
                a["mlat"] if "mlat" in a else None,
                a["nucp"] if "nucp" in a else None,
                a["seen_pos"] if "seen_pos" in a else None,
                a["rssi"] if "rssi" in a else None, dist, az, el, time)

            aircraft_list.append(aircraftdata)
        return aircraft_list