예제 #1
0
        ///------------------------------------------
        /// <summary>
        /// MainWindow
        /// Main program starts here
        /// </summary>
        //--------------------------------------------
        public MainWindow()
        {
            // Create the window
            InitializeComponent();
            mainWin = this;

            // Create and show start up dialog
            winStartUp = new StartUpWindow();
            winStartUp.ShowDialog();
            // winStartUp.Topmost = true;
            winStartUp.Activate();

            // Exit application if the user exited the startup window
            if (winStartUp == null)
            {
                Application.Current.Shutdown();
            }

            /*
             * else
             * {
             *  Debug.WriteLine("Latency = " + startUpVars.getLatency());
             *  Debug.WriteLine("Projection = " + startUpVars.getProjection());
             * }
             */
            // Process Starup window into meaningful URIs
            GetWmsUri();

            // Initialize the Main window model view
            startDate_DP.SelectedDate = _firstDate;
            // endDate_DP.SelectedDate = _today;    // add back in when animation is considered
            InitializeWMSLayer_VM();

            // Set map to current location
            BasemapView.LocationDisplay.IsEnabled        = true;
            BasemapView.LocationDisplay.ShowLocation     = false;
            BasemapView.LocationDisplay.AutoPanMode      = LocationDisplayAutoPanMode.Recenter;
            BasemapView.LocationDisplay.InitialZoomScale = 2000000;
            BasemapView.LocationDisplay.IsEnabled        = false;

            // Initialize AOI sketch - in AOI_draw.cs
            InitializeAOIsketch();

            // Create and hide AOI Window
            aoiWin = new AOIWindow();
            aoiWin.Hide();

            // Put the main window on top and set flags
            // mainWin.Topmost = true;
            mainWin.Activate();
            haveSketch = false;
            haveLayer  = false;
        }   // end MainWindow
예제 #2
0
        ///------------------------------------------
        /// <summary>
        /// MainWindow
        /// Main program starts here
        /// </summary>
        //--------------------------------------------
        public MainWindow()
        {
            // Create the window
            InitializeComponent();
            mainWin = this;

            /*
             * // Create and show start up dialog
             * winStartUp = new StartUpWindow();
             * winStartUp.ShowDialog();
             * winStartUp.Activate();
             *
             * // Exit application if the user exited the startup window
             * if (winStartUp == null)
             *  Application.Current.Shutdown();
             */
            // Set Wms Capability uri
            SetWmsUri();

            // Initialize the Main window model view
            startDate_DP.SelectedDate = _firstDate;
            InitializeWMSLayer_VM();

            // Set map to current location
            BasemapView.LocationDisplay.IsEnabled        = true;
            BasemapView.LocationDisplay.ShowLocation     = false;
            BasemapView.LocationDisplay.AutoPanMode      = LocationDisplayAutoPanMode.Recenter;
            BasemapView.LocationDisplay.InitialZoomScale = 2000000;
            BasemapView.LocationDisplay.IsEnabled        = false;

            // Activate main window and set flags
            mainWin.Activate();
            haveSketch = false;
            haveLayer  = false;

            // Initialize panels: AOI Win, Confirm, and Download - PANEL
            // Set panel visibility

            // Initialize AOI sketch editor - in AOI_draw.cs
            InitializeAOIsketch();

            // Create and hide AOI Window
            aoiWin = new AOIWindow();
            aoiWin.Hide();
        }   // end MainWindow
