Beispiel #1
0
        private void MainDlg_Load(object sender, EventArgs e)
        {
            // start minimized if enabled
            if (Properties.Settings.Default.Windows_Startup_Minimized)
            {
                WindowState = FormWindowState.Minimized;
            }
            else
            {
                WindowState = FormWindowState.Normal;
            }
            // reset FirstRun flag
            Properties.Settings.Default.Application_FirstRun = false;

            // set initial settings for CoverageMap
            // setting User Agent to fix Open Street Map issue 2016-09-20
            GMap.NET.MapProviders.GMapProvider.UserAgent = "AirScout";
            // clearing referrer URL issue 2019-12-14
            gm_Planes_Coverage.MapProvider.RefererUrl   = "";
            gm_Planes_Coverage.MapProvider              = GMapProviders.Find(Properties.Settings.Default.Planes_MapProvider);
            gm_Planes_Coverage.IgnoreMarkerOnMouseWheel = true;
            gm_Planes_Coverage.MinZoom             = 0;
            gm_Planes_Coverage.MaxZoom             = 20;
            gm_Planes_Coverage.Zoom                = 6;
            gm_Planes_Coverage.DragButton          = System.Windows.Forms.MouseButtons.Left;
            gm_Planes_Coverage.CanDragMap          = true;
            gm_Planes_Coverage.ScalePen            = new Pen(Color.Black, 3);
            gm_Planes_Coverage.HelperLinePen       = null;
            gm_Planes_Coverage.SelectionPen        = null;
            gm_Planes_Coverage.MapScaleInfoEnabled = true;
            gm_Planes_Coverage.Overlays.Add(gmo_Planes_Coverage);

            // keep startup time
            StartupTime = DateTime.UtcNow;

            // start database

            // enable/disable functions
            cb_WebFeed1_Active_CheckedChanged(this, null);
            cb_WebFeed2_Active_CheckedChanged(this, null);
            cb_WebFeed3_Active_CheckedChanged(this, null);
            cb_Log_Active_CheckedChanged(this, null);
            cb_Server_Active_CheckedChanged(this, null);

            // start timer
            ti_Main.Enabled = true;
            ti_Main.Start();

            // start background workers
            bw_JSONWriter.RunWorkerAsync();
            bw_DatabaseUpdater.RunWorkerAsync();
        }
Beispiel #2
0
        public TrafficDlg()
        {
            InitializeComponent();

            // set initial settings for Map
            gm_Options_Traffic.MapProvider = GMapProviders.Find(Properties.Settings.Default.Map_Provider);
            gm_Options_Traffic.IgnoreMarkerOnMouseWheel = true;
            gm_Options_Traffic.MinZoom             = 0;
            gm_Options_Traffic.MaxZoom             = 20;
            gm_Options_Traffic.Zoom                = 6;
            gm_Options_Traffic.DragButton          = System.Windows.Forms.MouseButtons.Left;
            gm_Options_Traffic.CanDragMap          = true;
            gm_Options_Traffic.ScalePen            = new Pen(Color.Black, 3);
            gm_Options_Traffic.HelperLinePen       = null;
            gm_Options_Traffic.SelectionPen        = null;
            gm_Options_Traffic.MapScaleInfoEnabled = true;
            gm_Options_Traffic.Overlays.Add(Coveragepolygons);
            gm_Options_Traffic.Overlays.Add(routes);

            // add tile to map polygons
            List <PointLatLng> l = new List <PointLatLng>();

            l.Add(new PointLatLng(Properties.Settings.Default.MinLat, Properties.Settings.Default.MinLon));
            l.Add(new PointLatLng(Properties.Settings.Default.MinLat, Properties.Settings.Default.MaxLon));
            l.Add(new PointLatLng(Properties.Settings.Default.MaxLat, Properties.Settings.Default.MaxLon));
            l.Add(new PointLatLng(Properties.Settings.Default.MaxLat, Properties.Settings.Default.MinLon));
            GMapPolygon p = new GMapPolygon(l, "Coverage");

            p.Stroke = new Pen(Color.FromArgb(255, Color.Magenta), 3);
            p.Fill   = new SolidBrush(Color.FromArgb(0, Color.Magenta));
            Coveragepolygons.Polygons.Add(p);
            // zoom the map
            gm_Options_Traffic.SetZoomToFitRect(RectLatLng.FromLTRB(Properties.Settings.Default.MinLon - 1, Properties.Settings.Default.MaxLat + 1, Properties.Settings.Default.MaxLon + 1, Properties.Settings.Default.MinLat - 1));

            try
            {
                dtp_Options_Traffic_Start.Value = AircraftPositionData.Database.AircraftPositionOldestEntry();
                dtp_Options_Traffic_Stop.Value  = AircraftPositionData.Database.AircraftPositionYoungestEntry();
            }
            catch
            {
                dtp_Options_Traffic_Start.Value = DateTime.UtcNow;
                dtp_Options_Traffic_Stop.Value  = DateTime.UtcNow;
            }
        }
