コード例 #1
0
        async void LoadGeoDb(EngineeringMap emap)
        {
            string file = ProjDef.LocalFilePath + "\\" + emap.LocalGeoDbFileName;

            if (File.Exists(file))
            {
                Geodatabase gdb = await Geodatabase.OpenAsync(file);

                IEnumerable <GeodatabaseFeatureTable> featureTables =
                    gdb.FeatureTables;
                List <GdbLayer> gdbLayers = new List <GdbLayer>();
                foreach (var table in featureTables)
                {
                    GdbLayer layer = new GdbLayer();
                    layer.Name         = table.Name;
                    layer.Visibility   = false;
                    layer.FeatureTable = table;
                    gdbLayers.Add(layer);

                    LayerDef lyrDef = emap.LocalGdbLayersDef.Find(x => x.Name == table.Name);
                    if (lyrDef == null)
                    {
                        lyrDef = GdbHelper.GenerateDefaultLayerDef(table);
                        emap.LocalGdbLayersDef.Add(lyrDef);
                    }
                    await GdbHelper.addGeodatabaseLayer(Map, lyrDef, table);
                }

                GeoDBLayrList.ItemsSource = gdbLayers;
            }
        }
コード例 #2
0
        // Load the specifiled emap's geodatabase, and add all the features layers to the map.
        //
        async Task ReloadGeoDb(EngineeringMap emap)
        {
            // Clear existing Local GeoDB layers
            if (GeoDBLayrLB.ItemsSource != null)
            {
                foreach (var item in GeoDBLayrLB.ItemsSource)
                {
                    GdbLayer lyr    = item as GdbLayer;
                    Layer    mapLyr = Map.Layers[lyr.Name];
                    if (mapLyr != null)
                    {
                        Map.Layers.Remove(mapLyr);
                    }
                }
                GeoDBLayrLB.ItemsSource = null;
            }

            // Load new
            string file = _projDef.LocalFilePath + "\\" + emap.LocalGeoDbFileName;

            if (File.Exists(file))
            {
                // Open geodatabase
                Geodatabase gdb = await Geodatabase.OpenAsync(file);

                IEnumerable <GeodatabaseFeatureTable> featureTables =
                    gdb.FeatureTables;
                List <GdbLayer> gdbLayers = new List <GdbLayer>();
                foreach (var table in featureTables)
                {
                    // Search LayerDef, use default if not found.
                    LayerDef lyrDef = emap.LocalGdbLayersDef.Find(x => x.Name == table.Name);
                    if (lyrDef == null)
                    {
                        lyrDef = GdbHelper.GenerateDefaultLayerDef(table);
                        emap.LocalGdbLayersDef.Add(lyrDef);
                    }

                    // GdbLayer is used for UI binding and selection operations.
                    GdbLayer layer = new GdbLayer();
                    layer.Name         = table.Name;
                    layer.Visibility   = lyrDef.IsVisible;
                    layer.LayerObject  = layer;
                    layer.FeatureTable = table;
                    layer.Extent       = table.Extent;
                    gdbLayers.Add(layer);


                    // Add the feature layer to the map
                    await GdbHelper.addGeodatabaseLayer(Map, lyrDef, table);
                }

                // Refresh UI
                GeoDBLayrLB.ItemsSource = gdbLayers;
            }
        }