private void AirDataCompleted(object sender, DownloadDataCompletedEventArgs e) { var data = e.Result; var asString = Encoding.UTF8.GetString(data); var res = JObject.Parse(asString); var dataArray = (JArray)res["acList"]; foreach (var d in dataArray) { var airCraft = new Aircraft { Id = d["Id"] == null ? -1 : (int)d["Id"], Identifier = d["Icao"] == null ? "Unknown" : (string)d["Icao"], Altitude = d["Alt"] == null ? -1 : (int)d["Alt"], Lat = d["Lat"] == null ? -1 : (float)d["Lat"], Lon = d["Long"] == null ? -1f : (float)d["Long"], Time = d["PosTime"] == null ? -1 : (long)d["PosTime"], Speed = d["Spd"] == null ? -1f : (float)d["Spd"], Type = d["Type"] == null ? "Unknown" : (string)d["Type"], Model = d["Mdl"] == null ? "Unknown" : (string)d["Mdl"], Manufacturer = d["Man"] == null ? "Unknown" : (string)d["Man"], Year = d["Year"] == null ? "Unknown" : (string)d["Year"], Operator = d["Op"] == null ? "Unknown" : (string)d["Op"], VerticalSpeed = d["Vsi"] == null ? -1 : (int)d["Vsi"], Turbulence = d["WTC"] == null ? "Unknown" : ParseTurbulence((int)d["WTC"]), Species = d["Species"] == null ? "Unknown" : ParseSpecies((int)d["Species"]), Military = d["Mil"] == null ? false : (bool)d["Mil"], Country = d["Cou"] == null ? "Unknown" : (string)d["Cou"], Call = d["Call"] == null ? "Unknown" : (string)d["Call"], From = d["From"] == null ? "Stockholm-Arlanda, Stockholm, Sweden" : (string)d["From"], To = d["To"] == null ? "Billund, Denmark" : (string)d["To"], }; if (airCraft != null) { // todo: on update (not redraw) check if aircraft is already in the list if (!AircraftList.Any(a => a.Id == airCraft.Id)) { AircraftList.Add(airCraft); } MapController.AddAircraftToMap(airCraft); QueryGeoLocation(airCraft); } } }