Beispiel #3
0
        public HorizonDlg(string call, double lat, double lon, LocalObstructionDesignator localobstruction)
        {
            InitializeComponent();
            Location         = StationData.Database.LocationFindOrCreate(call, MaidenheadLocator.LocFromLatLon(lat, lon, false, 3));
            QRV              = StationData.Database.QRVFindOrCreateDefault(call, MaidenheadLocator.LocFromLatLon(lat, lon, false, 3), Properties.Settings.Default.Band);
            LocalObstruction = localobstruction;
            Elevation        = ElevationData.Database[Location.Lat, Location.Lon, Properties.Settings.Default.ElevationModel];
            AntennaHeight    = (QRV.AntennaHeight != 0) ? QRV.AntennaHeight : StationData.Database.QRVGetDefaultAntennaHeight(Properties.Settings.Default.Band);
            NumberFormatInfo provider = new NumberFormatInfo();

            provider.NumberDecimalSeparator = ".";
            provider.NumberGroupSeparator   = ",";
            tb_Horizon_Lat.Text             = Location.Lat.ToString("F8", provider);
            tb_Horizon_Lon.Text             = Location.Lon.ToString("F8", provider);
            tb_Horizon_Elevation.Text       = ElevationData.Database[Location.Lat, Location.Lon, Properties.Settings.Default.ElevationModel].ToString("F0", provider);
            tb_Horizon_Height.Text          = AntennaHeight.ToString("F0", provider);
            tb_Horizon_K_Factor.Text        = Properties.Settings.Default.Path_Band_Settings[Properties.Settings.Default.Band].K_Factor.ToString("F2", provider);
            tb_Horizon_QRG.Text             = Bands.GetStringValue(Properties.Settings.Default.Band);
            tb_Horizon_F1_Clearance.Text    = Properties.Settings.Default.Path_Band_Settings[Properties.Settings.Default.Band].F1_Clearance.ToString("F2", provider);
            tb_Horizon_ElevationModel.Text  = Properties.Settings.Default.ElevationModel.ToString();
            // setting User Agent to fix Open Street Map issue 2016-09-20
            GMap.NET.MapProviders.GMapProvider.UserAgent = "AirScout";
            // clearing referrer URL issue 2019-12-14
            gm_Horizon.MapProvider.RefererUrl = "";
            // set initial settings for main map
            gm_Horizon.MapProvider = GMapProviders.Find(Properties.Settings.Default.Map_Provider);
            gm_Horizon.IgnoreMarkerOnMouseWheel = true;
            gm_Horizon.MinZoom             = 0;
            gm_Horizon.MaxZoom             = 20;
            gm_Horizon.Zoom                = 8;
            gm_Horizon.DragButton          = System.Windows.Forms.MouseButtons.Left;
            gm_Horizon.CanDragMap          = true;
            gm_Horizon.ScalePen            = new Pen(Color.Black, 3);
            gm_Horizon.MapScaleInfoEnabled = true;
            gm_Horizon.Overlays.Add(horizons);
            GMarkerGoogle gm = new GMarkerGoogle(new PointLatLng(Location.Lat, Location.Lon), GMarkerGoogleType.red_dot);

            gm.ToolTipText = Location.Call;
            horizons.Markers.Add(gm);
            horizon.Stroke = new Pen(Color.Red, 3);
            horizons.Routes.Add(horizon);
            this.Text = "Radio Horizon of " + Location.Call;
            // initialize charts
            InitializeCharts();
            // activate Polar if nothing checked
            if (!Properties.Settings.Default.Horizon_Plot_Polar && !Properties.Settings.Default.Horizon_Plot_Cartesian && !Properties.Settings.Default.Horizon_Plot_Map)
            {
                Properties.Settings.Default.Horizon_Plot_Polar = true;
            }
            // show according child windows
            UpdateCharts();
            // create ToolTip on this window
            TT       = new ToolTip();
            OwnerWin = gm_Horizon;
            HorizonDlg_SizeChanged(this, null);
            // set map bounds
            Map_Left   = Location.Lon;
            Map_Right  = Location.Lon;
            Map_Top    = Location.Lat;
            Map_Bottom = Location.Lat;
        }
