Example #1
0
        private void BindCurrentLevel()
        {
            if (_controller.Level != null)
            {
                _root = new GroupLayer(_controller.RootLayer);

                _controller.LevelGeometry = _layerControl.LevelGeometry;

                _layerControl.RootLayer = _root;
                _layerControl.TextureCache.SourcePool = _controller.TexturePool;

                _layerControl.ReferenceOriginX = _controller.Level.OriginX;
                _layerControl.ReferenceOriginY = _controller.Level.OriginY;
                _layerControl.ReferenceWidth   = _controller.Level.Width;
                _layerControl.ReferenceHeight  = _controller.Level.Height;

                float zoomWidth  = (float)_layerControl.Width / _layerControl.ReferenceWidth;
                float zoomHeight = (float)_layerControl.Height / _layerControl.ReferenceHeight;
                _layerControl.Zoom = Math.Min(zoomWidth, zoomHeight);
            }
            else
            {
                _root = null;
                _layerControl.RootLayer = null;
                _layerControl.TextureCache.SourcePool = null;
            }
        }
Example #2
0
        public void ClearSelectionOnParentGroupLayerRemove()
        {
            var featureProvider = new DataTableFeatureProvider();

            featureProvider.Add(new WKTReader().Read("POINT(0 0)"));
            var layer = new VectorLayer {
                DataSource = featureProvider
            };
            var groupLayer = new GroupLayer {
                Layers = { layer }
            };

            using (var mapControl = new MapControl {
                Map = { Layers = { groupLayer } }, AllowDrop = false
            })
            {
                var selectTool = mapControl.SelectTool;

                selectTool.Select(featureProvider.Features.Cast <IFeature>());

                WindowsFormsTestHelper.Show(mapControl);

                mapControl.Map.Layers.Remove(groupLayer);

                mapControl.WaitUntilAllEventsAreProcessed();

                selectTool.Selection
                .Should("selection is cleared on layer remove").Be.Empty();
            }

            WindowsFormsTestHelper.CloseAll();
        }
Example #3
0
 /// <summary>
 /// Handles changes to the map (or bubbled up from ITheme, ILayer) properties.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public override void OnMapPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (sender is ILayer)
     {
         if (e.PropertyName == "Enabled")
         {
             // If a layer is enabled of disables and features of the layer are selected
             // the selection is cleared. Another solution is to remove only features of layer
             // from the selection, but this simple and effective.
             ILayer layer = (ILayer)sender;
             if (layer is GroupLayer)
             {
                 GroupLayer layerGroup = (GroupLayer)layer;
                 foreach (ILayer layerGroupLayer in layerGroup.Layers)
                 {
                     HandleLayerStatusChanged(layerGroupLayer);
                 }
             }
             else
             {
                 HandleLayerStatusChanged(layer);
             }
         }
     }
 }
Example #4
0
        private void BindTilePool(TilePoolPresenter tilePool)
        {
            if (_tilePool != null)
            {
                _tilePool.LevelGeometry = null;
            }
            if (_layerControl.RootLayer != null)
            {
                _layerControl.RootLayer.Dispose();
                _layerControl.RootLayer = null;
            }

            _tilePool = tilePool;
            if (_tilePool != null)
            {
                _tilePool.LevelGeometry = _layerControl.LevelGeometry;

                _root = new GroupLayer(tilePool.RootLayer);

                _layerControl.RootLayer = _root;
                //_pointerController.Responder = tilePool.PointerEventResponder;
                _pointerController.Responder = new LocalPointerEventResponder(this, tilePool.PointerEventResponder);
            }
            else
            {
                _root = null;
                _pointerController.Responder = null;
            }
        }
        public Group AddGroup(short label, List <uint> nodeIds)
        {
            if (HasGroup(nodeIds))
            {
                return(null);
            }

            List <Node> nodeList = nodeIds.Select <uint, Node>(delegate(uint id)
            {
                Node v = FindNode(id);
                if (v == null)
                {
                    return(null);
                }
                if (v.Group != null)
                {
                    v.Group.RemoveMember(v);
                }
                return(v);
            }).ToList();

            if (nodeList.Exists(v => v == null))
            {
                return(null);
            }

            Group g = new Group(this, label, nodeList);

            GroupLayer.Add(g);
            return(g);
        }
        // Load data - enable functionality after layers are loaded.
        private async void MyMapView_ExtentChanged(object sender, EventArgs e)
        {
            try
            {
                MyMapView.ExtentChanged -= MyMapView_ExtentChanged;

                // Get group layer from Map and set list items source
                _hydrographicGroupLayer = MyMapView.Map.Layers.OfType <GroupLayer>().First();

                // Check that sample data is downloaded to the client
                await CreateHydrographicLayerAsync(LAYER_1_PATH);
                await CreateHydrographicLayerAsync(LAYER_2_PATH);

                // Wait until all layers are loaded
                var layers = await MyMapView.LayersLoadedAsync();

                Envelope extent = _hydrographicGroupLayer.ChildLayers.First().FullExtent;

                // Create combined extent from child hydrographic layers
                foreach (var layer in _hydrographicGroupLayer.ChildLayers)
                {
                    extent = extent.Union(layer.FullExtent);
                }


                // Zoom to full extent
                await MyMapView.SetViewAsync(extent);
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "S57 Display Properties Sample").ShowAsync();
            }
        }
Example #7
0
        // Zoom to combined extent of the group layer that contains all hydrographic layers
        private async void ZoomToHydrographicLayers()
        {
            try
            {
                // wait until all layers are loaded
                await MyMapView.LayersLoadedAsync();

                // Get group layer from Map and set list items source
                _hydrographicGroupLayer   = MyMapView.Map.Layers.OfType <GroupLayer>().First();
                s57CellList.ItemsSource   = _hydrographicGroupLayer.ChildLayers;
                s57CellList.SelectedIndex = 0;

                Envelope extent = _hydrographicGroupLayer.ChildLayers.First().FullExtent;

                // Create combined extent from child hydrographic layers
                foreach (var layer in _hydrographicGroupLayer.ChildLayers)
                {
                    extent = extent.Union(layer.FullExtent);
                }

                // Zoom to full extent
                await MyMapView.SetViewAsync(extent);

                // Enable controls
                addCellButton.IsEnabled             = true;
                zoomToSelectedButton.IsEnabled      = true;
                removeSelectedCellsButton.IsEnabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error occured : " + ex.Message, "Sample error");
            }
        }
        // Load data - enable functionality after layers are loaded.
        private async void MyMapView_ExtentChanged(object sender, EventArgs e)
        {
            try
            {
                MyMapView.ExtentChanged -= MyMapView_ExtentChanged;

                // Get group layer from Map and set list items source
                _hydrographicGroupLayer = MyMapView.Map.Layers.OfType <GroupLayer>().First();

                // Check that sample data is downloaded to the client
                await CreateHydrographicLayerAsync(LAYER_1_PATH);
                await CreateHydrographicLayerAsync(LAYER_2_PATH);

                // Wait until all layers are loaded
                var layers = await MyMapView.LayersLoadedAsync();

                // Set item sources
                s57CellList.ItemsSource   = _hydrographicGroupLayer.ChildLayers;
                s57CellList.SelectedIndex = 0;

                // Zoom to hydrographic layer
                await MyMapView.SetViewAsync(_hydrographicGroupLayer.FullExtent);
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "S57 Cell Info Sample").ShowAsync();
            }
        }
        private async void Initialize()
        {
            // Create the layers.
            ArcGISSceneLayer devOne    = new ArcGISSceneLayer(new Uri("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/DevA_Trees/SceneServer"));
            FeatureLayer     devTwo    = new FeatureLayer(new Uri("https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/DevA_Pathways/FeatureServer/1"));
            ArcGISSceneLayer devThree  = new ArcGISSceneLayer(new Uri("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/DevB_BuildingShells/SceneServer"));
            ArcGISSceneLayer nonDevOne = new ArcGISSceneLayer(new Uri("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/DevA_BuildingShells/SceneServer"));
            FeatureLayer     nonDevTwo = new FeatureLayer(new Uri("https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/DevelopmentProjectArea/FeatureServer/0"));

            // Create the group layer and add sublayers.
            GroupLayer gLayer = new GroupLayer();

            gLayer.Name = "Group: Dev A";
            gLayer.Layers.Add(devOne);
            gLayer.Layers.Add(devTwo);
            gLayer.Layers.Add(devThree);

            // Create the scene with a basemap.
            MySceneView.Scene = new Scene(Basemap.CreateImagery());

            // Add the top-level layers to the scene.
            MySceneView.Scene.OperationalLayers.Add(gLayer);
            MySceneView.Scene.OperationalLayers.Add(nonDevOne);
            MySceneView.Scene.OperationalLayers.Add(nonDevTwo);

            // Wait for all of the layers in the group layer to load.
            await Task.WhenAll(gLayer.Layers.ToList().Select(m => m.LoadAsync()).ToList());

            // Zoom to the extent of the group layer.
            MySceneView.SetViewpoint(new Viewpoint(gLayer.FullExtent));
        }
		// Load data - enable functionality after layers are loaded.
		private async void MyMapView_ExtentChanged(object sender, EventArgs e)
		{
			try
			{
				MyMapView.ExtentChanged -= MyMapView_ExtentChanged;

				// Get group layer from Map and set list items source
				_hydrographicGroupLayer = MyMapView.Map.Layers.OfType<GroupLayer>().First();

				// Check that sample data is downloaded to the client
				await CreateHydrographicLayerAsync(LAYER_1_PATH);
				await CreateHydrographicLayerAsync(LAYER_2_PATH);

				// Wait until all layers are loaded
				var layers = await MyMapView.LayersLoadedAsync();

				// Set item sources
				s57CellList.ItemsSource = _hydrographicGroupLayer.ChildLayers;
				s57CellList.SelectedIndex = 0;

				// Zoom to hydrographic layer
				await MyMapView.SetViewAsync(_hydrographicGroupLayer.FullExtent);
			}
			catch (Exception ex)
			{
				var _x = new MessageDialog(ex.Message, "S57 Cell Info Sample").ShowAsync();
			}
		}
