protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (e.State != AjaxControlToolkit.AjaxFileUploadState.Success) { return; } using (FlightData fd = new FlightData()) { if (fd.ParseFlightData(System.Text.Encoding.UTF8.GetString(e.GetContents()))) { if (fd.HasLatLongInfo) { Coordinates.AddRange(fd.GetTrajectory()); HasTime = HasTime && fd.HasDateTime; HasAlt = HasAlt && fd.HasAltitude; HasSpeed = HasSpeed && fd.HasSpeed; } } else { lblErr.Text = fd.ErrorString; } } e.DeleteTemporaryData(); }
protected void mfbMFUFlightImages_GeotagPhoto(object sender, PositionEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (e.TimeStamp == null || !e.TimeStamp.HasValue || e.ExpectedPosition != null) { return; } string szData = mfbFlightInfo1.Telemetry; if (szData == null) { return; } using (FlightData fd = new FlightData()) { if (fd.ParseFlightData(szData) && fd.HasDateTime && fd.HasLatLongInfo) { e.ExpectedPosition = Position.Interpolate(e.TimeStamp.Value, fd.GetTrajectory()); } } }
/// <summary> /// Returns a KML respresentation of all of the flights represented by the specified query /// </summary> /// <param name="fq">The flight query</param> /// <param name="s">The stream to which to write</param> /// <param name="error">Any error</param> /// <param name="lstIDs">The list of specific flight IDs to request</param> /// <returns>KML string for the matching flights.</returns> public static void AllFlightsAsKML(FlightQuery fq, Stream s, out string error, IEnumerable <int> lstIDs = null) { if (fq == null) { throw new ArgumentNullException(nameof(fq)); } if (String.IsNullOrEmpty(fq.UserName) && (lstIDs == null || !lstIDs.Any())) { throw new MyFlightbookException("Don't get all flights as KML for an empty user!!"); } if (lstIDs != null) { fq.EnumeratedFlights = lstIDs; } // Get the master airport list AirportList alMaster = AllFlightsAndNavaids(fq); using (KMLWriter kw = new KMLWriter(s)) { kw.BeginKML(); error = LookAtAllFlights( fq, LogbookEntryCore.LoadTelemetryOption.LoadAll, (le) => { if (le.Telemetry.HasPath) { using (FlightData fd = new FlightData()) { try { fd.ParseFlightData(le.Telemetry.RawData, le.Telemetry.MetaData); if (fd.HasLatLongInfo) { kw.AddPath(fd.GetTrajectory(), String.Format(CultureInfo.CurrentCulture, "{0:d} - {1}", le.Date, le.Comment), fd.SpeedFactor); return; } } catch (Exception ex) when(!(ex is OutOfMemoryException)) { } // eat any error and fall through below } } // No path was found above. AirportList al = alMaster.CloneSubset(le.Route); kw.AddRoute(al.GetNormalizedAirports(), String.Format(CultureInfo.CurrentCulture, "{0:d} - {1}", le.Date, le.Route)); }, lstIDs != null && lstIDs.Any()); kw.EndKML(); } }