예제 #3
0
        }   // end SelectedDateChanged


        // Initialize WMTS data
        private async void InitializeWMTS()
        {
            String str;
            WmtsService wmtsService;
            Uri wmtsServiceURI;

            // Create the WMTS Service Load data from the URI
            WMTS_CAP_URL = "https://gibs.earthdata.nasa.gov/wmts/" + wmsUriStartup.EPSG
                            + "/" + wmsUriStartup.latency + "/1.0.0/WMTSCapabilities.xml";
            wmtsServiceURI = new Uri(WMTS_CAP_URL);

            // Define an instance of the service
            wmtsService = new WmtsService(wmtsServiceURI);

            // If service can load, initialize the app
            try
            {
                if (aoiWin == null)
                    aoiWin = new AOIWindow();

                // Load the WMS Service.
                await wmtsService.LoadAsync();

                // Get the service info (metadata) from the service.
                wmts.serviceInfo = wmtsService.ServiceInfo;

                // Get the WMTS tile information
                wmts.tileSets = new List<WMTS.TileSetVariables>();
                for (int i = 0; i < selectedLayers.Count; i++)
                {
                    wmts.tileSets.Add(new WMTS.TileSetVariables());
                    wmts.tileSets[i].tileSetTitle = wmts.serviceInfo.TileMatrixSets[i].Id;
                    wmts.tileSets[i].zoomLvls = wmts.serviceInfo.TileMatrixSets[i].TileMatrices.Count;
                    for (int j = 0; j < wmts.serviceInfo.TileMatrixSets[i].TileMatrices.Count; j++)
                    {
                        wmts.tileSets[i].resTypes.Add(new WMTS.ResType());
                        wmts.tileSets[i].resTypes[j].id =
                            wmts.serviceInfo.TileMatrixSets[i].TileMatrices[j].Id;
                        wmts.tileSets[i].resTypes[j].scaleDenom =
                            wmts.serviceInfo.TileMatrixSets[i].TileMatrices[j].ScaleDenominator;
                    }
                }

                // Obtain the read only list of WMTS layers info objects
                // for selected layers
                wmts.selectedLayers = new List<WmtsLayerInfo>();
                foreach (WmsLayerInfo wmsLayerInfo in selectedLayers)
                {
                    str = wmsLayerInfo.Title;
                    foreach (WmtsLayerInfo wmtsLayerInfo in wmts.serviceInfo.LayerInfos)
                    {
                        // Got a layer - save info about this layer
                        if (str == wmtsLayerInfo.Title)
                        {
                            wmts.selectedLayers.Add(wmtsLayerInfo);
                            break;
                        }
                    }
                }

                // Set up tile matrix information for selected tiles
                wmts.layerTileSets = new List<WMTS.TileSetVariables>();
                for (int i = 0; i < wmts.selectedLayers.Count; i++)
                {
                    wmts.layerTileSets.Add(new WMTS.TileSetVariables());
                    wmts.layerTileSets[i].zoomLvls = wmts.selectedLayers[i].TileMatrixSets[0].TileMatrices.Count;
                    wmts.layerTileSets[i].tileSetTitle =
                         wmts.selectedLayers[i].TileMatrixSets[0].Id;
                    wmts.layerTileSets[i].layerTitle = wmts.selectedLayers[i].Title;
                    wmts.layerTileSets[i].layerName = wmts.selectedLayers[i].Id;
                    wmts.layerTileSets[i].tileWidth = TILE_WIDTH;
                    wmts.layerTileSets[i].tileHeight = TILE_HEIGHT;

                    // get tile matrices info
                    for (int j = 0; j < wmts.selectedLayers[i].TileMatrixSets[0].TileMatrices.Count; j++)
                    {
                        wmts.layerTileSets[i].resTypes.Add(new WMTS.ResType());
                        wmts.layerTileSets[i].resTypes[j].id =
                            wmts.selectedLayers[i].TileMatrixSets[0].TileMatrices[j].Id;
                        wmts.layerTileSets[i].resTypes[j].scaleDenom =
                            wmts.selectedLayers[i].TileMatrixSets[0].TileMatrices[j].ScaleDenominator;
                        wmts.layerTileSets[i].resTypes[j].resolution =
                            wmts.layerTileSets[i].resTypes[j].scaleDenom / 397569610;
                        wmts.layerTileSets[i].resTypes[j].matrixWidth = 2 ^ j;
                        wmts.layerTileSets[i].resTypes[j].matrixHeight = 2 ^ j;
                    }
                }

                // Set AOI window Titles
                aoiWin.panelVars.titleList = new List<string>();
                foreach (WMTS.TileSetVariables tileSet in wmts.layerTileSets)
                {
                    str = tileSet.layerTitle + "\n" +
                          "Tile Set: " + tileSet.tileSetTitle + "\t"
                          + "Zoom Levels: " + tileSet.zoomLvls;
                    aoiWin.panelVars.titleList.Add(str);
                }

                aoiWin.ImageryTitle.ItemsSource = aoiWin.panelVars.titleList;
                aoiWin.ImageryTitle.SelectedIndex = 0;

                // Set the zoom level specific to image selected
                ResetZoomLevels(aoiWin.ImageryTitle.SelectedIndex, "Skipper");
            }   // end try

            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "WMTS SERVER LOAD ERROR");
            }
        }   // end InitializeWMTS