Example #11
0
        public void GetLayerByFeatureType()
        {
            var map         = new Map();
            var groupLayer1 = new GroupLayer();
            var groupLayer2 = new GroupLayer();
            var childLayer1 = new VectorLayer();
            var childLayer2 = new VectorLayer();
            var feature     = new Branch();

            map.Layers.Add(groupLayer1);
            groupLayer1.Layers.Add(childLayer1);
            groupLayer1.Layers.Add(groupLayer2);
            groupLayer2.Layers.Add(childLayer2);

            Assert.IsNull(map.GetLayerByFeature(feature));

            childLayer2.DataSource = new FeatureCollection
            {
                FeatureType = typeof(Branch)
            };

            Assert.AreSame(childLayer2, map.GetLayerByFeatureType(feature));

            childLayer1.DataSource = new FeatureCollection
            {
                FeatureType = typeof(Feature)
            };

            Assert.AreSame(childLayer2, map.GetLayerByFeatureType(feature));

            ((FeatureCollection)childLayer1.DataSource).FeatureType = typeof(Branch);

            Assert.AreSame(childLayer1, map.GetLayerByFeatureType(feature));
        }
Example #12
0
        public override void OnMapCollectionChanged(object sender, NotifyCollectionChangingEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangeAction.Remove:
            {
                if (sender is Map)
                {
                    ILayer layer = (ILayer)e.Item;
                    if (layer is GroupLayer)
                    {
                        GroupLayer layerGroup = (GroupLayer)layer;
                        foreach (ILayer layerGroupLayer in layerGroup.Layers)
                        {
                            HandleLayerStatusChanged(layerGroupLayer);
                        }
                    }
                    else
                    {
                        HandleLayerStatusChanged(layer);
                    }
                }
                break;
            }

            case NotifyCollectionChangeAction.Replace:
                throw new NotImplementedException();
            }
        }
		// Load data - enable functionality after layers are loaded.
		private async void MyMapView_ExtentChanged(object sender, EventArgs e)
		{
			try
			{
				MyMapView.ExtentChanged -= MyMapView_ExtentChanged;

				// Get group layer from Map and set list items source
				_hydrographicGroupLayer = MyMapView.Map.Layers.OfType<GroupLayer>().First();

				// Check that sample data is downloaded to the client
				await CreateHydrographicLayerAsync(LAYER_1_PATH);
				await CreateHydrographicLayerAsync(LAYER_2_PATH);

				// Wait until all layers are loaded
				var layers = await MyMapView.LayersLoadedAsync();

				Envelope extent = _hydrographicGroupLayer.ChildLayers.First().FullExtent;

				// Create combined extent from child hydrographic layers
				foreach (var layer in _hydrographicGroupLayer.ChildLayers)
					extent = extent.Union(layer.FullExtent);


				// Zoom to full extent
				await MyMapView.SetViewAsync(extent);
			}
			catch (Exception ex)
			{
				var _x = new MessageDialog(ex.Message, "S57 Display Properties Sample").ShowAsync();
			}
		}
Example #14
0
        public void BringForward()
        {
            var mocks = new MockRepository();

            var groupLayer = new GroupLayer();
            var layer1     = mocks.Stub <ILayer>();
            var layer2     = mocks.Stub <ILayer>();
            var layer3     = mocks.Stub <ILayer>();
            var layer4     = mocks.Stub <ILayer>();
            var layer5     = mocks.Stub <ILayer>();

            mocks.ReplayAll();

            var map = new Map();

            map.Layers.AddRange(new[] { groupLayer, layer4, layer5 });
            groupLayer.Layers.AddRange(new[] { layer1, layer2, layer3 });

            layer5.RenderOrder = 0;

            layer1.RenderOrder = 1;
            layer3.RenderOrder = 2;
            layer2.RenderOrder = 4;

            layer4.RenderOrder = 5;

            map.BringForward(layer3);

            Assert.AreEqual(0, layer5.RenderOrder);
            Assert.AreEqual(2, layer1.RenderOrder);
            Assert.AreEqual(1, layer3.RenderOrder);
            Assert.AreEqual(3, layer2.RenderOrder);
            Assert.AreEqual(4, layer4.RenderOrder);
        }
Example #15
0
        public void GroupLayerCloneTest()
        {
            var mocks = new MockRepository();
            var map   = mocks.StrictMock <Map>();

            map.Expect(m => m.IsDisposing).Return(false).Repeat.Any();

            var layer1      = mocks.DynamicMock <ILayer>();
            var layer1Clone = mocks.DynamicMock <ILayer>();

            layer1.Expect(l => l.Clone()).Return(layer1Clone).Repeat.Once();

            mocks.ReplayAll();

            var originalGroupLayer = new GroupLayer("original");

            originalGroupLayer.Map = map;
            originalGroupLayer.Layers.AddRange(new[] { layer1 });
            originalGroupLayer.HasReadOnlyLayersCollection = true;

            var clone = (GroupLayer)originalGroupLayer.Clone();

            Assert.AreEqual("original", clone.Name);
            Assert.IsNull(clone.Map);
            Assert.IsTrue(clone.HasReadOnlyLayersCollection);

            mocks.VerifyAll();
        }
        protected override void OnClick()
        {
            GroupLayer selectedGroupLayer = null;

            //If one group layer is selected, then add graphics layer to that one layer
            if (MapView.Active.GetSelectedLayers().Count == 1)
            {
                selectedGroupLayer = MapView.Active.GetSelectedLayers()[0] as GroupLayer;
            }

            var graphicsLayerCreationParams = new GraphicsLayerCreationParams {
                Name = "Graphics Layer"
            };

            QueuedTask.Run(() => {
                if (selectedGroupLayer != null)
                {
                    LayerFactory.Instance.CreateLayer <GraphicsLayer>(graphicsLayerCreationParams, selectedGroupLayer,
                                                                      LayerPosition.AutoArrange);
                }
                if (selectedGroupLayer == null)
                {
                    LayerFactory.Instance.CreateLayer <GraphicsLayer>(graphicsLayerCreationParams, MapView.Active.Map,
                                                                      LayerPosition.AutoArrange);
                }
            });
        }
Example #17
0
        public void SendToBack()
        {
            var mocks = new MockRepository();

            var groupLayer = new GroupLayer();
            var layer1     = mocks.Stub <ILayer>();
            var layer2     = mocks.Stub <ILayer>();
            var layer3     = mocks.Stub <ILayer>();
            var layer4     = mocks.Stub <ILayer>();

            mocks.ReplayAll();

            var map = new Map();

            map.Layers.AddRange(new[] { groupLayer, layer4 });
            groupLayer.Layers.AddRange(new[] { layer1, layer2, layer3 });

            layer4.RenderOrder = 5;

            layer1.RenderOrder = 1;
            layer3.RenderOrder = 2;
            layer2.RenderOrder = 4;

            map.SendToBack(groupLayer);

            Assert.AreEqual(1, layer1.RenderOrder);
            Assert.AreEqual(3, layer2.RenderOrder);
            Assert.AreEqual(2, layer3.RenderOrder);
            Assert.AreEqual(0, layer4.RenderOrder);
        }
Example #18
0
        /// <summary>
        /// Converts a layer hierarchy that may include group layers into a flat collection of layers.
        /// </summary>
        private static IEnumerable <Layer> FlattenLayers(this IEnumerable <Layer> layers, GroupLayer parent = null)
        {
            LayerCollection flattenedLayers = new LayerCollection();

            foreach (Layer layer in layers)
            {
                if (layer is GroupLayer && !(layer is KmlLayer))
                {
                    // Flatten group layers
                    GroupLayer groupLayer = (GroupLayer)layer;
                    foreach (Layer child in groupLayer.ChildLayers.FlattenLayers(groupLayer))
                    {
                        flattenedLayers.Add(child);
                    }
                }
                else
                {
                    // If the layer was within a group layer, account for the group layer's visibility
                    // and opacity
                    if (parent != null)
                    {
                        layer.Visible     = !parent.Visible ? false : layer.Visible;
                        layer.Opacity     = parent.Opacity * layer.Opacity;
                        layer.DisplayName = parent.DisplayName;
                    }

                    flattenedLayers.Add(layer);
                }
            }

            return(flattenedLayers);
        }
		// Zoom to combined extent of the group layer that contains all hydrographic layers
		private async void ZoomToHydrographicLayers()
		{
			try
			{
				// wait until all layers are loaded
				await MyMapView.LayersLoadedAsync();
				
				// Get group layer from Map and set list items source
				_hydrographicGroupLayer = MyMapView.Map.Layers.OfType<GroupLayer>().First();
				s57CellList.ItemsSource = _hydrographicGroupLayer.ChildLayers;
				s57CellList.SelectedIndex = 0;

				Envelope extent = _hydrographicGroupLayer.ChildLayers.First().FullExtent;

				// Create combined extent from child hydrographic layers
				foreach (var layer in _hydrographicGroupLayer.ChildLayers)
					extent = extent.Union(layer.FullExtent);

				// Zoom to full extent
				await MyMapView.SetViewAsync(extent);

				// Enable controls
				addCellButton.IsEnabled = true;
				zoomToSelectedButton.IsEnabled = true;
				removeSelectedCellsButton.IsEnabled = true;
			}
			catch (Exception ex)
			{
				MessageBox.Show("Error occurred : " + ex.Message, "Sample error");
			}
		}