Beispiel #4
0
            protected override void OnDoWork(DoWorkEventArgs e)
            {
                BACKGROUNDUPDATERSTARTOPTIONS Options = (BACKGROUNDUPDATERSTARTOPTIONS)e.Argument;

                // name the thread for debugging
                if (String.IsNullOrEmpty(Thread.CurrentThread.Name))
                {
                    Thread.CurrentThread.Name = this.Name + "_" + this.GetType().Name;
                }
                this.ReportProgress(0, this.Name + " started.");
                Log.WriteMessage(this.Name + " started.");
                // get update interval
                int interval = (int)Properties.Settings.Default.Background_Update_Period * 60;

                // get mpst simple elevation model
                if (Properties.Settings.Default.Elevation_GLOBE_Enabled)
                {
                    Model = ELEVATIONMODEL.GLOBE;
                }
                else if (Properties.Settings.Default.Elevation_SRTM3_Enabled)
                {
                    Model = ELEVATIONMODEL.SRTM3;
                }
                else if (Properties.Settings.Default.Elevation_SRTM1_Enabled)
                {
                    Model = ELEVATIONMODEL.SRTM1;
                }
                // return if no elevation model selected
                if (Model == ELEVATIONMODEL.NONE)
                {
                    return;
                }
                // setting User Agent to fix Open Street Map issue 2016-09-20
                GMap.NET.MapProviders.GMapProvider.UserAgent = "AirScout";
                // clearing referrer URL issue 2019-12-14
                gm_Map.MapProvider.RefererUrl = "";
                // set initial settings for main map
                gm_Map.MapProvider = GMapProviders.Find(Properties.Settings.Default.Map_Provider);
                gm_Map.MinZoom     = 0;
                gm_Map.MaxZoom     = 20;
                // get database filename
                int i     = 0;
                int count = 0;
                int total = 0;

                do
                {
                    i     = 0;
                    count = 0;
                    total = 0;
                    // checks if elevation database is complete
                    try
                    {
                        this.ReportProgress(0, this.Name + " getting tiles from database.");
                        int zmin = 5;
                        int zmax = 11;
                        List <MapPreloaderTile> l = new List <MapPreloaderTile>();
                        for (int z = zmin; z <= zmax; z++)
                        {
                            int xmin = long2tilex(Properties.Settings.Default.MinLon, z);
                            int xmax = long2tilex(Properties.Settings.Default.MaxLon, z);
                            int ymin = lat2tiley(Properties.Settings.Default.MaxLat, z);
                            int ymax = lat2tiley(Properties.Settings.Default.MinLat, z);
                            for (int x = xmin; x <= xmax; x++)
                            {
                                for (int y = ymin; y <= ymax; y++)
                                {
                                    // check if tile already in database --> add it to list to get it from the web
                                    if (!MapData.Database.TileExists(x, y, z, gm_Map.MapProvider.DbId))
                                    {
                                        MapPreloaderTile t = new MapPreloaderTile(x, y, z, gm_Map.MapProvider.DbId);
                                        l.Add(t);
                                    }
                                    total++;
                                    if (this.CancellationPending)
                                    {
                                        break;
                                    }
                                }
                                if (this.CancellationPending)
                                {
                                    break;
                                }
                            }
                            if (this.CancellationPending)
                            {
                                break;
                            }
                        }
                        if (this.CancellationPending)
                        {
                            break;
                        }
                        count = l.Count();
                        Random rng = new Random();
                        // shuffle the list
                        int n = l.Count;
                        while (n > 1)
                        {
                            n--;
                            int k = rng.Next(n + 1);
                            MapPreloaderTile value = l[k];
                            l[k] = l[n];
                            l[n] = value;
                        }
                        n = 0;
                        foreach (MapPreloaderTile t in l)
                        {
                            Exception ex = null;
                            this.ReportProgress(0, "Preloading " + "/" + t.Z.ToString() + "/" + t.X.ToString() + "/" + t.Y.ToString() + ".png");
                            try
                            {
                                // try to donwload from www.airscout.eu first
                                if (gm_Map.MapProvider.GetType() == typeof(OpenStreetMapProvider))
                                {
                                    LoadOSM(t.X, t.Y, t.Z);
                                }
                                else
                                {
                                    PureImage img = gm_Map.Manager.GetImageFrom(gm_Map.MapProvider, new GPoint(t.X, t.Y), t.Z, out ex);
                                    // wait until cache is written to database
                                }
                                if (ex == null)
                                {
                                    Console.WriteLine("Preload tile [" + i.ToString() + " of " + count.ToString() + "] x=" + t.X + ", y=" + t.Y + ", z=" + t.Z + ": OK");
                                }
                                else
                                {
                                    Console.WriteLine("Preload tile [" + i.ToString() + " of " + count.ToString() + "] x=" + t.X + ", y=" + t.Y + ", z=" + t.Z + ": " + ex.ToString());
                                }
                            }
                            catch (Exception e1)
                            {
                                Console.WriteLine(this.Name + ": " + e1.ToString());
                            }
                            Thread.Sleep(100);
                            i++;
                            n++;
                            if (n > 100)
                            {
                                while (GMaps.Instance.tileCacheQueue.Count > 0)
                                {
                                    Application.DoEvents();
                                    if (this.CancellationPending)
                                    {
                                        break;
                                    }
                                }
                                n = 0;
                            }
                            if (this.CancellationPending)
                            {
                                break;
                            }
                        }
                        if (this.CancellationPending)
                        {
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        this.ReportProgress(-1, ex.ToString());
                    }

                    // sleep when running periodically
                    if (Options == BACKGROUNDUPDATERSTARTOPTIONS.RUNPERIODICALLY)
                    {
                        int l = 0;
                        while (!this.CancellationPending && (l < interval))
                        {
                            Thread.Sleep(1000);
                            l++;
                        }
                    }
                    if (this.CancellationPending)
                    {
                        break;
                    }
                }while (Options == BACKGROUNDUPDATERSTARTOPTIONS.RUNPERIODICALLY);
                if (this.CancellationPending)
                {
                    this.ReportProgress(0, Name + " cancelled.");
                    Log.WriteMessage(Name + " cancelled.");
                }
                else
                {
                    this.ReportProgress(0, Name + " finished, total  " + total.ToString() + " tile(s), " + (count - i).ToString() + " left.");
                    Log.WriteMessage(Name + " finished, total  " + total.ToString() + " tile(s), " + (count - i).ToString() + " left.");
                }
            }