예제 #4
0
        }   // end DrawButtonClick


        private void SelectButtonClick(object sender, RoutedEventArgs e)
        {
            Geometry geometry;

            if (selectedLayers != null)
            {
                // get the selected layers information
                ResetWmtsInfo();

                //Process each of the selected layers
                if ((selectedLayers.Count > 0))
                {
                    haveLayer = true;

                    // Create window if it does not exist
                    if (aoiWin == null)
                        aoiWin = new AOIWindow();

                    // Complete Current Sketch if one is being executed
                    if (BasemapView.SketchEditor.CompleteCommand.CanExecute(null))
                    {
                        geometry = BasemapView.SketchEditor.Geometry;
                        BasemapView.SketchEditor.CompleteCommand.Execute(null);
                        Graphic graphic = CreateGraphic(geometry);
                        sketchOverlay.Graphics.Add(graphic);

                        // Set Buttons
                        AOIDraw.IsEnabled = true;
                        AOISelect.IsEnabled = false;
                        AOIClear.IsEnabled = true;
                        AOICancel.IsEnabled = true;

                        // Fetch wmts layer information for the selected layers
                        InitializeWMTS();

                        // Update Geo Coords in aoi window
                        AOIEnvelope = geometry.Extent;
                        aoiWin.MinLat.Text = AOIEnvelope.YMin.ToString("F4");
                        aoiWin.MaxLat.Text = AOIEnvelope.YMax.ToString("F4");
                        aoiWin.MinLon.Text = AOIEnvelope.XMin.ToString("F4");
                        aoiWin.MaxLon.Text = AOIEnvelope.XMax.ToString("F4");

                        // Update Date/Time in aoi window
                        DateTime date = startDate_DP.SelectedDate.Value;
                        String year = date.Year.ToString("D4");
                        String month = date.Month.ToString("D2");
                        String day = date.Day.ToString("D2");
                        aoiWin.AOI_Date.Text = year + "-" + month + "-" + day;

                        // Convert envelope to pixel values - currently degrees
                        string str = AOIEnvelope.Width.ToString("F4") + " x " + AOIEnvelope.Height.ToString("F4");
                        aoiWin.PixelSize.Text = str;

                        aoiWin.ZoomCombo.SelectedIndex = 0;
                        aoiWin.ImageryTitle.SelectedIndex = 0;
                        aoiWin.Top = mainWin.Top;
                        aoiWin.Left = mainWin.Left;

                        // Get the list of layers to display then show
                        aoiWin.getDisplayLayers();
                        if (aoiWin != null)
                        {
                            aoiWin.ShowDialog();
                            aoiWin.Activate();
                        }

                    }   // end if CompleteCommand.CanExecute

                    // If there is an existing sketch - use it
                    else if (haveSketch)
                    {
                        // Already have AOI
                        AOIDraw.IsEnabled = true;
                        AOISelect.IsEnabled = false;
                        AOIClear.IsEnabled = true;
                        AOICancel.IsEnabled = true;

                        aoiWin.ZoomCombo.SelectedIndex = 0;
                        aoiWin.ImageryTitle.SelectedIndex = 0;

                        // Start dialog
                        // aoiWin.Topmost = true;
                        aoiWin.Activate();
                        aoiWin.ShowDialog();
                    }   // end use existing sketch

                }   // end if there is more than one selected layer
            }   // end if selected layers != null
            else
                MessageBox.Show("Please select at least one layer", "LAYER SELECTION ERROR");

        }   // end SelectButtonClick