Example #20
0
        public static IGroupLayer GetGroupLayer(string sName, IGroupLayer pParentGroupLayer, bool bCreateIfNeeded = true)
        {
            if (string.IsNullOrEmpty(sName))
            {
                // This route might be needed if the GCD calls this function without an open project.
                return(null);
            }

            // Try and find the group layer already in the hierarchy
            ICompositeLayer pCompositeLayer = (ICompositeLayer)pParentGroupLayer;

            for (int i = 0; i <= pCompositeLayer.Count - 1; i++)
            {
                if (string.Compare(pCompositeLayer.Layer[i].Name, sName, true) == 0)
                {
                    return((IGroupLayer)pCompositeLayer.Layer[i]);
                }
            }

            IGroupLayer pResultLayer = new GroupLayer();

            pResultLayer.Name = sName;
            ((IMapLayers)ArcMap.Document.FocusMap).InsertLayerInGroup(pParentGroupLayer, pResultLayer, true, 0);

            return(pResultLayer);
        }
Example #21
0
 // Adds all appropriate Layer objects to the list.
 // Calls itself recursively to search through GroupLayers.
 private void AddLayersToList(LayersBase layers, ListBox listbox)
 {
     foreach (IMapLayer layer in layers)
     {
         if (layer is GroupLayer)
         {
             GroupLayer grpLyr = layer as GroupLayer;
             AddLayersToList(grpLyr, listbox);
         }
         else if (layer is FeatureLayer)
         {
             FeatureLayer featLyr = layer as FeatureLayer;
             if (featLyr != null && featLyr.IsVisible &&
                 featLyr.Type != LayerType.Raster &&
                 featLyr.Type != LayerType.Grid)
             {
                 // The specified layer should be select-able.
                 // But if we've been asked to build a list of EDIT-able layers,
                 // take some other criteria into account... Seamless layers are
                 // not editable, and some tables are simply read-only.
                 if ((FilterType == FilterType.Selectable) ||
                     LayerCanBeMadeEditable(featLyr))
                 {
                     listbox.Items.Add(featLyr);
                 }
             }
         }
     }
 }
        // Create feature layers from the given geodatabase file
        private async Task CreateFeatureLayersAsync(string gdbPath)
        {
            try
            {
                var gdb = await Geodatabase.OpenAsync(gdbPath);

                if (gdb.FeatureTables.Count() == 0)
                {
                    throw new ApplicationException("Downloaded geodatabase has no feature tables.");
                }

                var groupLayer = MyMapView.Map.Layers["Local_Geodatabase"] as GroupLayer;
                if (groupLayer != null)
                {
                    MyMapView.Map.Layers.Remove(groupLayer);
                }

                groupLayer = new GroupLayer()
                {
                    ID          = "Local_Geodatabase",
                    DisplayName = string.Format("Local ({0})", gdbPath)
                };

                Envelope extent = gdb.FeatureTables.First().Extent;
                foreach (var table in gdb.FeatureTables)
                {
                    //if this call is made after FeatureTable is initialized, a call to FeatureLayer.ResetRender will be required.
                    table.UseAdvancedSymbology = true;
                    var flayer = new FeatureLayer()
                    {
                        ID           = table.Name,
                        DisplayName  = string.Format("{0} ({1})", table.Name, table.RowCount),
                        FeatureTable = table
                    };

                    if (table.Extent != null)
                    {
                        if (extent == null)
                        {
                            extent = table.Extent;
                        }
                        else
                        {
                            extent = extent.Union(table.Extent);
                        }
                    }

                    groupLayer.ChildLayers.Add(flayer);
                }

                MyMapView.Map.Layers.Add(groupLayer);

                await MyMapView.SetViewAsync(extent.Expand(1.10));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error creating feature layer: " + ex.Message, "Sample Error");
            }
        }
Example #23
0
        public override void OnClick()
        {
            IGroupLayer pGroupFLayer = new GroupLayer();

            pGroupFLayer.Name    = "н¨Í¼²ã×é";
            pGroupFLayer.Visible = true;
            _AppHk.MapControl.AddLayer(pGroupFLayer, 0);
        }
Example #24
0
 public void Add()
 {
     IsRunning = true;
     kml = new KmlLayer { ID = Name, Url = Location };
     gl = AppState.ViewDef.FindOrCreateGroupLayer(Folder);
     if (gl != null) gl.ChildLayers.Add(kml);
     kml.Initialize();
 }
Example #25
0
        public void MutatingAGroupLayerWithHasReadonlyLayerCollectionThrows()
        {
            var layerGroup = new GroupLayer {
                HasReadOnlyLayersCollection = true
            };
            var childLayer = new VectorLayer();

            layerGroup.Layers.Add(childLayer);
        }
        // Create feature layers from the given geodatabase file
        private async Task CreateFeatureLayersAsync(string gdbPath)
        {
            try
            {
                var gdb = await Geodatabase.OpenAsync(gdbPath);

                if (gdb.FeatureTables.Count() == 0)
                {
                    throw new ApplicationException("Downloaded geodatabase has no feature tables.");
                }

                var groupLayer = mapView.Map.Layers["Local_Geodatabase"] as GroupLayer;
                if (groupLayer != null)
                {
                    mapView.Map.Layers.Remove(groupLayer);
                }

                groupLayer = new GroupLayer()
                {
                    ID          = "Local_Geodatabase",
                    DisplayName = string.Format("Local ({0})", gdbPath)
                };

                Envelope extent = new Envelope();
                foreach (var table in gdb.FeatureTables)
                {
                    var flayer = new FeatureLayer()
                    {
                        ID           = table.Name,
                        DisplayName  = string.Format("{0} ({1})", table.Name, table.RowCount),
                        FeatureTable = table
                    };

                    if (table.Extent != null)
                    {
                        if (extent == null)
                        {
                            extent = table.Extent;
                        }
                        else
                        {
                            extent = extent.Union(table.Extent);
                        }
                    }

                    groupLayer.ChildLayers.Add(flayer);
                }

                mapView.Map.Layers.Add(groupLayer);

                await mapView.SetViewAsync(extent.Expand(1.10));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error creating feature layer: " + ex.Message, "Sample Error");
            }
        }
Example #27
0
        public void Add()
        {
            
            IsRunning = true;
            Folder = "Transport";
            ftl = new FlightTrackerLayer();            
            gl = AppState.ViewDef.FindOrCreateGroupLayer(this.Folder);
            if (gl != null) gl.ChildLayers.Add(ftl);
            ftl.Initialize();

        }
Example #28
0
 public async void toggleOnMap(bool value)
 {
     await QueuedTask.Run(() =>
     {
         string rootGroup      = "Planet API";
         string dateGroup      = parent.mapLayerName;
         string[] stripParents = { dateGroup, rootGroup };
         GroupLayer group      = Asset.GetGroup(mapLayerName, stripParents);
         group.SetVisibility(value);
     });
 }
		public S57IdentifySample()
		{
			InitializeComponent();
			_searchResults = new ObservableCollection<S57FeatureObject>();
			resultList.ItemsSource = _searchResults;

			// Reference layers that are used
			_hydrographicGroupLayer = mapView.Map.Layers.OfType<GroupLayer>().First();
			_resultGraphicsLayer = mapView.Map.Layers.OfType<GraphicsLayer>().First();
			mapView.ExtentChanged += mapView_ExtentChanged;
		}
        public S57IdentifySample()
        {
            InitializeComponent();
            _searchResults         = new ObservableCollection <S57FeatureObject>();
            resultList.ItemsSource = _searchResults;

            // Reference layers that are used
            _hydrographicGroupLayer = mapView.Map.Layers.OfType <GroupLayer>().First();
            _resultGraphicsLayer    = mapView.Map.Layers.OfType <GraphicsLayer>().First();
            mapView.ExtentChanged  += mapView_ExtentChanged;
        }
