Beispiel #1
0
        public LayerWms(string serviceName, string url)
        {
            WmsProjectInfo info = new WmsProjectInfo();
            info.LatLonBoundingBox = new Extent(-180, -90, 180, 90);
            info.Name = serviceName;
            info.GetMapInfo.Formats.Add("image/png");
            Initialize(info);

            wmsService = new WmsService(url);
            InitializeEvents();
            setupDone = true;
        }
Beispiel #2
0
        private async void Initialize()
        {
            // Show dark gray canvas basemap.
            _myMapView.Map = new Map(Basemap.CreateDarkGrayCanvasVector());

            // Create the WMS Service.
            WmsService service = new WmsService(_wmsUrl);

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

            // Get the service info (metadata) from the service.
            WmsServiceInfo info = service.ServiceInfo;

            // Get the list of layer infos.
            IReadOnlyList <WmsLayerInfo> topLevelLayers = info.LayerInfos;

            // Recursively build up a list of all the layers in the service and get their IDs as a flat list.
            List <WmsLayerInfo> expandedList = new List <WmsLayerInfo>();

            BuildLayerInfoList(topLevelLayers, expandedList);

            List <LayerDisplayVm> displayList = new List <LayerDisplayVm>();

            // Build the ViewModel from the expanded list of layer infos.
            foreach (WmsLayerInfo layerInfo in expandedList)
            {
                // LayerDisplayVM is a custom type made for this sample to serve as the ViewModel; it is not a part of the ArcGIS Runtime.
                displayList.Add(new LayerDisplayVm(layerInfo));
            }

            // Construct the layer list source.
            _layerListSource = new LayerListSource(displayList, this);

            // Set the source for the table view (layer list).
            _myDisplayList.Source = _layerListSource;

            // Force an update of the list display.
            _myDisplayList.ReloadData();
        }
        private async void Initialize()
        {
            // Apply an imagery basemap to the map
            _myMapView.Map = new Map(Basemap.CreateDarkGrayCanvasVector());

            // Create the WMS Service
            WmsService service = new WmsService(_wmsUrl);

            try
            {
                // Load the WMS Service
                await service.LoadAsync();

                // Get the service info (metadata) from the service.
                WmsServiceInfo info = service.ServiceInfo;

                // Get the list of layer infos.
                foreach (var layerInfo in info.LayerInfos)
                {
                    LayerDisplayVM.BuildLayerInfoList(new LayerDisplayVM(layerInfo, null), _viewModelList);
                }

                // Create an array adapter for the layer display
                ArrayAdapter adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, _viewModelList);

                // Apply the adapter
                _myDisplayList.Adapter = adapter;

                // Subscribe to selection change notifications
                _myDisplayList.ItemClick += _myDisplayList_ItemClick;

                // Update the map display based on the viewModel
                UpdateMapDisplay(_viewModelList);
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
            }
        }
        private async void Initialize()
        {
            // Show dark gray canvas basemap.
            _myMapView.Map = new Map(Basemap.CreateDarkGrayCanvasVector());

            // Create the WMS Service.
            WmsService service = new WmsService(_wmsUrl);

            try
            {
                // Load the WMS Service.
                await service.LoadAsync();

                // Get the service info (metadata) from the service.
                WmsServiceInfo info = service.ServiceInfo;

                List <LayerDisplayVM> viewModelList = new List <LayerDisplayVM>();

                // Get the list of layer infos.
                foreach (var layerInfo in info.LayerInfos)
                {
                    LayerDisplayVM.BuildLayerInfoList(new LayerDisplayVM(layerInfo, null), viewModelList);
                }

                // Construct the layer list source.
                _layerListSource = new LayerListSource(viewModelList, this);

                // Set the source for the table view (layer list).
                _layerList.Source = _layerListSource;

                // Force an update of the list display.
                _layerList.ReloadData();
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
Beispiel #5
0
        }   // end MainWindow

        /// <summary>
        /// Open WMS service and store the list of imagery
        /// preserving hierarchy, if any
        /// Source: Runtime wms Service catalog
        /// MOD - pass in serviceurl
        /// </summary>
        private async void InitializeWMSLayer_VM()
        {
            // Initialize the display with a basemap
            // Reset Map projection if applicable
            Map myMap = new Map(SpatialReference.Create(4326));

            baseImageLayer = new ArcGISMapImageLayer(new Uri(
                                                         "https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer"));

            // Add baseImageLayer to the Map
            myMap.OperationalLayers.Add(baseImageLayer);

            // Assign the map to the MapView
            BasemapView.Map = myMap;

            // Create the WMS Service Load data from the URI
            // Create WMS Service service with default uri
            serviceURI = new Uri(wmsUriStartup.capableUri);
            serviceWMS = new WmsService(serviceURI);

            // If service can load, initialize the app
            try
            {
                // Load the WMS Service.
                await serviceWMS.LoadAsync();

                // Get the service info (metadata) from the service.
                WmsServiceInfo info = serviceWMS.ServiceInfo;

                // Process info to get information for all the layers
                // for the given serviceUri
                // LayerInfos gets a list of sublayers for a given layer
                IList <LayerInfoVM> temp = new List <LayerInfoVM>();
                foreach (WmsLayerInfo layerInfo in info.LayerInfos)
                {
                    LayerInfoVM.BuildLayerInfoList(new LayerInfoVM(layerInfo, null, false), _layerInfoOC);
                }

                // NASA GIBS Specific
                #region NASA
                string epsg = wmsUriStartup.EPSG.Substring(0, 4) + ":"
                              + wmsUriStartup.EPSG.Substring(4, 4);
                ProductLabel.Content = "NASA GIBS for EODIS: "
                                       + wmsUriStartup.latency.ToUpper() + " - "
                                       + epsg.ToUpper();
                Sort_NASA_GIBS(_layerInfoOC, out temp);
                _layerInfoOC.Clear();

                foreach (LayerInfoVM layerInfo in temp)
                {
                    _layerInfoOC.Add(layerInfo);
                }
                #endregion NASA

                // Update the map display based on the viewModel.
                UpdateViewModel(_layerInfoOC);

                // Update Product List
                //ProductTreeView.ItemsSource = _layerInfoOC;
                ProductList.ItemsSource = _layerInfoOC;
            }   // end try
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "WMS SERVER LOAD ERROR");
            }
        }   // end InitializeWMSLayer_VM
