private void ShowMap(LogbookEntry le) { double distance = 0.0; bool fHasPath = le.Telemetry != null && le.Telemetry.HasPath; ListsFromRoutesResults result = null; if (le.Route.Length > 0 || fHasPath) // show a map. { result = AirportList.ListsFromRoutes(le.Route); MfbGoogleMap1.Map.Airports = result.Result; MfbGoogleMap1.Map.ShowRoute = ckShowRoute.Checked; MfbGoogleMap1.Map.AutofillOnPanZoom = (result.Result.Count() == 0); MfbGoogleMap1.Map.AllowDupeMarkers = false; lnkZoomOut.NavigateUrl = MfbGoogleMap1.ZoomToFitScript; lnkZoomOut.Visible = !result.MasterList.LatLongBox().IsEmpty; // display flight path, if available. if (ckShowPath.Checked && le.Telemetry.HasPath) { MfbGoogleMap1.Map.Path = le.Telemetry.Path(); distance = le.Telemetry.Distance(); lnkViewKML.Visible = true; } string szURL = Request.Url.PathAndQuery; lnkShowMapOnly.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", szURL, szURL.Contains("?") ? "&" : "?", "show=map"); } MfbGoogleMap1.Map.Images = ckShowImages.Checked ? mfbIlFlight.Images.ImageArray.ToArray() : new MFBImageInfo[0]; bool fForceDynamicMap = util.GetIntParam(Request, "dm", 0) != 0; bool fHasGeotaggedImages = false; if (le.FlightImages != null) { Array.ForEach <MFBImageInfo>(le.FlightImages, (mfbii) => { fHasGeotaggedImages = fHasGeotaggedImages || mfbii.Location != null; }); } // By default, show only a static map (cut down on dynamic map hits) if (fForceDynamicMap || fHasGeotaggedImages || fHasPath) { MfbGoogleMap1.Mode = MyFlightbook.Mapping.GMap_Mode.Dynamic; } else { MfbGoogleMap1.Mode = MyFlightbook.Mapping.GMap_Mode.Static; popmenu.Visible = false; lnkZoomOut.Visible = mfbAirportServices1.Visible = false; } if (result != null) { mfbAirportServices1.GoogleMapID = MfbGoogleMap1.MapID; mfbAirportServices1.AddZoomLink = (MfbGoogleMap1.Mode == MyFlightbook.Mapping.GMap_Mode.Dynamic); mfbAirportServices1.SetAirports(result.MasterList.GetNormalizedAirports()); } lblDistance.Text = le.GetPathDistanceDescription(distance); pnlDistance.Visible = lblDistance.Text.Length > 0; }
private void ShowMap(LogbookEntry le) { double distance = 0.0; bool fHasPath = le.Telemetry != null && le.Telemetry.HasPath; ListsFromRoutesResults result = null; if (le.Route.Length > 0 || fHasPath) // show a map. { result = AirportList.ListsFromRoutes(le.Route); MfbGoogleMap1.Map.Airports = result.Result; MfbGoogleMap1.Map.Options.fShowRoute = ckShowRoute.Checked; MfbGoogleMap1.Map.Options.fAutofillPanZoom = (result.Result.Count == 0); MfbGoogleMap1.Map.AllowDupeMarkers = false; lnkZoomOut.NavigateUrl = MfbGoogleMap1.ZoomToFitScript; lnkZoomOut.Visible = !result.MasterList.LatLongBox().IsEmpty; // display flight path, if available. if (ckShowPath.Checked && le.Telemetry.HasPath) { MfbGoogleMap1.Map.Path = le.Telemetry.Path(); distance = le.Telemetry.Distance(); rowKML.Visible = true; } } MfbGoogleMap1.Map.Images = ckShowImages.Checked ? mfbIlFlight.Images.ImageArray.ToArray() : Array.Empty <MFBImageInfo>(); bool fForceDynamicMap = util.GetIntParam(Request, "dm", 0) != 0; bool fHasGeotaggedImages = false; if (le.FlightImages != null) { foreach (MFBImageInfo mfbii in le.FlightImages) { fHasGeotaggedImages = fHasGeotaggedImages || mfbii.Location != null; } } // By default, show only a static map (cut down on dynamic map hits) if (fForceDynamicMap || fHasGeotaggedImages || fHasPath) { MfbGoogleMap1.Mode = MyFlightbook.Mapping.GMap_Mode.Dynamic; } else { MfbGoogleMap1.Mode = MyFlightbook.Mapping.GMap_Mode.Static; popmenu.Visible = false; lnkZoomOut.Visible = mfbAirportServices1.Visible = false; } if (result != null) { mfbAirportServices1.GoogleMapID = MfbGoogleMap1.MapID; mfbAirportServices1.AddZoomLink = (MfbGoogleMap1.Mode == MyFlightbook.Mapping.GMap_Mode.Dynamic); mfbAirportServices1.SetAirports(result.MasterList.GetNormalizedAirports()); } lblDistance.Text = le.GetPathDistanceDescription(distance); pnlDistance.Visible = lblDistance.Text.Length > 0; }
protected void MapAirports(string szAirports) { ListsFromRoutesResults result = AirportList.ListsFromRoutes(szAirports); SetAirportsInMap(result.Result); // and add the table to the page underneath the map mfbAirportServices1.SetAirports(result.MasterList.GetNormalizedAirports()); lnkZoomOut.Visible = !result.MasterList.LatLongBox().IsEmpty; pnlMetars.Visible = result != null && result.Result != null && result.Result.Count > 0; }
protected void btnOptimizeRoute_Click(object sender, EventArgs e) { List <airport> lst = new List <airport>(AirportList.ListsFromRoutes(txtAirports.Text).Result[0].UniqueAirports); if (lst.Count == 0) { return; } IEnumerable <IFix> path = TravelingSalesman.ShortestPath(lst); txtAirports.Text = HttpUtility.HtmlEncode(String.Join(" ", path.Select(ap => ap.Code))); btnMapEm_Click(sender, e); }
protected ListsFromRoutesResults RoutesList(string szRoute) { if (szRoute == null) { throw new ArgumentNullException(nameof(szRoute)); } ListsFromRoutesResults lfrr = (ListsFromRoutesResults)ViewState[szkeyVSAirportListResult]; if (lfrr == null) { ViewState[szkeyVSAirportListResult] = lfrr = AirportList.ListsFromRoutes(szRoute); } return(lfrr); }
/// <summary> /// Return stats for flights over the preceding N days. This will be cached for 30 minutes /// </summary> /// <returns>A FlightStats object</returns> public static FlightStats GetFlightStats() { FlightStats fs = CachedStats(); if (fs == null) { fs = new FlightStats(); // we don't use the regular base query so that this can be super fast. As a result, not all of the properties of the Logbook entry will be filled in. const string szQuery = @" SELECT f.*, 0 AS FlightDataLength, IF (ac.tailnumber LIKE '#%', CONCAT('(', m.model, ')'), ac.tailnumber) AS TailNumberDisplay, '' AS FlightVids, 0 AS HasDigitizedSignature, 0 AS distance, '' AS flightpath, 0 AS telemetrytype FROM flights f INNER JOIN Aircraft ac ON f.idaircraft=ac.idaircraft INNER JOIN models m ON ac.idmodel=m.idmodel WHERE f.Date > ?dateMin AND f.Date < ?dateMax AND f.fPublic <> 0 ORDER BY f.date DESC, f.idflight DESC LIMIT 200"; DBHelper dbh = new DBHelper(szQuery); List <string> lstRoutes = new List <string>(); dbh.ReadRows( (comm) => { comm.Parameters.AddWithValue("dateMin", DateTime.Now.AddDays(-30)); comm.Parameters.AddWithValue("dateMax", DateTime.Now.AddDays(1)); }, (dr) => { LogbookEntry le = new LogbookEntry(dr, (string)dr["username"]); fs.m_lstFlights.Add(le); lstRoutes.Add(le.Route); }); dbh.CommandText = "SELECT f.Route FROM flights f WHERE f.Date > ?dateMin AND f.Date < ?dateMax ORDER BY f.Date DESC LIMIT 350"; dbh.CommandArgs.Parameters.Clear(); dbh.ReadRows((comm) => { comm.Parameters.AddWithValue("dateMin", DateTime.Now.AddDays(-MaxDays)); comm.Parameters.AddWithValue("dateMax", DateTime.Now.AddDays(1)); }, (dr) => { lstRoutes.Add((string)dr["Route"]); }); fs.m_lstRoutes = AirportList.ListsFromRoutes(lstRoutes).Result; dbh.CommandText = "SELECT count(distinct(f.username)) AS numUsers, count(f.idflight) AS numFlights FROM flights f WHERE f.Date > ?dateMin AND f.Date < ?dateMax"; dbh.CommandArgs.Parameters.Clear(); dbh.ReadRow((comm) => { comm.Parameters.AddWithValue("dateMin", DateTime.Now.AddDays(-MaxDays)); comm.Parameters.AddWithValue("dateMax", DateTime.Now.AddDays(1)); }, (dr) => { fs.NumDays = MaxDays; fs.NumFlights = Convert.ToInt32(dr["numFlights"]); fs.NumUsers = Convert.ToInt32(dr["numUsers"]); }); if (HttpRuntime.Cache != null) { HttpRuntime.Cache.Add(CacheKey(), fs, null, DateTime.Now.AddMinutes(30), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } return(fs); }