Example #31
0
        /// <summary>
        /// Copies the definition expressions from any feature layers under the source layer to the matching feature layers under the target layer.
        /// </summary>
        /// <param name="targetLayer">the target group layer</param>
        /// <param name="sourceLayer">the source group layer</param>
        private static void SetupLayersUnderGroupLayer(GroupLayer targetLayer, GroupLayer sourceLayer, LayerFileSource lfs)
        {
            Dictionary <string, string> defExprs = new Dictionary <string, string>();

            //
            // Collect all definition expressions.
            //
            foreach (Layer srcChildLayer in sourceLayer.Layers)
            {
                if (srcChildLayer is FeatureLayer)
                {
                    TesterLayer testLayer = new TesterLayer();
                    testLayer.FeatureLayer = srcChildLayer as FeatureLayer;
                    GeodatabaseFeatureTable featureTable = testLayer.FeatureLayer.FeatureTable as GeodatabaseFeatureTable;
                    testLayer.FeatureTable = featureTable;
                    lfs.Children.Add(testLayer);
                    FeatureLayer srcLayer = (FeatureLayer)srcChildLayer;
                    string       defExpr  = srcLayer.DefinitionExpression;

                    if (!string.IsNullOrEmpty(defExpr))
                    {
                        defExprs[srcLayer.Name] = defExpr;
                    }
                }
            }

            //
            // Apply all definition expressions.  Cache them as derived.
            //
            foreach (Layer tgtChildLayer in targetLayer.Layers)
            {
                if (tgtChildLayer is FeatureLayer)
                {
                    TesterLayer testLayer = new TesterLayer();
                    testLayer.FeatureLayer = tgtChildLayer as FeatureLayer;
                    GeodatabaseFeatureTable featureTable = testLayer.FeatureLayer.FeatureTable as GeodatabaseFeatureTable;
                    testLayer.FeatureTable = featureTable;
                    lfs.Children.Add(testLayer);
                    FeatureLayer tgtLayer = (FeatureLayer)tgtChildLayer;
                    tgtLayer.LabelsEnabled = true;

                    // This will apply the mapservice name to the feature layer under the group layers so that
                    // the results from this layer will be under the same map service or else it will be in a different set
                    // under a system generated hashcode for this layer.
                    tgtLayer.Id = targetLayer.Id;

                    if (defExprs.ContainsKey(tgtLayer.Name))
                    {
                        tgtLayer.DefinitionExpression = defExprs[tgtLayer.Name];
                    }
                }
            }
        }
        // This method will be called when the AddToMap button is clicked, this button will be displayed only if more than one scene is selected in the Datagrid
        private async void AddToMap()
        {
            if (SelectedLayer is ImageServiceLayer)
            {
                await QueuedTask.Run(() =>
                {
                    ImageServiceLayer imageServiceLayer = (ImageServiceLayer)SelectedLayer;
                    // Store information of original service layer so that it can be displayed back again
                    CIMMosaicRule originalMosaicRule = imageServiceLayer.GetMosaicRule();
                    string originalLayerName         = imageServiceLayer.Name;
                    //Map _map = await GetMapFromProject(Project.Current, "Map");
                    Map _map = MapView.Active.Map;
                    // Create a Group Layer which will act as a cotainer where selected layers will be added
                    GroupLayer grplayer = (GroupLayer)LayerFactory.Instance.CreateGroupLayer(_map, 0, _groupLayerName);
                    int _sceneCount     = 0;
                    foreach (object obj in _selectedList.Reverse <object>())
                    {
                        Scene scene = obj as Scene;
                        CIMMosaicRule mosaicRule = new CIMMosaicRule();
                        mosaicRule.MosaicMethod  = RasterMosaicMethod.LockRaster;
                        mosaicRule.LockRasterID  = scene.ObjectID;
                        ((ImageServiceLayer)imageServiceLayer).SetMosaicRule(mosaicRule);
                        imageServiceLayer.SetName(scene.Name);
                        imageServiceLayer.SetVisibility(false);
                        int ListCount = _selectedList.Count - 1;
                        if (_sceneCount == ListCount)
                        {
                            imageServiceLayer.SetVisibility(true);
                        }
                        else
                        {
                            imageServiceLayer.SetVisibility(false);
                            _sceneCount = _sceneCount + 1;
                        }
                        LayerFactory.Instance.CopyLayer(imageServiceLayer, grplayer);
                    }
                    // Done to display original image service layer
                    imageServiceLayer.SetMosaicRule(originalMosaicRule);
                    imageServiceLayer.SetName(originalLayerName);
                    imageServiceLayer.SetVisibility(false);
                    SelectedLayer = imageServiceLayer;
                    // Set visibilty of Group Layer to be true by default
                    grplayer.SetVisibility(true);

                    // Once the user has entered Group Layer Name, reset the Stack Panel
                    GroupLayerName = "";
                    NotifyPropertyChanged(() => GroupLayerName);

                    GroupNameVisibility = false;
                    NotifyPropertyChanged(() => GroupNameVisibility);
                });
            }
        }
Example #33
0
        public void Init(GroupLayer gl, MapPoint start, MapPoint finish, ResourceDictionary rd)
        {
            Start = new csPoint() { Mp = start };
            Finish = new csPoint() { Mp = finish };
            MLayer = new GraphicsLayer() { ID = Guid.NewGuid().ToString() };
            _start = new Graphic();
            _finish = new Graphic();
            _line = new Graphic();

            LineSymbol ls = new LineSymbol() { Color = Brushes.Black, Width = 4 };
            _line.Symbol = ls;
            //UpdateLine();

            MLayer.Graphics.Add(_line);

            _start.Geometry = start;
            _start.Attributes["position"] = start;

            _start.Symbol = rd["Start"] as Symbol;
            _start.Attributes["finish"] = _finish;
            _start.Attributes["start"] = _start;
            _start.Attributes["line"] = _line;
            _start.Attributes["state"] = "start";
            _start.Attributes["measure"] = this;
            _start.Attributes["menuenabled"] = true;
            MLayer.Graphics.Add(_start);

            _finish.Geometry = finish;
            _finish.Attributes["position"] = finish;
            _finish.Symbol = rd["Finish"] as Symbol;
            _finish.Attributes["finish"] = _finish;
            _finish.Attributes["menuenabled"] = true;
            _finish.Attributes["start"] = _start;
            _finish.Attributes["line"] = _line;
            _finish.Attributes["measure"] = this;
            _finish.Attributes["state"] = "finish";
            MLayer.Graphics.Add(_finish);



            Layer.ChildLayers.Add(MLayer);
            MLayer.Initialize();

            //AppStateSettings.Instance.ViewDef.MapManipulationDelta += ViewDef_MapManipulationDelta;

            GeoTimer = new Timer();

            GeoTimer.Elapsed += GeoTimer_Elapsed;
            GeoTimer.Interval = 100;

            GeoTimer.Start();
        }
        private void GetLayerNode(Layer lyr, XmlDocument doc)
        {
            Layer plyr = MapView.Active.Map.FindLayer(lyr.URI, true);


            MapMember mm = lyr;
            XmlNode   lnd;

            lnd = doc.SelectSingleNode("//Layers/String[text()='" + lyr.URI + "']");
            CIMService cs = new MapMemberService((MapMember)lyr);
            //var xmlLayer = GetlayerDefinitionAsync(lyr);
            var xmlLayer = cs.GetDefinitionAsync();
            XmlDocumentFragment xfrag = doc.CreateDocumentFragment();

            xfrag.InnerXml = xmlLayer.Result;
            XmlNode nd = xfrag.FirstChild;

            switch (lyr.GetType().Name)
            {
            case "GroupLayer":
                lnd.AppendChild(xfrag);
                GroupLayer glyr = (GroupLayer)lyr;
                foreach (var layer in glyr.Layers)
                {
                    lnd = doc.SelectSingleNode("//Layers/String[text()='" + lyr.URI + "']");
                    GetLayerNode(layer, doc);
                }
                break;

            case "FeatureLayer":
                var cfl = CIMFeatureLayer.FromXml(xmlLayer.Result);

                GetRenderer(cfl.Renderer, nd, ReportDir);
                lnd.AppendChild(nd);
                break;

            case "RasterLayer":
                var crl = CIMRasterLayer.FromXml(xmlLayer.Result);
                //GetRenderer(crl., nd, ReportDir);
                lnd.AppendChild(nd);
                break;

            case "StandaloneTable":
                lnd = doc.SelectSingleNode("//StandaloneTables/String[text()='" + lyr.URI + "']");
                lnd.AppendChild(nd);
                break;

            default:
                lnd.AppendChild(nd);
                break;
            }
        }
Example #35
0
        public async Task InitializeAsync(MapView mapView = null)
        {
            _updateVisibility = false;
            GroupLayer        = null;
            Clear();
            _initialExtent = (mapView ?? MapView.Active)?.Extent;
            Map    map  = (mapView ?? MapView.Active)?.Map;
            string name = _constants.CycloMediaLayerName;

            if (map != null)
            {
                var  layers = map.GetLayersAsFlattenedList();
                var  layersForGroupLayer = map.FindLayers(name);
                bool leave = false;

                foreach (Layer layer in layersForGroupLayer)
                {
                    if (layer is GroupLayer)
                    {
                        if (!leave)
                        {
                            GroupLayer = layer as GroupLayer;
                            leave      = true;
                        }
                    }
                    else
                    {
                        await QueuedTask.Run(() =>
                        {
                            map.RemoveLayer(layer);
                        });
                    }
                }

                if (GroupLayer == null)
                {
                    await QueuedTask.Run(() =>
                    {
                        GroupLayer = LayerFactory.Instance.CreateGroupLayer(map, 0, name);
                        GroupLayer.SetExpanded(true);
                    });
                }

                foreach (Layer layer in layers)
                {
                    await AddLayerAsync(layer.Name, mapView);
                }
            }

            MapMemberPropertiesChangedEvent.Subscribe(OnMapMemberPropertiesChanged);
            await CheckVisibilityLayersAsync();
        }
Example #36
0
        public S57IdentifySample()
        {
            InitializeComponent();
            _searchResults         = new ObservableCollection <S57FeatureObject>();
            resultList.ItemsSource = _searchResults;

            // Reference layers that are used
            _hydrographicLayers           = MyMapView.Map.Layers.OfType <GroupLayer>().First();
            _polygonResultGraphicsOverlay = MyMapView.GraphicsOverlays["polygonResultsOverlay"];
            _lineResultGraphicsOverlay    = MyMapView.GraphicsOverlays["lineResultsOverlay"];
            _pointResultGraphicsOverlay   = MyMapView.GraphicsOverlays["pointResultsOverlay"];
            ZoomToHydrographicLayers();
        }
		public S57IdentifySample()
		{
			InitializeComponent();
			_searchResults = new ObservableCollection<S57FeatureObject>();
			resultList.ItemsSource = _searchResults;

			// Reference layers that are used
			_hydrographicLayers = MyMapView.Map.Layers.OfType<GroupLayer>().First();
			_polygonResultGraphicsOverlay = MyMapView.GraphicsOverlays["polygonResultsOverlay"];
			_lineResultGraphicsOverlay = MyMapView.GraphicsOverlays["lineResultsOverlay"];
			_pointResultGraphicsOverlay = MyMapView.GraphicsOverlays["pointResultsOverlay"];
			ZoomToHydrographicLayers();
		}