Beispiel #6
0
 public LayerWms(WmsProjectInfo wmsInfo)
 {
     wmsService = new WmsService(wmsInfo.GetCapabilities.Url);
     InitializeEvents(); 
     Initialize(wmsInfo);
 }
Beispiel #7
0
 public void Setup(string url)
 {
     if (setupDone) return;
     wmsService = new WmsService(url);
     InitializeEvents();
     wmsService.GetCapabilities();
     setupDone = true;
 }
        }   // end MainWindow

        /// <summary>
        /// Open WMS service and store the list of imagery
        /// perserving heirarchy, if any
        /// Source: Runtime wms Service catalog
        /// MOD - pass in serviceurl
        /// </summary>
        private async void InitializeWMSLayer_VM()
        {
            // Initialize the display with a basemap
            // BasemapView is UI esri mapview name in XAML
            // Reset Map projection if applicable
            Map myMap = new Map(SpatialReference.Create(4326));

            baseImageLayer = new ArcGISMapImageLayer(new Uri(
                                                         "https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer"));

            // Add baseImageLayer to the Map
            myMap.OperationalLayers.Add(baseImageLayer);

            // Assign the map to the MapView
            BasemapView.Map = myMap;

            // Create the WMS Service Load data from the URI
            // Create WMS Service service with default uri
            serviceURI = new Uri(wmsUriStartup.capableUri);
            serviceWMS = new WmsService(serviceURI);

            // If service can load, initialize the app
            try
            {
                // Load the WMS Service.
                await serviceWMS.LoadAsync();

                // Get the service info (metadata) from the service.
                WmsServiceInfo info = serviceWMS.ServiceInfo;

                // Process info to get information for all the layers
                // for the given serviceUri
                // LayerInfos gets a list of sublayers for a given layer
                foreach (var layerInfo in info.LayerInfos)
                {
                    LayerInfoVM.BuildLayerInfoList(new LayerInfoVM(layerInfo, null, false), _layerInfoOC);
                }


                // Sort Layers
                // This sorts list but list does not get passed to Itemsource

                /*
                 * List<WmsLayerInfo> sortedWmsInfo = new List<WmsLayerInfo>();
                 * ObservableCollection<LayerInfoVM> SortedList = new ObservableCollection<LayerInfoVM>( _layerInfoOC.OrderBy(o => o.Info.Title).ToList())
                 * _layerInfoOC = new ObservableCollection<LayerInfoVM>(SortedList);
                 * foreach (LayerInfoVM layerInfo in _layerInfoOC)
                 *  Debug.WriteLine(layerInfo.Info.Title + "  " + layerInfo.Info.Name);
                 * Debug.WriteLine("Counts: " + _layerInfoOC.Count + "  " + SortedList.Count);
                 */

                // Update the map display based on the viewModel.
                UpdateViewModel(_layerInfoOC);

                // Update UI element
                ProductLabel.Content = "NASA GIBS - " + wmsUriStartup.EPSG + " - "
                                       + wmsUriStartup.latency;
                ProductTreeView.ItemsSource = _layerInfoOC.Take(1);
            }   // end try
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "WMS SERVER LOAD ERROR");
            }
        }   // end InitializeWMSLayer_VM