Example #38
0
        public void GetGroupLayerContainingLayer()
        {
            var map        = new Map();
            var groupLayer = new GroupLayer();
            var childLayer = new VectorLayer();

            map.Layers.Add(groupLayer);
            groupLayer.Layers.Add(childLayer);

            Assert.AreEqual(groupLayer, map.GetGroupLayerContainingLayer(childLayer));
            //the grouplayer is not part of a grouplayer
            Assert.IsNull(map.GetGroupLayerContainingLayer(groupLayer));
        }
        public S57SearchSample()
        {
            this.InitializeComponent();
            MyMapView.ExtentChanged += MyMapView_ExtentChanged;

            _searchResults = new ObservableCollection<S57FeatureObject>();
            resultList.ItemsSource = _searchResults;

            // Reference layers that are used
            _hydrographicLayers = MyMapView.Map.Layers.OfType<GroupLayer>().First();
            _drawGraphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"];
            _polygonResultGraphicsOverlay = MyMapView.GraphicsOverlays["polygonResultsOverlay"];
            _lineResultGraphicsOverlay = MyMapView.GraphicsOverlays["lineResultsOverlay"];
            _pointResultGraphicsOverlay = MyMapView.GraphicsOverlays["pointResultsOverlay"];
        }
        public S57SearchSample()
        {
            InitializeComponent();

            DataContext = this;
            _currentDrawShape = DrawShape.Point;
            _searchResults = new ObservableCollection<S57FeatureObject>();
            ResultList.ItemsSource = _searchResults;

            // Reference layers that are used
            _hydrographicLayers = MyMapView.Map.Layers.OfType<GroupLayer>().First();
            _drawGraphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"];
            _polygonResultGraphicsOverlay = MyMapView.GraphicsOverlays["polygonResultsOverlay"];
            _lineResultGraphicsOverlay = MyMapView.GraphicsOverlays["lineResultsOverlay"];
            _pointResultGraphicsOverlay = MyMapView.GraphicsOverlays["pointResultsOverlay"];
            ZoomToHydrographicLayers();
        }
Example #41
0
 public ucGeoCodingTool()
 {
     InitializeComponent();
     Loaded += UcPlacemarkLoaded;
     _layer = AppState.ViewDef.MapToolsLayer;
     Layer l = _layer.ChildLayers.FirstOrDefault(k => k.ID == "Geo");
     if (l != null && l is GraphicsLayer)
     {
         gLayer = (GraphicsLayer)l;
     }
     else
     {
         gLayer = new GraphicsLayer { ID = "Geo" };
         _layer.ChildLayers.Add(gLayer);
         gLayer.Initialize();
     }
 }
Example #42
0
        public void Init()
        {
            var folder = AppState.Config.Get("ShapeLayer.Folder", "");
            if (String.IsNullOrEmpty(folder)) return;
            _folder = folder;
            var groupName = AppState.Config.Get("ShapeLayer.GroupName", "Shapes");
            var layer = new GroupLayer {ID = groupName};

            layer.Initialize();
            layer.Visible = true;
            _gl = layer;

            _bgWorker = new BackgroundWorker();
            _bgWorker.DoWork += _bgWorker_DoWork;
            _bgWorker.RunWorkerCompleted += _bgWorker_RunWorkerCompleted;
            _bgWorker.RunWorkerAsync();
        }
Example #43
0
        public void Add()
        {
            //WmtsLayer kml = new WmtsLayer()
            //                     {
            //                         ID = Name,
            //                         Url =
            //                             "http://134.221.210.43:8008/geoserver/gwc/service/wmts?REQUEST=getcapabilities"
            //                     };
             kml = new WmsLayer() { ID = Name, Url = Location };            
            gl = AppState.ViewDef.FindOrCreateGroupLayer(this.Folder);
            //kml.Version = "1.1.0";
            //kml.ServiceMode = WmtsLayer.WmtsServiceMode.KVP;
            kml.Layers = Layers;    
            if (gl != null) gl.ChildLayers.Add(kml);
            kml.Initialize();
            IsRunning = true;

        }
Example #44
0
 public void AddShapefile(string filePath, GroupLayer curGrLayer)
 {
     Execute.OnUIThread(() =>
     {
         var grLay = new ShapeGraphicsLayer(filePath);
         //var grLay = new GraphicsLayer();
         var fi = new FileInfo(filePath);
         var settingsXml = fi.Directory + "/" + fi.Name + ".xml";
         var settings = new ShapeLayerSettings();
         if (File.Exists(settingsXml))
         {
             settings = GetSettings(settingsXml);
         }
         grLay.ID = fi.Name;
         grLay.Visible = false;
         grLay.Initialize();
         curGrLayer.ChildLayers.Add(grLay);
         using (var shapeFile = new Shapefile.Shapefile(filePath))
         {
             foreach (var shape in shapeFile)
             {
                                        //string[] metadataNames = shape.GetMetadataNames();
                                        // if (metadataNames != null)
                                        // {
                                        //     Console.WriteLine("Metadata:");
                                        //     var str = string.Empty;
                                        //     foreach (string metadataName in metadataNames)
                                        //     {
                                        //         str += String.Format("{0}={1} ({2})", metadataName, shape.GetMetadata(metadataName), shape.DataRecord.GetDataTypeName(shape.DataRecord.GetOrdinal(metadataName))) + Environment.NewLine;
                                        //     }
                                        //     Console.WriteLine();
                                        // }
                 switch (shape.Type)
                 {
                     case ShapeType.Polygon:
                         var shapePolygon = shape as ShapePolygon;
                         if (shapePolygon != null)
                             foreach (var part in shapePolygon.Parts)
                             {
                                 //Console.WriteLine("Polygon part:");
                                 var wpfShape = new System.Windows.Shapes.Polygon();
                                 var points = new System.Windows.Media.PointCollection();
                                 foreach (var point in part)
                                 {
                                     //Console.WriteLine("{0}, {1}", point.X, point.Y);
                                     double lat, lon;
                                                    //lat = point.Y;
                                                    //lon = point.X;
                                     CoordinateUtils.Rd2LonLat(point.X, point.Y, out lon, out lat);
                                     wpfShape.Points.Add(new Point(lon, lat));
                                     points.Add(new Point(lon, lat));
                                 }
                                 shapeList.Add(wpfShape);
                                 DrawPolygon(points, grLay, settings);
                             }
                         break;
                     case ShapeType.PolyLine:
                         var shapePolyline = shape as ShapePolyLine;
                         if (shapePolyline != null)
                             foreach (var part in shapePolyline.Parts)
                             {
                                 //Console.WriteLine("Polygon part:");
                                 var wpfShape = new System.Windows.Shapes.Polygon();
                                 var points = new System.Windows.Media.PointCollection();
                                 foreach (var point in part)
                                 {
                                     //Console.WriteLine("{0}, {1}", point.X, point.Y);
                                     //CoordinateUtils.Rd2LonLat(point.X,point.Y,out lon, out lat);
                                     var lat = point.Y;
                                     var lon = point.X;
                                     wpfShape.Points.Add(new Point(lon, lat));
                                     points.Add(new Point(lon, lat));
                                 }
                                 shapeList.Add(wpfShape);
                                 DrawPolyline(points, grLay, settings);
                             }
                         break;
                 }
             }
         }
     });
 }
        /// <summary>
        /// Converts a layer hierarchy that may include group layers into a flat collection of layers.  
        /// </summary>
        private static IEnumerable<Layer> FlattenLayers(this IEnumerable<Layer> layers, GroupLayer parent = null)
        {
            LayerCollection flattenedLayers = new LayerCollection();
            foreach (Layer layer in layers)
            {
                if (layer is GroupLayer && !(layer is KmlLayer))
                {
                    // Flatten group layers
                    GroupLayer groupLayer = (GroupLayer)layer;
                    foreach (Layer child in groupLayer.ChildLayers.FlattenLayers(groupLayer))
                        flattenedLayers.Add(child);                    
                }
                else
                {
                    // If the layer was within a group layer, account for the group layer's visibility
                    // and opacity
                    if (parent != null)
                    {
                        layer.Visible = !parent.Visible ? false : layer.Visible;
                        layer.Opacity = parent.Opacity * layer.Opacity;
                        layer.DisplayName = parent.DisplayName;
                    }

                    flattenedLayers.Add(layer);
                }
            }

            return flattenedLayers;
        }
        public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager envMgr, ESRI.ArcGIS.Geodatabase.IGPMessages message)
        {
            try
            {
                IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();

                if (TrackCancel == null)
                {
                    TrackCancel = new CancelTrackerClass();
                }

                IGPValue inputLayersGPValue = gpUtilities3.UnpackGPValue(paramvalues.get_Element(in_LayersNumber));
                IGPMultiValue inputLayersMultiValue = gpUtilities3.UnpackGPValue(inputLayersGPValue) as IGPMultiValue;

                IGPParameter outputGroupLayerParameter = paramvalues.get_Element(out_groupLayerNumber) as IGPParameter;
                IGPValue outputGPGroupLayer = gpUtilities3.UnpackGPValue(outputGroupLayerParameter);
                IGPCompositeLayer outputCompositeLayer = outputGPGroupLayer as IGPCompositeLayer;

                if (outputCompositeLayer == null)
                {
                    message.AddError(120048, string.Format(resourceManager.GetString("GPTools_NullPointerParameterType"), outputGroupLayerParameter.Name));
                    return;
                }

                IGroupLayer groupLayer = null;

                // find the last position of the "\" string
                // in case we find such a thing, i.e. position is >= -1 then let's assume that we are dealing with a layer file on disk
                // otherwise let's create a new group layer instance
                string outputGPLayerNameAsString = outputGPGroupLayer.GetAsText();
                int separatorPosition = outputGPLayerNameAsString.LastIndexOf(System.IO.Path.DirectorySeparatorChar);
                string layerName = String.Empty;

                if (separatorPosition > -1)
                {
                    layerName = outputGPGroupLayer.GetAsText().Substring(separatorPosition + 1);
                }
                else
                {
                    layerName = outputGPGroupLayer.GetAsText();
                }

                ILayer foundLayer = null;
                IGPLayer existingGPLayer = gpUtilities3.FindMapLayer2(layerName, out foundLayer);

                if (foundLayer != null)
                {
                    gpUtilities3.RemoveFromMapEx((IGPValue)existingGPLayer);
                    gpUtilities3.RemoveInternalLayerEx(foundLayer);
                }

                groupLayer = new GroupLayer();
                ((ILayer)groupLayer).Name = layerName;

                for (int layerIndex = 0; layerIndex < inputLayersMultiValue.Count; layerIndex++)
                {
                    IGPValue gpLayerToAdd = inputLayersMultiValue.get_Value(layerIndex) as IGPValue;

                    ILayer sourceLayer = gpUtilities3.DecodeLayer(gpLayerToAdd);

                    groupLayer.Add(sourceLayer);
                }

                outputGPGroupLayer = gpUtilities3.MakeGPValueFromObject(groupLayer);

                if (separatorPosition > -1)
                {
                    try
                    {
                        // in the case that we are dealing with a layer file on disk
                        // let's persist the group layer information into the file
                        ILayerFile pointLayerFile = new LayerFileClass();

                        if (System.IO.Path.GetExtension(outputGPLayerNameAsString).ToUpper().Equals(".LYR"))
                        {
                            if (pointLayerFile.get_IsPresent(outputGPLayerNameAsString))
                            {
                                try
                                {
                                    gpUtilities3.Delete(outputGPGroupLayer);
                                }
                                catch (Exception ex)
                                {
                                    message.AddError(120001, ex.Message);
                                    return;
                                }
                            }

                            pointLayerFile.New(outputGPLayerNameAsString);

                            pointLayerFile.ReplaceContents(groupLayer);

                            pointLayerFile.Save();

                        }

                         outputGPGroupLayer = gpUtilities3.MakeGPValueFromObject(pointLayerFile.Layer);
                    }
                    catch (Exception ex)
                    {
                        message.AddError(120002, ex.Message);
                        return;
                    }
                }

                gpUtilities3.PackGPValue(outputGPGroupLayer, outputGroupLayerParameter);

            }
            catch (Exception ex)
            {
                message.AddError(120049, ex.Message);
            }
        }
Example #47
0
 public ucRangeMapTool()
 {
     InitializeComponent();
     Loaded += UcPlacemarkLoaded;
     _layer = AppState.ViewDef.MapToolsLayer;
 }
Example #48
0
        public void Add()
        {
            IsRunning = true;

            geoRss = new GeoRssLayer() { ID = Name, Source = Location };
            gl = AppState.ViewDef.FindOrCreateGroupLayer(this.Folder);
            if (gl != null) gl.ChildLayers.Add(geoRss);
            var sr = new SimpleRenderer
            {
                Symbol = new PictureMarkerSymbol()
                {
                    Source = new BitmapImage(IconUri),
                    Width = IconSize,
                    OffsetX = IconSize / 2,
                    OffsetY = IconSize / 2
                }
            };
            geoRss.Renderer = sr; // Renderer;
            geoRss.Initialize();
        }
Example #49
0
        private void GetVisibleGraphics(Rect pos, GroupLayer gl, ref List<Graphic> vg)
        {
            // TODO EV Prevent camera from attaching

            foreach (GroupLayer g in gl.ChildLayers.Where(k => k is GroupLayer))
            {
                GetVisibleGraphics(pos, g, ref vg);
            }
            foreach (GraphicsLayer gr in gl.ChildLayers.Where(k => k is GraphicsLayer))
            {
                if (gr.Visible)
                    foreach (var gc in gr.FindGraphicsInHostCoordinates(pos))
                    {
                        if (gc.Attributes.ContainsKey("Attachable") && gc.Geometry is MapPoint) vg.Add(gc);
                    }
            }
        }
        // Create feature layers from the given geodatabase file
        private async Task CreateFeatureLayersAsync(string gdbPath)
        {
            try
            {
                var gdb = await Geodatabase.OpenAsync(gdbPath);

                if (gdb.FeatureTables.Count() == 0)
                    throw new ApplicationException("Downloaded geodatabase has no feature tables.");

                var groupLayer = mapView.Map.Layers["Local_Geodatabase"] as GroupLayer;
                if (groupLayer != null)
                    mapView.Map.Layers.Remove(groupLayer);
                
                groupLayer = new GroupLayer()
                {
                    ID = "Local_Geodatabase",
                    DisplayName = string.Format("Local ({0})", gdbPath)
                };

                Envelope extent = new Envelope();
                foreach (var table in gdb.FeatureTables)
                {
                    var flayer = new FeatureLayer()
                    {
                        ID = table.Name,
                        DisplayName = string.Format("{0} ({1})", table.Name, table.RowCount),
                        FeatureTable = table
                    };

                    if (table.Extent != null)
                    {
                        if (extent == null)
                            extent = table.Extent;
                        else
                            extent = extent.Union(table.Extent);
                    }

                    groupLayer.ChildLayers.Add(flayer);
                }

                mapView.Map.Layers.Add(groupLayer);

                await mapView.SetViewAsync(extent.Expand(1.10));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error creating feature layer: " + ex.Message, "Sample Error");
            }
        }
Example #51
0
 public EffectsMapToolView()
 {
     InitializeComponent();
     Loaded += OnLoaded;
     _layer = AppState.ViewDef.MapToolsLayer;
 }
Example #52
0
        //public string BaseUrl = "http://cool2.sensorlab.tno.nl:8000/BuienRadarService/RainImage/eu/warped/";
        //public string BaseUrl = "http://cool2.sensorlab.tno.nl:8000/BuienRadarService/RainImage/nl/warped/";
        //public string BaseUrl = "http://*****:*****@"Weather/Rain");
            var w = new WebMercator();
            //Buienradar
            var wi = new RainRadarLayer {ID = Name};
            i = new Image {
                IsHitTestVisible = false,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch
            };
            UpdateImage(AppState.TimelineManager.FocusTime);
            var mpa = new MapPoint(tlLat, tlLon);
            var mpb = new MapPoint(brLat, brLon);
          
            mpa = w.FromGeographic(mpa) as MapPoint;
            mpb = w.FromGeographic(mpb) as MapPoint;
            var envelope = new Envelope(mpa, mpb);
            ElementLayer.SetEnvelope(i, envelope);

            wi.Children.Add(i);
            wi.Initialize();
            wi.Visible = true;
            gl.ChildLayers.Add(wi);

            AppState.TimelineManager.TimeChanged += TimelineManager_TimeChanged;

            AppState.CreateCache += AppState_CreateCache;
        }
Example #53
0
 /// <summary>
 /// Reads the folder that is configured in the settings and creates layers for the files in the folders.
 /// </summary>
 public void ReadFolder(string path, GroupLayer curGrLayer)
 {
     //Canvas cnvs = new Canvas();
     //dispatcher = cnvs.Dispatcher;
     //string path = @"D:\Projects\TNO\bitBucket\apps\ufData\Forest2000";
     Execute.OnUIThread(() =>
                            {
                                foreach (var file in Directory.EnumerateFiles(path))
                                {
                                    if (file.ToLower().EndsWith(".shp"))
                                    {
                                        AddShapefile(file, curGrLayer); // Hier wordt de locale shape geladen. 
                                    }
                                    if(file.ToLower().EndsWith(".kml"))
                                    {
                                        AddKmlFile(file, curGrLayer);
                                    }
                                }
                                foreach (var folder in Directory.EnumerateDirectories(path))
                                {
                                    // Add Subfolders as new grouplayers
                                    var di = new DirectoryInfo(folder);
                                    var newGl = new GroupLayer {ID = di.Name};
                                    newGl.Initialize();
                                    curGrLayer.ChildLayers.Add(newGl);
                                    ReadFolder(folder, newGl);
                                }
                            });
 }
        public bool MoveToGroupLayer(string theGroupLayerName, ILayer aLayer,  bool Messages = false)
        {
            bool blExists = false;
            IGroupLayer myGroupLayer = new GroupLayer(); 
            // Does the group layer exist?
            if (GroupLayerExists(theGroupLayerName))
            {
                myGroupLayer = (IGroupLayer)GetGroupLayer(theGroupLayerName);
                blExists = true;
            }
            else
            {
                myGroupLayer.Name = theGroupLayerName;
            }
            string theOldName = aLayer.Name;

            // Remove the original instance, then add it to the group.
            RemoveLayer(aLayer);
            myGroupLayer.Add(aLayer);
            
            if (!blExists)
            {
                // Add the layer to the map.
                IMap pMap = GetMap();
                pMap.AddLayer(myGroupLayer);
            }
            RefreshTOC();
            return true;
        }
Example #55
0
        public void Init(GroupLayer gl, MapPoint start, MapPoint finish, ResourceDictionary rd)
        {
            Start = new EffectsPoint() { Mp = start };
            Finish = new EffectsPoint() { Mp = finish };
            MLayer = new GraphicsLayer() { ID = Guid.NewGuid().ToString() };
            ContoursLayer = new GraphicsLayer() { ID = Guid.NewGuid().ToString() };
            _start = new Graphic();
            _finish = new Graphic();
            Line = new Graphic();
            BaseEffectsModelShapes = new GraphicCollection();
            EffectsModelShapes = new GraphicCollection();

            
            
//            var testJson = new FileInfo(@"Plugins\USDomainPlugin\Effects\Data\testshape.json");
//            JObject geoJson = null;
//            using (var reader = testJson.OpenText())
//            {
//                var strJson = reader.ReadToEnd();
//                geoJson = JObject.Parse(strJson);
//                reader.Close();
//            }
//            var strWkt = @"POLYGON ((281.4968022018320000 0,281.3579005227060000 8.8420282352252900,280.9413325645150000 17.6753304560934000,280.2475094295410000 26.4911892597699000,279.2771158374510000 35.2809044579670000,278.0311094495650000 44.0358016629793000,276.5107199237550000 52.7472408482570000,274.7174477009240000 61.4066248750691000,272.6530625242520000 70.0054079768411000,270.3196016926710000 78.5351041927953000,267.7193680503000000 86.9872957425693000,264.8549277138150000 95.3536413335488000,261.7291075400000000 103.6258843927170000,258.3449923359800000 111.7958612148940000,254.7059218148940000 119.8555090193290000,250.8154872999950000 127.7968739066940000,246.6775281804520000 135.6121187086160000,242.2961281223330000 143.2935307220230000,237.6756110385240000 150.8335293206440000,232.8205368215440000 158.2246734361790000,227.7356968434850000 165.4596689017280000,222.4261092275060000 172.5313756502600000,216.8970138955490000 179.4328147609900000,211.1538673971700000 186.1571753467370000,205.2023375245860000 192.6978212754450000,199.0482977192440000 199.0482977192440000,192.6978212754450000 205.2023375245860000,186.1571753467370000 211.1538673971700000,179.4328147609900000 216.8970138955490000,172.5313756502600000 222.4261092275060000,165.4596689017280000 227.7356968434850000,158.2246734361790000 232.8205368215440000,150.8335293206440000 237.6756110385240000,143.2935307220230000 242.2961281223330000,135.6121187086160000 246.6775281804520000,127.7968739066940000 250.8154872999950000,119.8555090193290000 254.7059218148940000,111.7958612148940000 258.3449923359800000,103.6258843927170000 261.7291075400000000,95.3536413335487000 264.8549277138150000,86.9872957425692000 267.7193680503000000,78.5351041927953000 270.3196016926710000,70.0054079768411000 272.6530625242520000,61.4066248750690000 274.7174477009240000,52.7472408482570000 276.5107199237550000,44.0358016629793000 278.0311094495650000,35.2809044579670000 279.2771158374510000,26.4911892597699000 280.2475094295410000,17.6753304560934000 280.9413325645150000,8.8420282352253100 281.3579005227060000,0.0000000000000172 281.4968022018320000,-8.8420282352252800 281.3579005227060000,-17.6753304560934000 280.9413325645150000,-26.4911892597699000 280.2475094295410000,-35.2809044579670000 279.2771158374510000,-44.0358016629793000 278.0311094495650000,-52.7472408482571000 276.5107199237550000,-61.4066248750690000 274.7174477009240000,-70.0054079768410000 272.6530625242520000,-78.5351041927953000 270.3196016926710000,-86.9872957425692000 267.7193680503000000,-95.3536413335488000 264.8549277138150000,-103.6258843927170000 261.7291075400000000,-111.7958612148940000 258.3449923359800000,-119.8555090193300000 254.7059218148940000,-127.7968739066940000 250.8154872999950000,-135.6121187086170000 246.6775281804520000,-143.2935307220230000 242.2961281223330000,-150.8335293206440000 237.6756110385240000,-158.2246734361790000 232.8205368215440000,-165.4596689017280000 227.7356968434850000,-172.5313756502600000 222.4261092275060000,-179.4328147609900000 216.8970138955490000,-186.1571753467370000 211.1538673971700000,-192.6978212754450000 205.2023375245860000,-199.0482977192440000 199.0482977192440000,-205.2023375245860000 192.6978212754450000,-211.1538673971700000 186.1571753467370000,-216.8970138955490000 179.4328147609900000,-222.4261092275060000 172.5313756502600000,-227.7356968434850000 165.4596689017280000,-232.8205368215440000 158.2246734361790000,-237.6756110385240000 150.8335293206440000,-242.2961281223330000 143.2935307220230000,-246.6775281804520000 135.6121187086160000,-250.8154872999950000 127.7968739066940000,-254.7059218148940000 119.8555090193290000,-258.3449923359800000 111.7958612148940000,-261.7291075400000000 103.6258843927170000,-264.8549277138150000 95.3536413335488000,-267.7193680503000000 86.9872957425693000,-270.3196016926710000 78.5351041927953000,-272.6530625242520000 70.0054079768411000,-274.7174477009240000 61.4066248750690000,-276.5107199237550000 52.7472408482571000,-278.0311094495650000 44.0358016629793000,-279.2771158374510000 35.2809044579671000,-280.2475094295410000 26.4911892597699000,-280.9413325645150000 17.6753304560935000,-281.3579005227060000 8.8420282352252700,-281.4968022018320000 0.0000000000000345,-281.3579005227060000 -8.8420282352253200,-280.9413325645150000 -17.6753304560934000,-280.2475094295410000 -26.4911892597699000,-279.2771158374510000 -35.2809044579670000,-278.0311094495650000 -44.0358016629794000,-276.5107199237550000 -52.7472408482570000,-274.7174477009240000 -61.4066248750692000,-272.6530625242520000 -70.0054079768412000,-270.3196016926710000 -78.5351041927953000,-267.7193680503000000 -86.9872957425693000,-264.8549277138150000 -95.3536413335488000,-261.7291075400000000 -103.6258843927170000,-258.3449923359800000 -111.7958612148940000,-254.7059218148940000 -119.8555090193290000,-250.8154872999950000 -127.7968739066940000,-246.6775281804520000 -135.6121187086160000,-242.2961281223330000 -143.2935307220230000,-237.6756110385240000 -150.8335293206440000,-232.8205368215440000 -158.2246734361790000,-227.7356968434850000 -165.4596689017280000,-222.4261092275060000 -172.5313756502600000,-216.8970138955490000 -179.4328147609900000,-211.1538673971700000 -186.1571753467370000,-205.2023375245860000 -192.6978212754450000,-199.0482977192440000 -199.0482977192440000,-192.6978212754450000 -205.2023375245860000,-186.1571753467370000 -211.1538673971700000,-179.4328147609900000 -216.8970138955490000,-172.5313756502600000 -222.4261092275060000,-165.4596689017280000 -227.7356968434850000,-158.2246734361790000 -232.8205368215440000,-150.8335293206440000 -237.6756110385240000,-143.2935307220230000 -242.2961281223330000,-135.6121187086160000 -246.6775281804520000,-127.7968739066940000 -250.8154872999950000,-119.8555090193290000 -254.7059218148940000,-111.7958612148940000 -258.3449923359800000,-103.6258843927170000 -261.7291075400000000,-95.3536413335488000 -264.8549277138150000,-86.9872957425693000 -267.7193680503000000,-78.5351041927954000 -270.3196016926710000,-70.0054079768412000 -272.6530625242520000,-61.4066248750690000 -274.7174477009240000,-52.7472408482570000 -276.5107199237550000,-44.0358016629793000 -278.0311094495650000,-35.2809044579671000 -279.2771158374510000,-26.4911892597698000 -280.2475094295410000,-17.6753304560934000 -280.9413325645150000,-8.8420282352252900 -281.3579005227060000,-0.0000000000000517 -281.4968022018320000,8.8420282352251800 -281.3579005227060000,17.6753304560935000 -280.9413325645150000,26.4911892597699000 -280.2475094295410000,35.2809044579670000 -279.2771158374510000,44.0358016629792000 -278.0311094495650000,52.7472408482572000 -276.5107199237550000,61.4066248750692000 -274.7174477009240000,70.0054079768411000 -272.6530625242520000,78.5351041927953000 -270.3196016926710000,86.9872957425694000 -267.7193680503000000,95.3536413335489000 -264.8549277138150000,103.6258843927170000 -261.7291075400000000,111.7958612148940000 -258.3449923359800000,119.8555090193290000 -254.7059218148940000,127.7968739066940000 -250.8154872999950000,135.6121187086160000 -246.6775281804520000,143.2935307220230000 -242.2961281223330000,150.8335293206440000 -237.6756110385240000,158.2246734361790000 -232.8205368215440000,165.4596689017280000 -227.7356968434850000,172.5313756502600000 -222.4261092275060000,179.4328147609900000 -216.8970138955490000,186.1571753467370000 -211.1538673971700000,192.6978212754450000 -205.2023375245860000,199.0482977192440000 -199.0482977192440000,205.2023375245860000 -192.6978212754450000,211.1538673971700000 -186.1571753467370000,216.8970138955490000 -179.4328147609900000,222.4261092275060000 -172.5313756502600000,227.7356968434850000 -165.4596689017280000,232.8205368215440000 -158.2246734361790000,237.6756110385240000 -150.8335293206440000,242.2961281223330000 -143.2935307220230000,246.6775281804520000 -135.6121187086160000,250.8154872999950000 -127.7968739066940000,254.7059218148940000 -119.8555090193290000,258.3449923359800000 -111.7958612148940000,261.7291075400000000 -103.6258843927170000,264.8549277138150000 -95.3536413335488000,267.7193680503000000 -86.9872957425693000,270.3196016926710000 -78.5351041927954000,272.6530625242520000 -70.0054079768413000,274.7174477009240000 -61.4066248750690000,276.5107199237550000 -52.7472408482570000,278.0311094495650000 -44.0358016629794000,279.2771158374510000 -35.2809044579671000,280.2475094295410000 -26.4911892597698000,280.9413325645150000 -17.6753304560934000,281.3579005227060000 -8.8420282352253000,281.4968022018320000 -0.0000000000000689))";

//            BaseEffectsModelShapes.AddRange(geoJson.ToGraphic(new SpatialReference(28992)));
//            BaseEffectsModelShapes.AddRange(strWkt.ToGraphic(new SpatialReference(28992)));
//            BaseEffectsModelShapes.ForEach(shape =>
//            {
//                var clone = new Graphic();
//                clone.Geometry = ((Polygon) shape.Geometry).Clone();
//                clone.Symbol = new SimpleFillSymbol
//                {
//                    BorderBrush = new SolidColorBrush(Colors.Black),
//                    BorderThickness = 4,
//                    Fill = new SolidColorBrush(Colors.Red) { Opacity = 0.8f }
//                };
//                clone.Attributes.Add("base", shape);
//                EffectsModelShapes.Add(clone);
//            });
//            ContoursLayer.Graphics.AddRange(EffectsModelShapes);
//            ContoursLayer.Graphics.AddRange(BaseEffectsModelShapes);
            Layer.ChildLayers.Add(ContoursLayer);
            Layer.ChildLayers.Add(MLayer);

            LineSymbol ls = new LineSymbol() { Color = Brushes.Black, Width = 4 };
            Line.Symbol = ls;
            UpdateLine();

            MLayer.Graphics.Add(Line);
            _start.Geometry = start;
            _start.Attributes["position"] = start;

            _start.Symbol = rd["Start"] as Symbol;
            _start.Attributes["finish"] = _finish;
            _start.Attributes["start"] = _start;
            _start.Attributes["line"] = Line;
            _start.Attributes["state"] = "start";
            _start.Attributes["direction"] = this;
            _start.Attributes["menuenabled"] = true;

            MLayer.Graphics.Add(_start);

            _finish.Geometry = finish;
            _finish.Attributes["position"] = finish;
            _finish.Symbol = rd["Finish"] as Symbol;
            _finish.Attributes["finish"] = _finish;
            _finish.Attributes["start"] = _start;
            _finish.Attributes["line"] = Line;
            _finish.Attributes["direction"] = this;
            _finish.Attributes["state"] = "finish";
            MLayer.Graphics.Add(_finish);


            MLayer.Initialize();

            _start.SetZIndex(10);
            _finish.SetZIndex(10);
            Line.SetZIndex(10);

            SettingsViewModel = new EffectsModelSettingsViewModel();
            SettingsViewModel.PropertyChanged += SettingsViewModelOnPropertyChanged;
            SettingsViewModel.Initialize();

            AppStateSettings.Instance.ViewDef.MapManipulationDelta += ViewDef_MapManipulationDelta;

        }
Example #56
0
        // Using a DependencyProperty as the backing store for Folders.  This enables animation, styling, binding, etc...

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            Pdfs = new Queue<FileInfo>();

            if (Execute.InDesignMode) return;
            PresenterLayers = AppStateSettings.Instance.ViewDef.FindOrCreateGroupLayer("Presenter");

            Folders = new ObservableCollection<Folder>();

            if (StartPath != null)
            {
                StartDirectory = new DirectoryInfo(StartPath);
                SelectFolder(StartPath);
            }

            sbBack = GetTemplateChild("Back") as SurfaceButton;
            var sbNext = GetTemplateChild("Next") as SurfaceButton;
            var sbPrevious = GetTemplateChild("Previous") as SurfaceButton;
            IcTitle = GetTemplateChild("icTitle") as ItemsControl;

            if (sbBack != null) sbBack.Click += SbBackClick;

            if (sbNext != null) sbNext.Click += SbNextClick;
            if (sbPrevious != null) sbPrevious.Click += SbPreviousClick;

            UpdateTitle();
        }
Example #57
0
 public static void AddKmlFile(string filePath, GroupLayer curGrLayer)
 {
     var fi = new FileInfo(filePath);
     var kmlLayer = new KmlLayer { Url = new Uri(fi.FullName), ID = fi.Name} ;
     kmlLayer.Initialize();
     kmlLayer.Visible = false;
     curGrLayer.ChildLayers.Add(kmlLayer);
 }
Example #58
0
        public void Init(GroupLayer gl, MapPoint start, MapPoint finish, ResourceDictionary rd)
        {
            startPoint = new csPoint
            {
                Mp = start
            };
            finishPoint = new csPoint
            {
                Mp = finish
            };
            MLayer = new GraphicsLayer
            {
                ID = Guid.NewGuid().ToString()
            };
            _start = new Graphic();
            _finish = new Graphic();
            Line = new Graphic();

            var ls = new LineSymbol
            {
                Color = Brushes.Black,
                Width = 4
            };
            Line.Symbol = ls;
            UpdateLine();

            MLayer.Graphics.Add(Line);

            _start.Geometry = start;
            _start.Symbol = rd["Start"] as Symbol;
            _start.Attributes["position"] = start;
            _start.Attributes["finish"] = _finish;
            _start.Attributes["start"] = _start;
            _start.Attributes["line"] = Line;
            _start.Attributes["state"] = "start";
            _start.Attributes["measure"] = this;
            _start.Attributes["menuenabled"] = true;
            MLayer.Graphics.Add(_start);

            _finish.Geometry = finish;
            _finish.Attributes["position"] = finish;
            _finish.Symbol = rd["Finish"] as Symbol;
            _finish.Attributes["finish"] = _finish;
            _finish.Attributes["start"] = _start;
            _finish.Attributes["line"] = Line;
            _finish.Attributes["measure"] = this;
            _finish.Attributes["state"] = "finish";
            _finish.Attributes["menuenabled"] = true;
            MLayer.Graphics.Add(_finish);

            Layer.ChildLayers.Add(MLayer);
            MLayer.Initialize();

            AppStateSettings.Instance.ViewDef.MapManipulationDelta += ViewDef_MapManipulationDelta;

            if (AppState.Imb != null && AppState.Imb.Imb != null)
            {
                _3d = AppState.Imb.Imb.Publish(AppState.Imb.Imb.ClientHandle + ".3d");
                //AppState.Imb.Imb.Publish(_channel);
            }

            _updateTimer.Interval = 50;
            _updateTimer.Elapsed += UpdateTimerElapsed;
            _updateTimer.Start();
        }
        // Create feature layers from the given geodatabase file
        private async Task CreateFeatureLayersAsync(string gdbPath)
        {
            try
            {
                var gdb = await Geodatabase.OpenAsync(gdbPath);

                if (gdb.FeatureTables.Count() == 0)
                    throw new ApplicationException("Downloaded geodatabase has no feature tables.");

                var groupLayer = MyMapView.Map.Layers["Local_Geodatabase"] as GroupLayer;
                if (groupLayer != null)
                    MyMapView.Map.Layers.Remove(groupLayer);

                groupLayer = new GroupLayer()
                {
                    ID = "Local_Geodatabase",
                    DisplayName = string.Format("Local ({0})", gdbPath)
                };

                Envelope extent = gdb.FeatureTables.First().Extent;
                foreach (var table in gdb.FeatureTables)
                {
                    //if this call is made after FeatureTable is initialized, a call to FeatureLayer.ResetRender will be required.
                    table.UseAdvancedSymbology = true;
                    var flayer = new FeatureLayer()
                    {
                        ID = table.Name,
                        DisplayName = string.Format("{0} ({1})", table.Name, table.RowCount),
                        FeatureTable = table
                    };

                    if (table.Extent != null)
                    {
                        if (extent == null)
                            extent = table.Extent;
                        else
                            extent = extent.Union(table.Extent);
                    }

                    groupLayer.ChildLayers.Add(flayer);
                }

                MyMapView.Map.Layers.Add(groupLayer);

                await MyMapView.SetViewAsync(extent.Expand(1.10));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error creating feature layer: " + ex.Message, "Sample Error");
            }
        }
Example #60
0
        public void Init(GroupLayer gl, MapPoint start, MapPoint finish, ResourceDictionary rd)
        {
            remoteClient.ComputeFieldOfViewAsImageCompleted += ClientOnComputeFieldOfViewCompleted;
            localClient .ComputeFieldOfViewAsImageCompleted += ClientOnComputeFieldOfViewCompleted;

            StartPoint = new csPoint
            {
                Mp = start
            };
            FinishPoint = new csPoint
            {
                Mp = finish
            };
            MLayer = new GraphicsLayer
            {
                ID = Guid.NewGuid().ToString()
            };

            ImageLayer = new ElementLayer();
            Image = new System.Windows.Controls.Image
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
                Stretch = Stretch.Fill,
                StretchDirection = StretchDirection.Both
            };
            ElementLayer.SetEnvelope(Image, AppState.ViewDef.MapControl.Extent);
            ImageLayer.Children.Add(Image);

            Start = new Graphic();
            Finish = new Graphic();
            Line = new Graphic();

            var ls = new LineSymbol
            {
                Color = Brushes.Black,
                Width = 4
            };
            Line.Symbol = ls;
            UpdateLine();

            MLayer.Graphics.Add(Line);

            Start.Geometry = start;
            Start.Symbol = rd["Start"] as Symbol;
            Start.Attributes["position"] = start;
            Start.Attributes["finish"] = Finish;
            Start.Attributes["start"] = Start;
            Start.Attributes["line"] = Line;
            Start.Attributes["state"] = "start";
            Start.Attributes["measure"] = this;
            Start.Attributes["menuenabled"] = true;
            MLayer.Graphics.Add(Start);

            Finish.Geometry = finish;
            Finish.Attributes["position"] = finish;
            Finish.Symbol = rd["Finish"] as Symbol;
            Finish.Attributes["finish"] = Finish;
            Finish.Attributes["start"] = Start;
            Finish.Attributes["line"] = Line;
            Finish.Attributes["measure"] = this;
            Finish.Attributes["state"] = "finish";
            Finish.Attributes["menuenabled"] = true;
            MLayer.Graphics.Add(Finish);
            Layer.ChildLayers.Add(ImageLayer);
            Layer.ChildLayers.Add(MLayer);
            MLayer.Initialize();

            AppStateSettings.Instance.ViewDef.MapManipulationDelta += ViewDef_MapManipulationDelta;

            if (AppState.Imb != null && AppState.Imb.Imb != null)
            {
                _3D = AppState.Imb.Imb.Publish(AppState.Imb.Imb.ClientHandle + ".3d");
                //AppState.Imb.Imb.Publish(_channel);
            }

            updateTimer.Interval = 50;
            updateTimer.Elapsed += UpdateTimerElapsed;
            updateTimer.Start();
        }