Esempio n. 1
0
        protected override void Execute()
        {
            var point = new Point
            {
                X = Args.X,
                Y = Args.Y
            };

            var dataset = RasterWorkspace.OpenRasterDataset(Args.LayerName);

            var rasterLayer = new RasterLayer();

            rasterLayer.CreateFromDataset(dataset);

            var identify = rasterLayer as IIdentify;
            var results  = identify.Identify(point);

            if (results == null)
            {
                Result = null;
                return;
            }

            var rasterObj = results.Element[0] as IRasterIdentifyObj;

            if (rasterObj == null)
            {
                Result = null;
                return;
            }

            Result = rasterObj.Name;
        }
 public static bool LoadRasterData(string filePath, AxMapControl mapControl)
 {
     try
     {
         var factory = new RasterWorkspaceFactory();
         IRasterWorkspace rasterWorkspace = factory.OpenFromFile(System.IO.Path.GetDirectoryName(filePath), 0) as IRasterWorkspace;
         var            fileName          = System.IO.Path.GetFileName(filePath);
         IRasterDataset rasterDataset     = rasterWorkspace.OpenRasterDataset(fileName);
         if (rasterDataset == null)
         {
             return(false);
         }
         IRasterLayer rasterLayer = new RasterLayer();
         rasterLayer.CreateFromDataset(rasterDataset);
         #region  影像去黑边
         IRasterRGBRenderer2 rasterRGBRender = rasterLayer.Renderer as IRasterRGBRenderer2;
         IRasterStretch2     pRasterStretch2 = rasterRGBRender as IRasterStretch2;
         double[]            value           = new double[3] {
             0.0, 0.0, 0.0
         };
         pRasterStretch2.BackgroundValue = value;
         pRasterStretch2.Background      = true;
         #endregion
         mapControl.AddLayer(rasterLayer, mapControl.LayerCount);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 3
0
        private static byte[] ReproHandler(NameValueCollection boundVariables,
                                           JsonObject operationInput,
                                           string outputFormat,
                                           string requestProperties,
                                           out string responseProperties)
        {
            responseProperties = null;

            // connect to SDE
            var propertySet = new PropertySet();

            propertySet.SetProperty("SERVER", "");
            propertySet.SetProperty("INSTANCE", "");
            propertySet.SetProperty("DATABASE", "");
            propertySet.SetProperty("USER", "");
            propertySet.SetProperty("PASSWORD", "");
            propertySet.SetProperty("VERSION", "sde.DEFAULT");

            var workspaceFactory = new SdeWorkspaceFactory();
            var workspace        = workspaceFactory.Open(propertySet, 0);

            var featureWorkspace = workspace as IRasterWorkspaceEx;

            // open the dem in an SDE Raster Dataset with a Raster Attribute Table
            // our raster table has the schema objectid, value, count, feet
            var featureClass = featureWorkspace.OpenRasterDataset("DEM_10Meter");

            var rasterLayer = new RasterLayer();

            rasterLayer.CreateFromDataset(featureClass);

            var table    = rasterLayer as ITable;
            var identify = rasterLayer as IIdentify;

            // create a point that will intersect your raster
            IPoint point = null;

            var results = identify.Identify(point);
            var item    = results.Element[0] as IRasterIdentifyObj2;

            // this will return 1 for value since object id is 0, count is 2 and feet is 3
            var valueIndex = table.FindField("VALUE");

            string property;
            string value;

            item.GetPropAndValues(valueIndex, out property, out value);

            // when using the index 1, the property will be object id and the value will be the object id
            // when querying for feet, the correct property and value are returned.

            // The correct way
            var    item2 = item as IIdentifyObject;
            object props;
            object values;

            item2.PropertySet.GetAllProperties(out props, out values);

            return(Encoding.UTF8.GetBytes(property + ": " + value));
        }
Esempio n. 4
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            string year  = cbxYear.SelectedItem.ToString();
            string month = cbxMonth.SelectedItem.ToString();

            IWorkspaceFactory pFileGDBWorkspaceFactory;

            pFileGDBWorkspaceFactory = new FileGDBWorkspaceFactory();
            IWorkspace   pWorkspace   = pFileGDBWorkspaceFactory.OpenFromFile(rasterPath, 0);
            IEnumDataset pEnumDataset = pWorkspace.get_Datasets(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTAny);

            pEnumDataset.Reset();
            IDataset  pDataset        = pEnumDataset.Next();
            DataTable SpatialRefTable = new DataTable();

            SpatialRefTable.Columns.Add(new DataColumn("影像名称", typeof(string)));
            SpatialRefTable.Columns.Add(new DataColumn("影像拍摄时间", typeof(string)));

            //判断数据集是否有数据
            while (pDataset != null)
            {
                if (pDataset is IRasterDataset) //栅格数据集
                {
                    IRasterWorkspaceEx pRasterWorkspace = (IRasterWorkspaceEx)pWorkspace;
                    IRasterDataset     pRasterDataset   = pRasterWorkspace.OpenRasterDataset(pDataset.Name);
                    //影像金字塔判断与创建
                    ISpatialReference pSpatialRef = (pRasterDataset as IGeoDataset).SpatialReference;
                    string            spatialref  = pSpatialRef.Name.ToString();
                    string            rastername  = pDataset.Name.ToString();
                    string[]          strArray    = rastername.Split('_');

                    DataRow dr = SpatialRefTable.NewRow();
                    dr["影像名称"]   = pDataset.Name.ToString();
                    dr["影像拍摄时间"] = strArray[1].Substring(0, 8);
                    IRasterLayer pRasterLayer = new RasterLayer();
                    pRasterLayer.CreateFromDataset(pRasterDataset);
                    if (strArray[1].Substring(0, 6) == year + month)
                    {
                        SpatialRefTable.Rows.Add(dr);
                    }
                }
                pDataset = pEnumDataset.Next();
            }
            // ExportExcel(SpatialRefTable);
            //弹出显示框
            FormQueryShowResult timeQuery = new FormQueryShowResult();

            timeQuery.Text = "时间查询";
            timeQuery.dgvQueryResult.DataSource       = SpatialRefTable;
            timeQuery.dgvQueryResult.Columns[1].Width = 200;
            timeQuery.Show();
        }
Esempio n. 5
0
        ///
        /// 打开遥感图像
        ///
        /// 图像的地址
        /// IRasterLayer
        private IRasterLayer OpenImage(string imagePath)
        {
            string ws  = Path.GetDirectoryName(imagePath);
            string fbs = Path.GetFileName(imagePath);

            IWorkspaceFactory pWork          = new RasterWorkspaceFactory();
            IRasterWorkspace  pRasterWs      = pWork.OpenFromFile(ws, 0) as IRasterWorkspace;
            IRasterDataset    pRasterDataset = pRasterWs.OpenRasterDataset(fbs);

            IRasterLayer pRasterLayer = new RasterLayer() as IRasterLayer;

            pRasterLayer.CreateFromDataset(pRasterDataset);
            return(pRasterLayer);
        }
Esempio n. 6
0
        void AddRasterToView(string filePath)
        {
            String dir  = "";
            String name = "";

            FileUtil.ExtractFileNameFromFullPath(filePath, ref dir, ref name);

            IWorkspaceFactory pWorkspaceFactory = new RasterWorkspaceFactory();
            IRasterWorkspace  pRasterWorkspace  = (IRasterWorkspace)pWorkspaceFactory.OpenFromFile(dir, 0);
            IRasterDataset    pRasterDataset    = (IRasterDataset)pRasterWorkspace.OpenRasterDataset(name);
            IRasterLayer      pRasterLayer      = new RasterLayer();

            pRasterLayer.CreateFromDataset(pRasterDataset);
            axMapControl1.Map.AddLayer(pRasterLayer);
            axMapControl1.ActiveView.Refresh();
        }
        public static void readRaster(string path, ref IRasterLayer rasterLayer)
        {
            if (path.Trim() == "")
            {
                return;
            }
            string strFileDirectory = path.Substring(0, path.LastIndexOf('\\'));
            string strFileName      = path.Substring(path.LastIndexOf('\\') + 1);

            IWorkspaceFactory rasterWorkspaceFac = new RasterWorkspaceFactory();
            IRasterWorkspace  rasterWorkspace    = rasterWorkspaceFac.OpenFromFile(strFileDirectory, 0) as IRasterWorkspace;
            IRasterDataset    rasterDataset      = rasterWorkspace.OpenRasterDataset(strFileName);
            IRasterLayer      rasterLayer2       = new RasterLayer();

            rasterLayer2.CreateFromDataset(rasterDataset);
            rasterLayer = rasterLayer2;
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            //ESRI License Initializer generated code.
            m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeAdvanced },
                                                         new esriLicenseExtensionCode[] { });
            //ESRI License Initializer generated code.


            //Get a path to the raster workspace and create a RasterWorkspace object
            Type factoryType = Type.GetTypeFromProgID("esriDataSourcesRaster.RasterWorkspaceFactory");
            IWorkspaceFactory workspaceFactory = Activator.CreateInstance(factoryType) as IWorkspaceFactory;
            IRasterWorkspace2 rasterWorkspace  = (IRasterWorkspace2)workspaceFactory.OpenFromFile("\\\\Filepath\\ToRaster\\Folder", 0);
            IRasterDataset    rasterDataset    = rasterWorkspace.OpenRasterDataset("DEM_Resample.tif");

            //Create a raster layer to get the raster object from it
            IRasterLayer rasterLayer = new RasterLayer();

            rasterLayer.CreateFromDataset(rasterDataset);
            IRaster raster = rasterLayer.Raster;

            //Get the raster properties so we can modify them later and get details about them if we so choose.
            IRasterProps rasterProps = raster as IRasterProps;
            double       cellSize    = 60;

            //Declate a new spatial reference if you want to change the spatial reference used.
            ISpatialReferenceFactory srFactory   = new SpatialReferenceEnvironment();
            ISpatialReference2       srReference = srFactory.CreateProjectedCoordinateSystem(26917) as ISpatialReference2;

            //Create an IRasterGeometryProc object as this has the projectFast method we are looking for.
            IRasterGeometryProc rasterGeometryProc = new RasterGeometryProc();

            rasterGeometryProc.ProjectFast(rasterProps.SpatialReference, rstResamplingTypes.RSP_NearestNeighbor, ((object)cellSize), raster);

            //Create a new rasterBandCollection to store the raster in and save it there.
            IRasterBandCollection rasterBandCollection = raster as IRasterBandCollection;
            String outName = "NewImage.tif";

            String outType = "TIFF";

            rasterBandCollection.SaveAs(outName, ((IWorkspace)rasterWorkspace), outType);

            Console.WriteLine("DONE");
            Console.ReadLine();
            //Do not make any call to ArcObjects after ShutDownApplication()
            m_AOLicenseInitializer.ShutdownApplication();
        }
Esempio n. 9
0
        //添加栅格数据函数
        private void addrasterlayer(string filepath, string filename, AxMapControl mapControl)
        {
            //1.构建工作空间工厂
            IWorkspaceFactory pWF = new RasterWorkspaceFactory();
            //2.利用工厂建立工作空间
            IRasterWorkspace pRW = pWF.OpenFromFile(filepath, 0) as IRasterWorkspace;
            //3.使用工作区打开并得到RasterDataset
            IRasterDataset pRDataset = pRW.OpenRasterDataset(filename);
            //4.把RasterDataset装载到新建的图层实例
            IRasterLayer rasterLay = new RasterLayer(); rasterLay.CreateFromDataset(pRDataset);

            //5.把图层加载到MapControl控件**//MapControl.ClearLayers();//清空原有图层
            mapControl.Map.AddLayer(rasterLay);//or//this.MapControl.Map.AddShapeFile(filepath, filename);//添加图层
            IActiveView activeViw = mapControl.Map as IActiveView;

            activeViw.Extent = mapControl.FullExtent;
            //6.刷新mapcontrol
            mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, rasterLay, null);
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            //ESRI License Initializer generated code.
            m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeAdvanced },
            new esriLicenseExtensionCode[] { });
            //ESRI License Initializer generated code.

            //Get a path to the raster workspace and create a RasterWorkspace object
            Type factoryType = Type.GetTypeFromProgID("esriDataSourcesRaster.RasterWorkspaceFactory");
            IWorkspaceFactory workspaceFactory = Activator.CreateInstance(factoryType) as IWorkspaceFactory;
            IRasterWorkspace2 rasterWorkspace = (IRasterWorkspace2) workspaceFactory.OpenFromFile("\\\\Filepath\\ToRaster\\Folder", 0);
            IRasterDataset rasterDataset = rasterWorkspace.OpenRasterDataset("DEM_Resample.tif");

            //Create a raster layer to get the raster object from it
            IRasterLayer rasterLayer = new RasterLayer();
            rasterLayer.CreateFromDataset(rasterDataset);
            IRaster raster = rasterLayer.Raster;

            //Get the raster properties so we can modify them later and get details about them if we so choose.
            IRasterProps rasterProps = raster as IRasterProps;
            double cellSize = 60;

            //Declate a new spatial reference if you want to change the spatial reference used.
            ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironment();
            ISpatialReference2 srReference = srFactory.CreateProjectedCoordinateSystem(26917) as ISpatialReference2;

            //Create an IRasterGeometryProc object as this has the projectFast method we are looking for.
            IRasterGeometryProc rasterGeometryProc = new RasterGeometryProc();
            rasterGeometryProc.ProjectFast(rasterProps.SpatialReference, rstResamplingTypes.RSP_NearestNeighbor, ((object)cellSize), raster);

            //Create a new rasterBandCollection to store the raster in and save it there.
            IRasterBandCollection rasterBandCollection = raster as IRasterBandCollection;
            String outName = "NewImage.tif";

            String outType = "TIFF";
            rasterBandCollection.SaveAs(outName, ((IWorkspace)rasterWorkspace), outType);

            Console.WriteLine("DONE");
            Console.ReadLine();
            //Do not make any call to ArcObjects after ShutDownApplication()
            m_AOLicenseInitializer.ShutdownApplication();
        }
Esempio n. 11
0
        public void readModelOutput(string InputFileName, string OutputFileName)
        {
            try
            {
                IRasterImportOp pRasterImportOp = new ESRI.ArcGIS.GeoAnalyst.RasterConversionOp() as IRasterImportOp;

                IWorkspaceFactory PRasterWSFact = new RasterWorkspaceFactory() as IWorkspaceFactory;
                IWorkspace        pRasterWS     = PRasterWSFact.OpenFromFile(ArcTimData.StaticClass.infoTable.Rows[0]["ModelPath"].ToString(), 0) as IWorkspace;
                //ImportfromAscii must have an output filename that is less than 8 char
                //the output filename shouldn't have the path with it
                IRasterDataset pRasOut   = pRasterImportOp.ImportFromASCII(InputFileName, pRasterWS, OutputFileName, "GRID", false);
                IRasterLayer   pRasterLy = new RasterLayer();
                pRasterLy.CreateFromDataset(pRasOut);
                IMxDocument pMxDoc = GetMxDocument(m_application);
                pMxDoc.FocusMap.AddLayer(pRasterLy);
                pMxDoc.FocusMap.MoveLayer(pRasterLy, pMxDoc.FocusMap.LayerCount - 1);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            //try
            //{
            //    IWorkspaceFactory pWorkspaceFactory = new RasterWorkspaceFactory() as IWorkspaceFactory;
            //    IRasterWorkspace pRasterworkspace = (IRasterWorkspace)pWorkspaceFactory.OpenFromFile(ArcTim5PropertiesMenu.StaticClass.pathName, 0);

            //    IRasterLayer pRasterLayer = new RasterLayer();
            //    pRasterLayer.CreateFromDataset(pRasterworkspace.OpenRasterDataset(InputFileName));
            //    pRasterLayer.Name = OutputFileName;

            //    IMxDocument pMxDoc = GetMxDocument(m_application);
            //    pMxDoc.FocusMap.AddLayer(pRasterLayer);
            //}
            //catch (Exception ex)
            //{
            //    System.Diagnostics.Debug.WriteLine(ex.Message);
            //}
        }
Esempio n. 12
0
        public static ILayer AddToMap(FileSystemDataset dataset, string sLayerName, IGroupLayer pGroupLayer, List <string> precedingLayers, FileInfo fiSymbologyLayerFile = null, bool bAddToMapIfPresent = false, short transparency = 0, string definition_query = "")
        {
            if (!dataset.Exists)
            {
                return(null);
            }

            // Only add if it doesn't exist already
            ILayer pResultLayer = GetLayerBySource(dataset.Path);

            if ((pResultLayer is ILayer && string.Compare(pResultLayer.Name, sLayerName, true) == 0) && !bAddToMapIfPresent)
            {
                return(pResultLayer);
            }

            // Confirm that the symbology layer file exists
            if (fiSymbologyLayerFile != null && !fiSymbologyLayerFile.Exists)
            {
                Exception ex = new Exception("A symbology layer file was provided, but the file does not exist");
                ex.Data["Data Source"] = dataset.Path.FullName;
                ex.Data["Layer file"]  = fiSymbologyLayerFile.FullName;
                throw ex;
            }

            IWorkspace pWorkspace = GetWorkspace(dataset);

            switch (dataset.WorkspaceType)
            {
            case FileSystemDataset.GISDataStorageTypes.RasterFile:
                IRasterDataset pRDS      = ((IRasterWorkspace)pWorkspace).OpenRasterDataset(Path.GetFileName(dataset.Path.FullName));
                IRasterLayer   pRLResult = new RasterLayer();
                pRLResult.CreateFromDataset(pRDS);
                pResultLayer = pRLResult;
                break;

            case FileSystemDataset.GISDataStorageTypes.CAD:
                string        sFile = Path.GetFileName(Path.GetDirectoryName(dataset.Path.FullName));
                string        sFC   = sFile + ":" + Path.GetFileName(dataset.Path.FullName);
                IFeatureClass pFC   = ((IFeatureWorkspace)pWorkspace).OpenFeatureClass(sFC);
                pResultLayer = new FeatureLayer();
                ((IFeatureLayer)pResultLayer).FeatureClass = pFC;
                break;

            case FileSystemDataset.GISDataStorageTypes.ShapeFile:
                IFeatureWorkspace pWS        = (IFeatureWorkspace)ArcMapUtilities.GetWorkspace(dataset);
                IFeatureClass     pShapeFile = pWS.OpenFeatureClass(Path.GetFileNameWithoutExtension(dataset.Path.FullName));
                pResultLayer = new FeatureLayer();
                ((IFeatureLayer)pResultLayer).FeatureClass = pShapeFile;
                break;

            case FileSystemDataset.GISDataStorageTypes.TIN:
                ITin pTIN = ((ITinWorkspace)pWorkspace).OpenTin(System.IO.Path.GetFileName(dataset.Path.FullName));
                pResultLayer = new TinLayer();
                ((ITinLayer)pResultLayer).Dataset = pTIN;
                pResultLayer.Name = dataset.Name;
                break;

            case FileSystemDataset.GISDataStorageTypes.GeoPackage:
                IFeatureWorkspace pGPKGWS = (IFeatureWorkspace)ArcMapUtilities.GetWorkspace(dataset);
                IFeatureClass     pGPKGFC = pGPKGWS.OpenFeatureClass(System.IO.Path.GetFileName(dataset.Path.FullName));
                pResultLayer = new FeatureLayer();
                ((IFeatureLayer)pResultLayer).FeatureClass = pGPKGFC;
                break;

            default:
                Exception ex = new Exception("Unhandled GIS dataset type");
                ex.Data["FullPath Path"] = dataset.Path.FullName;
                ex.Data["Storage Type"]  = dataset.WorkspaceType.ToString();
                throw ex;
            }

            if (!string.IsNullOrEmpty(sLayerName))
            {
                pResultLayer.Name = sLayerName;
            }

            try
            {
                ApplySymbology(pResultLayer, fiSymbologyLayerFile);
            }
            catch (Exception ex)
            {
                if (ex.Message.ToLower().Contains("symbology"))
                {
                    System.Diagnostics.Debug.Print(ex.Message);
                    // DO Nothing
                }
                else
                {
                    throw;
                }
            }

            try
            {
                if (pResultLayer is IFeatureLayer && !string.IsNullOrEmpty(definition_query))
                {
                    ApplyDefinitionquery((IFeatureLayer)pResultLayer, definition_query);
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.ToLower().Contains("symbology"))
                {
                    System.Diagnostics.Debug.Print(ex.Message);
                    // DO Nothing
                }
                else
                {
                    throw;
                }
            }

            if (transparency > 0)
            {
                ILayerEffects pLayerEffects = (ILayerEffects)pResultLayer;
                pLayerEffects.Transparency = transparency;
            }

            if (pGroupLayer == null)
            {
                ((IMapLayers)ArcMap.Document.FocusMap).InsertLayer(pResultLayer, false, 0);
            }
            else
            {
                int layerIndex = 0;
                foreach (string name in precedingLayers)
                {
                    // Try and find the preceding layer already in the hierarchy
                    ICompositeLayer pCompositeLayer = (ICompositeLayer)pGroupLayer;
                    for (int i = 0; i <= pCompositeLayer.Count - 1; i++)
                    {
                        if (string.Compare(pCompositeLayer.Layer[i].Name, name, true) == 0)
                        {
                            layerIndex++;
                        }
                    }
                }

                ((IMapLayers)ArcMap.Document.FocusMap).InsertLayerInGroup(pGroupLayer, pResultLayer, false, layerIndex);
            }

            ArcMap.Document.UpdateContents();
            ArcMap.Document.ActiveView.Refresh();
            ArcMap.Document.CurrentContentsView.Refresh(null);

            return(pResultLayer);
        }
        /// <summary>
        /// Add Raster Layer for the result of Extract textlayer
        /// </summary>
        /// <param name="path"></param>
        /// <param name="fileName"></param>
        public void AddRasterLayer(string path, string fileName)
        {
            IMap map = ArcMap.Document.FocusMap;

            try
            {

                IWorkspaceFactory workspaceFactory = new RasterWorkspaceFactory();
                IRasterWorkspace rasterWorkspace = (ESRI.ArcGIS.DataSourcesRaster.IRasterWorkspace)(workspaceFactory.OpenFromFile(path, 0));
                IRasterDataset rasterDataset = rasterWorkspace.OpenRasterDataset(fileName);
                IGeoDataset geoDataset = (ESRI.ArcGIS.Geodatabase.IGeoDataset)rasterDataset;
                // Create a raster for viewing
                IRasterLayer rasterLayer = new RasterLayer();

                rasterLayer.CreateFromDataset(rasterDataset);

                // Add the raster to the map
                map.AddLayer(rasterLayer);

            }
            catch (System.Exception ex)
            {
                Log.WriteLine("AddRasterLayer: " + ex.Message);
            }
        }
Esempio n. 14
0
        public static bool AddDataset(IBasicMap pBasicMap, IDatasetName pDatasetName, Collection <object> m_DatasetCol, bool blnAddData)
        {
            bool functionReturnValue = false;

            functionReturnValue = false;
            ////如果是特征数据集,则添加里边的所有要素类
            IFeatureDataset pFeatDS      = default(IFeatureDataset);
            IEnumDataset    pEnumDataSet = default(IEnumDataset);
            IDataset        pDataset     = default(IDataset);
            IFeatureClass   pFeatCls     = default(IFeatureClass);
            IFeatureLayer   pFeatLayer   = default(IFeatureLayer);
            IName           pName        = default(IName);
            ILayer          pLayer       = default(ILayer);
            ITopologyLayer  pTopoLayer   = default(ITopologyLayer);
            //Dim pEnumLyr As IEnumLayer
            ITinWorkspace              pTinWS            = default(ITinWorkspace);
            IEnumFeatureClass          pEnumFeatCls      = null;
            IRasterCatalogDisplayProps pRasterCatalogPro = default(IRasterCatalogDisplayProps);

            //ClsErrorHandle pfrmError = new ClsErrorHandle();
            //ClsLayerRender pLayerRender = null;


            if (pDatasetName is IFeatureDatasetName)
            {
                pName   = pDatasetName as IName;
                pFeatDS = pName.Open() as IFeatureDataset;

                pEnumDataSet = pFeatDS.Subsets;
                pDataset     = pEnumDataSet.Next();

                m_DatasetCol.Add(pDataset);
                if (pDataset == null)
                {
                    return(false);
                }
                ////根据数据集的类型,添加特征数据集中的所有要素类(拓扑,一般的,栅格目录,网络)
                while ((pDataset != null))
                {
                    if (pDataset.Type == esriDatasetType.esriDTFeatureClass)
                    {
                        //pLayerRender = new ClsLayerRender();
                        //// 陈昉  2008-12-3  修改 修改原因 添加SDE图层时从数据库读取符号化信息
                        //pFeatLayer = null;
                        //if (pDataset.Workspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
                        //{
                        //    pFeatLayer = pLayerRender.GetRendererLayer((IFeatureClass)pDataset);
                        //}
                        if (pFeatLayer == null)
                        {
                            pFeatLayer              = new FeatureLayer();
                            pFeatCls                = pDataset as IFeatureClass;
                            pFeatLayer.Name         = pFeatCls.AliasName;
                            pFeatLayer.FeatureClass = pFeatCls;
                        }

                        if (pDataset.Type == esriDatasetType.esriDTRasterCatalog)
                        {
                            // Dim pRaster
                        }

                        if (blnAddData == true)
                        {
                            //pMap.AddLayer pFeatLayer
                            AddLyrToBasicMap(pBasicMap, pFeatLayer);
                            SortLayer(pBasicMap, pFeatLayer);
                        }
                        // pSelectedCln.Add(pFeatLayer)
                    }
                    else if (pDataset.Type == esriDatasetType.esriDTTopology)
                    {
                        pTopoLayer          = new TopologyLayer() as ITopologyLayer;
                        pTopoLayer.Topology = pDataset as ITopology;
                        pLayer      = pTopoLayer as ILayer;
                        pLayer.Name = pDataset.Name;

                        if (blnAddData == true)
                        {
                            //pMap.AddLayer pLayer
                            AddLyrToBasicMap(pBasicMap, pLayer);
                            SortLayer(pBasicMap, pLayer);
                        }
                        //pSelectedCln.Add(pFeatLayer)
                    }

                    pDataset = pEnumDataSet.Next();
                }
                functionReturnValue = true;


                ////添加拓扑图层
            }
            else if (pDatasetName is ITopologyName)
            {
                ITopology pTopo = null;
                pName               = pDatasetName as IName;
                pDataset            = pName.Open() as IDataset;
                pTopoLayer          = new TopologyLayer() as ITopologyLayer;
                pTopoLayer.Topology = pDataset as ITopology;
                pLayer              = pTopoLayer as ILayer;
                pLayer.Name         = pDataset.Name;
                m_DatasetCol.Add(pDataset);
                if (blnAddData == true)
                {
                    //pMap.AddLayer pLayer
                    AddLyrToBasicMap(pBasicMap, pLayer);
                    SortLayer(pBasicMap, pLayer);
                }
                //pSelectedCln.Add(pLayer)

                if (MessageBox.Show("要把拓扑里边的所有要素类也添加到当前地图中吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                    == DialogResult.Yes)
                {
                    IFeatureClassContainer pFeatClsContainer = default(IFeatureClassContainer);
                    pFeatClsContainer = pTopo as IFeatureClassContainer;
                    pEnumFeatCls      = pFeatClsContainer.Classes;
                    pFeatCls          = pEnumFeatCls.Next();
                    pFeatLayer        = new FeatureLayer();

                    ////循环拓扑中的每个要素类,并添加到当前地图中
                    while ((pFeatCls != null))
                    {
                        pFeatLayer.FeatureClass = pFeatCls;
                        pFeatLayer.Name         = pFeatCls.AliasName;

                        if (blnAddData == true)
                        {
                            //pMap.AddLayer pFeatLayer
                            AddLyrToBasicMap(pBasicMap, pFeatLayer);
                            SortLayer(pBasicMap, pFeatLayer);
                        }
                        //pSelectedCln.Add(pFeatLayer)

                        pFeatCls = pEnumFeatCls.Next();
                    }
                }
                functionReturnValue = true;
                ////添加网络数据
            }
            else if (pDatasetName is IGeometricNetworkName)
            {
                INetworkCollection pNetworkCollection = default(INetworkCollection);
                IGeometricNetwork  pGeometricNetwork  = default(IGeometricNetwork);

                IDataset pGeoDataset = default(IDataset);

                pName       = pDatasetName as IName;
                pGeoDataset = pName.Open() as IDataset;
                m_DatasetCol.Add(pGeoDataset);
                if (pGeoDataset.Type == esriDatasetType.esriDTGeometricNetwork)
                {
                    ////这里对网络数据进行处理
                    IFeatureClassContainer pFeatureClassContainer = null;
                    pGeometricNetwork      = pGeoDataset as IGeometricNetwork;
                    pFeatureClassContainer = pGeometricNetwork as IFeatureClassContainer;

                    for (int i = 0; i < pFeatureClassContainer.ClassCount; i++)
                    {
                        pFeatCls                = pFeatureClassContainer.get_Class(i);
                        pFeatLayer              = new FeatureLayer();
                        pFeatLayer.Name         = pFeatCls.AliasName;
                        pFeatLayer.FeatureClass = pFeatCls;

                        if (blnAddData == true)
                        {
                            // pMap.AddLayer pFeatLayer
                            AddLyrToBasicMap(pBasicMap, pFeatLayer);
                            SortLayer(pBasicMap, pFeatLayer);
                        }
                        //pSelectedCln.Add(pFeatLayer)
                    }
                }
                else
                {
                    pFeatDS            = pGeoDataset as IFeatureDataset;
                    pNetworkCollection = pFeatDS as INetworkCollection;
                    ////如果是用户选择一个网络技术打开的话,肯定只有一个网络在里边,其实
                    ////可以不需要循环,而用GeometricNetwork(0)代替循环
                    for (int j = 0; j < pNetworkCollection.GeometricNetworkCount; j++)
                    {
                        pGeometricNetwork = pNetworkCollection.get_GeometricNetwork(j);
                        for (int i = 0; i <= 3; i++)
                        {
                            switch (i)
                            {
                            case 0:
                                pEnumFeatCls = pGeometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleJunction);
                                break;

                            case 1:
                                pEnumFeatCls = pGeometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleEdge);
                                break;

                            case 2:
                                pEnumFeatCls = pGeometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexJunction);
                                break;

                            case 3:
                                pEnumFeatCls = pGeometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexEdge);
                                break;
                            }
                            pFeatCls = pEnumFeatCls.Next();
                            while ((pFeatCls != null))
                            {
                                pFeatLayer              = new FeatureLayer();
                                pFeatLayer.Name         = pFeatCls.AliasName;
                                pFeatLayer.FeatureClass = pFeatCls;
                                pFeatCls = pEnumFeatCls.Next();

                                if (blnAddData == true)
                                {
                                    //pMap.AddLayer pFeatLayer
                                    AddLyrToBasicMap(pBasicMap, pFeatLayer);
                                    SortLayer(pBasicMap, pFeatLayer);
                                }
                                // pSelectedCln.Add(pFeatLayer)

                                functionReturnValue = true;
                            }
                        }
                    }
                }

                ////添加栅格目录,并设置为显示最新时相
            }
            else if (pDatasetName is IRasterCatalogName)
            {
                pName    = pDatasetName as IName;
                pDataset = pName.Open() as IDataset;
                m_DatasetCol.Add(pDataset);
                pFeatLayer = new GdbRasterCatalogLayer() as IFeatureLayer;
                pFeatLayer.FeatureClass = pDataset as IFeatureClass;
                pFeatLayer.Name         = pDataset.Name;

                //'//如果是SDE的栅格目录
                //If pFeatLayer.DataSourceType = "SDE Raster Catalog" Then

                //    Dim pFeatLayerDef As IFeatureLayerDefinition
                //    pFeatLayerDef = pFeatLayer

                //    '//设置最初显示地图范围内最近时相的数据
                //    pFeatLayerDef.DefinitionExpression = "objectid in (select objectid from" & vbNewLine & _
                //        "(select a.objectid, b.receive_date,rank()" & vbNewLine & _
                //        "over(partition by a.name,a.resolution order by b.receive_date desc) as cid" & vbNewLine & _
                //        "from " & pFeatLayer.Name & " a, sj_t_tense b" & vbNewLine & _
                //        "where a.tense = b.tense" & vbNewLine & "and b.online_state = 1) t2" & vbNewLine & _
                //        "where " & pFeatLayer.Name & ".objectid=t2.objectid and t2.cid = 1)"

                //End If
                ////设置当栅格目录中的图幅在地图上超过16个的时候,以格网来显示,而不显示栅格本身
                pRasterCatalogPro = pFeatLayer as IRasterCatalogDisplayProps;
                ////不用数量来控制了,而以比例尺来控制
                pRasterCatalogPro.DisplayRasters = 16;
                pRasterCatalogPro.UseScale       = true;
                ////设置一个比例,在此临界栅格数据将会在框架显示与实际栅格显示之间转换
                pRasterCatalogPro.TransitionScale = 50000;

                if (blnAddData == true)
                {
                    //pMap.AddLayer pFeatLayer
                    AddLyrToBasicMap(pBasicMap, pFeatLayer);
                    //SortLayer(pBasicMap, pFeatLayer)
                }
                //pSelectedCln.Add(pFeatLayer)
                functionReturnValue = true;
            }
            else if (pDatasetName is IRasterDatasetName)
            {
                IRasterLayer pRasterLayer = default(IRasterLayer);
                pName    = pDatasetName as IName;
                pDataset = pName.Open() as IDataset;
                m_DatasetCol.Add(pDataset);
                pRasterLayer = new RasterLayer();
                pRasterLayer.CreateFromDataset((IRasterDataset)pDataset);
                pRasterLayer.Name = pDataset.Name;
                AddLyrToBasicMap(pBasicMap, pRasterLayer);
                functionReturnValue = true;
                ////添加TIN图层
            }
            else if (pDatasetName is ITinWorkspace)
            {
                pTinWS = pDatasetName as ITinWorkspace;
                ITinLayer pTinLyr = default(ITinLayer);
                pTinLyr         = new TinLayer();
                pTinLyr.Dataset = pTinWS.OpenTin(pDatasetName.Name);
                pTinLyr.Name    = pDatasetName.Name;

                if (blnAddData == true)
                {
                    //pMap.AddLayer pTinLyr
                    AddLyrToBasicMap(pBasicMap, pTinLyr);
                    SortLayer(pBasicMap, pTinLyr);
                }
                //pSelectedCln.Add(pTinLyr)
                functionReturnValue = true;
            }
            else if (pDatasetName is INetworkDatasetName)
            {
                //Dim pNetWorkDS As INetworkDataset
                try
                {
                    INetworkLayer pNetLayer = default(INetworkLayer);

                    pName     = pDatasetName as IName;
                    pNetLayer = new NetworkLayer() as INetworkLayer;
                    pNetLayer.NetworkDataset = pName.Open() as INetworkDataset;
                    pLayer      = pNetLayer as ILayer;
                    pLayer.Name = pName.NameString;
                    if (blnAddData == true)
                    {
                        AddLyrToBasicMap(pBasicMap, pLayer);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                ////添加一般的要素类,未写完。。。。。。
            }
            else
            {
                pName    = pDatasetName as IName;
                pDataset = pName.Open() as IDataset;
                pFeatCls = pDataset as IFeatureClass;
                m_DatasetCol.Add(pDataset);
                if (pFeatCls.FeatureType == esriFeatureType.esriFTAnnotation)
                {
                    pFeatLayer = new FDOGraphicsLayer() as IFeatureLayer;
                }
                else if (pFeatCls.FeatureType == esriFeatureType.esriFTDimension)
                {
                    pFeatLayer = new DimensionLayer() as IFeatureLayer;
                }
                else
                {
                    pFeatLayer = new FeatureLayer();
                    //pLayerRender = new ClsLayerRender();
                    //// 陈昉  2008-12-3  修改 修改原因 添加SDE图层时从数据库读取符号化信息
                    //if (pDataset.Workspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
                    //{
                    //    pFeatLayer = pLayerRender.GetRendererLayer((IFeatureClass)pDataset);
                    //}
                }
                //印骅 20081205 添加"Not"
                if ((pFeatLayer != null))
                {
                    //pFeatLayer.Name = pDataset.Name
                    pFeatLayer.Name         = pFeatCls.AliasName;
                    pFeatLayer.FeatureClass = pDataset as IFeatureClass;
                }
                if (blnAddData == true)
                {
                    //pMap.AddLayer pFeatLayer

                    AddLyrToBasicMap(pBasicMap, pFeatLayer);
                    SortLayer(pBasicMap, pFeatLayer);
                }
                //pSelectedCln.Add(pFeatLayer)

                functionReturnValue = true;
            }

            return(functionReturnValue);

            //'//添加Coverage图层
            //ElseIf vItem.SmallIcon = "Coverage" Then
            //AddSelectedLayer = ADDCoverageLayer(pMap, pCurrentFilePath.Path, _
            //vItem.Text, pSelectedCln, blnAddData)
        }
Esempio n. 15
0
        /// <summary>
        /// 执行地图代数运算
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks></remarks>

        private void Button_OK_Click(System.Object sender, System.EventArgs e)
        {
            IRasterLayer pRasLayer = default(IRasterLayer);
            IRaster      pRaster   = default(IRaster);

            IEnvelope layExtend            = default(IEnvelope);
            double    AnalysisExtentLeft   = 0;
            double    AnalysisExtentRight  = 0;
            double    AnalysisExtentTop    = 0;
            double    AnalysisExtentBottom = 0;

            string layerNameFir = null;

            try
            {
                if (LayerList.Count != 0)
                {
                    if (textBox_Result.Text.ToString().Length != 0)
                    {
                        layerNameFir = LayerList[0].ToString();

                        layExtend            = GetLayerExtend(layerNameFir);
                        AnalysisExtentLeft   = layExtend.XMin;
                        AnalysisExtentRight  = layExtend.XMax;
                        AnalysisExtentTop    = layExtend.YMax;
                        AnalysisExtentBottom = layExtend.YMin;

                        pMapAlgebraOp = new RasterMapAlgebraOp() as IMapAlgebraOp;
                        //设置栅格计算分析环境
                        IRasterAnalysisEnvironment pRasAnaEnv = default(IRasterAnalysisEnvironment);
                        pRasAnaEnv            = (IRasterAnalysisEnvironment)pMapAlgebraOp;
                        pRasAnaEnv.VerifyType = esriRasterVerifyEnum.esriRasterVerifyOn;

                        object dddd;
                        dddd = GetRasterCellSize(layerNameFir);
                        pRasAnaEnv.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, ref dddd);
                        //设置分析范围pAnaExtent
                        IEnvelope pAnaExtent = default(IEnvelope);
                        pAnaExtent = new Envelope() as IEnvelope;

                        pAnaExtent.XMin = Convert.ToDouble(AnalysisExtentLeft);
                        pAnaExtent.XMax = Convert.ToDouble(AnalysisExtentRight);
                        pAnaExtent.YMax = Convert.ToDouble(AnalysisExtentTop);
                        pAnaExtent.YMin = Convert.ToDouble(AnalysisExtentBottom);

                        object dd1 = pAnaExtent;
                        object dd2 = null;


                        pRasAnaEnv.SetExtent(esriRasterEnvSettingEnum.esriRasterEnvValue, ref dd1, ref dd2);

                        foreach (string LayerName in LayerList)
                        {
                            pRasLayer = (IRasterLayer)FindLayerByName(pCurMap, LayerName);
                            //MsgBox(LayerName)
                            pRaster = pRasLayer.Raster;
                            RasterList.Add(pRaster);
                        }
                        //将容量设置为 ArrayList 中元素的实际数目
                        LayerList.TrimToSize();
                        RasterList.TrimToSize();

                        //绑定
                        int i = 0;
                        if (LayerList.Count == RasterList.Count)
                        {
                            for (i = 0; i <= LayerList.Count - 1; i++)
                            {
                                pMapAlgebraOp.BindRaster((IGeoDataset)RasterList[i], LayerList[i].ToString());
                            }
                        }


                        //获取文本框中的运算表达式()
                        string sCalExpression = null;
                        sCalExpression = textBox_Calculate.Text;
                        //执行地图代数运算
                        IRaster pOutRasterDS = default(IRaster);
                        pOutRasterDS = (IRaster)pMapAlgebraOp.Execute(sCalExpression);

                        //解除绑定
                        if (LayerList.Count == RasterList.Count)
                        {
                            for (i = 0; i <= LayerList.Count - 1; i++)
                            {
                                pMapAlgebraOp.UnbindRaster(LayerList[i].ToString());
                            }
                        }


                        //保存到工作空间
                        IWorkspaceFactory pWsFact = default(IWorkspaceFactory);
                        IWorkspace        pWS     = default(IWorkspace);
                        int hwnd = 0;
                        pWsFact = new RasterWorkspaceFactory();
                        pWS     = pWsFact.OpenFromFile(sOutRasPath, hwnd);
                        IRasterBandCollection pRasterbandCollection = default(IRasterBandCollection);

                        pRasterbandCollection = (IRasterBandCollection)pOutRasterDS;
                        IDataset pDataset = default(IDataset);

                        pDataset = pRasterbandCollection.SaveAs(sOutRasName, pWS, "IMAGINE Image");

                        //输出到mapcontrol中
                        IRasterDataset pOutResultDS = default(IRasterDataset);
                        pOutResultDS = (IRasterDataset)pDataset;
                        IRasterLayer pOutRasterLayer = default(IRasterLayer);
                        pOutRasterLayer = new RasterLayer();
                        pOutRasterLayer.CreateFromDataset(pOutResultDS);
                        //MapControlMain.AddLayer(pOutRasterLayer)
                        pCurMap.AddLayer(pOutRasterLayer);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("保存计算结果为空,请输入结果文件名!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                //Interaction.MsgBox(ex.ToString);
            }
        }
Esempio n. 16
0
        public static ILayer AddToMap(FileSystemInfo fiFullPath, string sLayerName = "", string sGroupLayer = "", FileInfo fiSymbologyLayerFile = null, bool bAddToMapIfPresent = false)
        {
            if (!fiFullPath.Exists)
            {
                return(null);
            }

            // Only add if it doesn't exist already
            ILayer pResultLayer = GetLayerBySource(fiFullPath);

            if (pResultLayer is ILayer && !bAddToMapIfPresent)
            {
                return(pResultLayer);
            }

            // Confirm that the symbology layer file exists
            if (fiSymbologyLayerFile != null && !fiSymbologyLayerFile.Exists)
            {
                Exception ex = new Exception("A symbology layer file was provided, but the file does not exist");
                ex.Data["Data Source"] = fiFullPath.FullName;
                ex.Data["Layer file"]  = fiSymbologyLayerFile.FullName;
                throw ex;
            }

            ArcMapBrowse.GISDataStorageTypes eStorageType = GetWorkspaceType(fiFullPath.FullName);
            IWorkspace pWorkspace = GetWorkspace(fiFullPath);

            switch (eStorageType)
            {
            case ArcMapBrowse.GISDataStorageTypes.RasterFile:
                IRasterDataset pRDS      = ((IRasterWorkspace)pWorkspace).OpenRasterDataset(fiFullPath.Name);
                IRasterLayer   pRLResult = new RasterLayer();
                pRLResult.CreateFromDataset(pRDS);
                pResultLayer = pRLResult;
                break;

            case ArcMapBrowse.GISDataStorageTypes.CAD:
                string        sFile = Path.GetFileName(Path.GetDirectoryName(fiFullPath.FullName));
                string        sFC   = sFile + ":" + Path.GetFileName(fiFullPath.FullName);
                IFeatureClass pFC   = ((IFeatureWorkspace)pWorkspace).OpenFeatureClass(sFC);
                pResultLayer = new FeatureLayer();
                ((IFeatureLayer)pResultLayer).FeatureClass = pFC;
                break;

            case ArcMapBrowse.GISDataStorageTypes.ShapeFile:
                IFeatureClass pShapeFile = ((IFeatureWorkspace)pWorkspace).OpenFeatureClass(fiFullPath.FullName);
                pResultLayer = new FeatureLayer();
                ((IFeatureLayer)pResultLayer).FeatureClass = pShapeFile;
                break;

            case ArcMapBrowse.GISDataStorageTypes.TIN:
                ITin pTIN = ((ITinWorkspace)pWorkspace).OpenTin(fiFullPath.FullName);
                pResultLayer = new TinLayer();
                ((ITinLayer)pResultLayer).Dataset = pTIN;
                pResultLayer.Name = fiFullPath.Name;
                break;

            default:
                Exception ex = new Exception("Unhandled GIS dataset type");
                ex.Data["FullPath Path"] = fiFullPath.FullName;
                ex.Data["Storage Type"]  = eStorageType.ToString();
                throw ex;
            }

            if (!string.IsNullOrEmpty(sLayerName))
            {
                pResultLayer.Name = sLayerName;
            }

            if (string.IsNullOrEmpty(sGroupLayer))
            {
                ((IMapLayers)ArcMap.Document.FocusMap).InsertLayer(pResultLayer, true, 0);
            }
            else
            {
                IGroupLayer pGrpLayer = GetGroupLayer(sGroupLayer);
                ((IMapLayers)ArcMap.Document.FocusMap).InsertLayerInGroup(pGrpLayer, pResultLayer, true, 0);
            }

            ArcMap.Document.UpdateContents();
            ArcMap.Document.ActiveView.Refresh();
            ArcMap.Document.CurrentContentsView.Refresh(null);

            return(pResultLayer);
        }
Esempio n. 17
0
        private static void AddRasterLayer(Raster gRaster, IRasterRenderer rasterRenderer, string sRasterName, IGroupLayer pGrpLyr, string sHeader = null, short fTransparency = -1, bool ExpandLegend = true)
        {
            if (pGrpLyr != null)
            {
                IRasterLayer pResultLayer = ArcMapUtilities.IsRasterLayerInGroupLayer(gRaster.GISFileInfo, pGrpLyr);
                if (pResultLayer is ILayer)
                {
                    return;
                }
            }

            IRasterLayer   rasterLayer = new RasterLayer();
            IRasterDataset pRDS        = ArcMapUtilities.GetRasterDataset(gRaster);

            rasterLayer.CreateFromDataset(pRDS);
            if (rasterRenderer != null)
            {
                rasterLayer.Renderer = rasterRenderer;
            }

            if (rasterLayer != null)
            {
                IMapLayers pMapLayers = (IMapLayers)ArcMap.Document.FocusMap;
                if (!string.IsNullOrEmpty(sRasterName))
                {
                    rasterLayer.Name = sRasterName;
                }

                if (!string.IsNullOrEmpty(sHeader))
                {
                    ESRI.ArcGIS.Carto.ILegendInfo pLegend = (ESRI.ArcGIS.Carto.ILegendInfo)rasterLayer;
                    pLegend.LegendGroup[0].Heading = sHeader;
                }

                if (fTransparency >= 0)
                {
                    ILayerEffects pLayerEffects = (ILayerEffects)rasterLayer;
                    pLayerEffects.Transparency = fTransparency;
                }

                if (pGrpLyr == null)
                {
                    pMapLayers.InsertLayer(rasterLayer, false, 0);
                }
                else
                {
                    pMapLayers.InsertLayerInGroup(pGrpLyr, rasterLayer, false, 0);
                }

                // Collapse or expand the legend in the ToC (e.g. Hillshade should be collapsed)
                ((ILegendGroup)((ILegendInfo)rasterLayer).LegendGroup[0]).Visible = ExpandLegend;
            }

            int refsLeft = 0;

            do
            {
                refsLeft = System.Runtime.InteropServices.Marshal.ReleaseComObject(pRDS);
            }while (refsLeft > 0);

            refsLeft = 0;
            do
            {
                refsLeft = System.Runtime.InteropServices.Marshal.ReleaseComObject(rasterLayer);
            }while (refsLeft > 0);
        }
Esempio n. 18
0
        public void LoadData(IList ilist_0)
        {
            try
            {
                List <ILayer> list = new List <ILayer>();
                for (int i = 0; i < ilist_0.Count; i++)
                {
                    if (ilist_0[i] is IGxLayer)
                    {
                        list.Add((ilist_0[i] as IGxLayer).Layer);
                    }
                    else
                    {
                        IGxDataset gxDataset = ilist_0[i] as IGxDataset;
                        if (gxDataset != null)
                        {
                            IDataset dataset = gxDataset.Dataset;
                            if (dataset != null)
                            {
                                if (dataset.Type == esriDatasetType.esriDTFeatureClass)
                                {
                                    IFeatureClass featureClass = (IFeatureClass)dataset;
                                    IFeatureLayer featureLayer;
                                    if ((gxDataset as IGxObject).Category.IndexOf("CAD") != -1)
                                    {
                                        if (featureClass.FeatureType == esriFeatureType.esriFTCoverageAnnotation)
                                        {
                                            featureLayer = new CadAnnotationLayer() as IFeatureLayer;
                                        }
                                        else
                                        {
                                            featureLayer = new CadFeatureLayer() as IFeatureLayer;
                                        }
                                        featureLayer.FeatureClass = featureClass;
                                        featureLayer.Name         = featureClass.AliasName;
                                    }
                                    else if (featureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                                    {
                                        featureLayer = new FDOGraphicsLayer() as IFeatureLayer;
                                        featureLayer.FeatureClass = featureClass;
                                        featureLayer.Name         = featureClass.AliasName;
                                    }
                                    else if (featureClass.FeatureType == esriFeatureType.esriFTDimension)
                                    {
                                        featureLayer = new DimensionLayer() as IFeatureLayer;
                                        featureLayer.FeatureClass = featureClass;
                                        featureLayer.Name         = featureClass.AliasName;
                                    }
                                    else
                                    {
                                        featureLayer = new FeatureLayer();
                                        featureLayer.FeatureClass = featureClass;
                                        featureLayer.Name         = featureClass.AliasName;
                                    }
                                    list.Add(featureLayer);
                                }
                                else if (dataset.Type == esriDatasetType.esriDTCadDrawing)
                                {
                                    if ((gxDataset as IGxObject).Category == "CAD绘图")
                                    {
                                        ICadLayer item = new CadLayer() as ICadLayer;
                                        item.CadDrawingDataset = gxDataset.Dataset as ICadDrawingDataset;
                                        item.Name = gxDataset.Dataset.Name;
                                        list.Add(item);
                                    }
                                    else
                                    {
                                        IEnumGxObject children = (gxDataset as IGxObjectContainer).Children;
                                        children.Reset();
                                        for (IGxDataset gxDataset2 = children.Next() as IGxDataset; gxDataset2 != null; gxDataset2 = (children.Next() as IGxDataset))
                                        {
                                            IFeatureClass featureClass = gxDataset2.Dataset as IFeatureClass;
                                            if (featureClass != null)
                                            {
                                                IFeatureLayer featureLayer;
                                                if (featureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                                                {
                                                    featureLayer = new FDOGraphicsLayer() as IFeatureLayer;
                                                    featureLayer.FeatureClass = featureClass;
                                                    featureLayer.Name         = featureClass.AliasName;
                                                }
                                                else
                                                {
                                                    featureLayer = new CadFeatureLayer() as IFeatureLayer;
                                                    featureLayer.FeatureClass = featureClass;
                                                    featureLayer.Name         = featureClass.AliasName;
                                                }
                                                list.Add(featureLayer);
                                            }
                                        }
                                    }
                                }
                                else if (dataset.Type == esriDatasetType.esriDTFeatureDataset)
                                {
                                    IEnumDataset subsets = dataset.Subsets;
                                    subsets.Reset();
                                    for (IDataset dataset2 = subsets.Next(); dataset2 != null; dataset2 = subsets.Next())
                                    {
                                        if (dataset2.Type == esriDatasetType.esriDTFeatureClass)
                                        {
                                            IFeatureClass featureClass = dataset2 as IFeatureClass;
                                            if (featureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                                            {
                                                IFeatureLayer item = new FDOGraphicsLayer() as IFeatureLayer;
                                                item.FeatureClass = featureClass;
                                                item.Name         = featureClass.AliasName;
                                                list.Add(item);
                                            }
                                            else
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass,
                                                    Name         = featureClass.AliasName
                                                });
                                            }
                                        }
                                        else if (dataset2.Type == esriDatasetType.esriDTTopology)
                                        {
                                            ITopologyLayer topologyLayer = new TopologyLayer() as ITopologyLayer;
                                            topologyLayer.Topology         = (dataset2 as ITopology);
                                            (topologyLayer as ILayer).Name = dataset2.Name;
                                            list.Add(topologyLayer as ILayer);
                                        }
                                    }
                                }
                                else if (dataset.Type == esriDatasetType.esriDTTopology)
                                {
                                    if (System.Windows.Forms.MessageBox.Show("是否将参加拓扑-" + dataset.Name + "-的所有要素添加到地图中", "添加拓扑层", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Asterisk) == System.Windows.Forms.DialogResult.Yes)
                                    {
                                        IEnumFeatureClass classes = (dataset as IFeatureClassContainer).Classes;
                                        classes.Reset();
                                        for (IFeatureClass featureClass2 = classes.Next(); featureClass2 != null; featureClass2 = classes.Next())
                                        {
                                            list.Add(new FeatureLayer
                                            {
                                                FeatureClass = featureClass2,
                                                Name         = featureClass2.AliasName
                                            });
                                        }
                                    }
                                    ITopologyLayer topologyLayer = new TopologyLayer() as ITopologyLayer;
                                    topologyLayer.Topology         = (dataset as ITopology);
                                    (topologyLayer as ILayer).Name = dataset.Name;
                                    list.Add(topologyLayer as ILayer);
                                }
                                else if (dataset.Type == esriDatasetType.esriDTTin)
                                {
                                    list.Add(new TinLayer
                                    {
                                        Dataset = (ITin)dataset,
                                        Name    = dataset.Name
                                    });
                                }
                                else if (dataset.Type == esriDatasetType.esriDTRasterDataset || dataset.Type == esriDatasetType.esriDTRasterBand)
                                {
                                    bool flag = true;
                                    if (!((IRasterPyramid)dataset).Present)
                                    {
                                        if (ApplicationRef.PyramidPromptType == PyramidPromptType.AlwaysBuildNoPrompt)
                                        {
                                            ((IRasterPyramid)dataset).Create();
                                        }
                                        else if (ApplicationRef.PyramidPromptType == PyramidPromptType.AlwaysPrompt)
                                        {
                                            System.Windows.Forms.DialogResult dialogResult = BuildPyramidSet.Show();
                                            if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                                            {
                                                ((IRasterPyramid)dataset).Create();
                                            }
                                            else if (dialogResult == System.Windows.Forms.DialogResult.Cancel)
                                            {
                                                flag = false;
                                            }
                                        }
                                    }
                                    if (flag)
                                    {
                                        IRasterLayer rasterLayer = new RasterLayer
                                        {
                                            Cached = true
                                        };
                                        rasterLayer.CreateFromDataset((IRasterDataset)dataset);
                                        rasterLayer.Name = dataset.Name;
                                        list.Add(rasterLayer);
                                    }
                                }
                                else
                                {
                                    if (dataset.Type == esriDatasetType.esriDTTable)
                                    {
                                        try
                                        {
                                            IRasterCatalogTable rasterCatalogTable = new RasterCatalogTable();
                                            rasterCatalogTable.Table = (ITable)dataset;
                                            rasterCatalogTable.Update();
                                            IRasterCatalogLayer rasterCatalogLayer = new RasterCatalogLayer() as IRasterCatalogLayer;
                                            rasterCatalogLayer.Create(rasterCatalogTable);
                                            rasterCatalogLayer.Name = dataset.BrowseName;
                                            list.Add(rasterCatalogLayer);
                                            goto IL_8B0;
                                        }
                                        catch (Exception ex)
                                        {
                                            try
                                            {
                                                IStandaloneTableCollection standaloneTableCollection = this.method_0() as IStandaloneTableCollection;
                                                IPropertySet connectionProperties = dataset.Workspace.ConnectionProperties;
                                                bool         flag2 = false;
                                                for (int j = 0; j < standaloneTableCollection.StandaloneTableCount; j++)
                                                {
                                                    ITable table = standaloneTableCollection.get_StandaloneTable(j).Table;
                                                    if (
                                                        connectionProperties.IsEqual(
                                                            (table as IDataset).Workspace.ConnectionProperties) &&
                                                        (table as IDataset).Name == dataset.Name)
                                                    {
                                                        flag2 = true;
                                                    }
                                                    else
                                                    {
                                                        standaloneTableCollection.AddStandaloneTable(new StandaloneTable
                                                        {
                                                            Table = dataset as ITable
                                                        });
                                                    }
                                                }
                                            }
                                            catch (Exception exception_)
                                            {
                                                CErrorLog.writeErrorLog(this, exception_, "");
                                            }

                                            goto IL_8B0;
                                        }
                                    }
                                    if (dataset.Type == esriDatasetType.esriDTGeometricNetwork)
                                    {
                                        IGeometricNetwork geometricNetwork = dataset as IGeometricNetwork;
                                        if (geometricNetwork != null)
                                        {
                                            IEnumFeatureClass enumFeatureClass = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleJunction);
                                            enumFeatureClass.Reset();
                                            for (IFeatureClass featureClass3 = enumFeatureClass.Next(); featureClass3 != null; featureClass3 = enumFeatureClass.Next())
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass3,
                                                    Name         = (featureClass3 as IDataset).Name
                                                });
                                            }
                                            enumFeatureClass = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexJunction);
                                            enumFeatureClass.Reset();
                                            for (IFeatureClass featureClass3 = enumFeatureClass.Next(); featureClass3 != null; featureClass3 = enumFeatureClass.Next())
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass3,
                                                    Name         = (featureClass3 as IDataset).Name
                                                });
                                            }
                                            enumFeatureClass = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleEdge);
                                            enumFeatureClass.Reset();
                                            for (IFeatureClass featureClass3 = enumFeatureClass.Next(); featureClass3 != null; featureClass3 = enumFeatureClass.Next())
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass3,
                                                    Name         = (featureClass3 as IDataset).Name
                                                });
                                            }
                                            enumFeatureClass = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexEdge);
                                            enumFeatureClass.Reset();
                                            for (IFeatureClass featureClass3 = enumFeatureClass.Next(); featureClass3 != null; featureClass3 = enumFeatureClass.Next())
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass3,
                                                    Name         = (featureClass3 as IDataset).Name
                                                });
                                            }
                                        }
                                    }
                                    else if (dataset.Type == esriDatasetType.esriDTNetworkDataset)
                                    {
                                        INetworkDataset networkDataset = dataset as INetworkDataset;
                                        INetworkLayer   item           = new NetworkLayer() as INetworkLayer;
                                        item.NetworkDataset = networkDataset;

                                        list.Add(item as ILayer);
                                        if (System.Windows.Forms.MessageBox.Show("是否将参加网络要素集-" + dataset.Name + "-的所有要素添加到地图中", "添加拓扑层", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Asterisk) == System.Windows.Forms.DialogResult.Yes)
                                        {
                                            IEnumFeatureClass classes = (dataset as IFeatureClassContainer).Classes;
                                            classes.Reset();
                                            for (IFeatureClass featureClass2 = classes.Next(); featureClass2 != null; featureClass2 = classes.Next())
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass2,
                                                    Name         = featureClass2.AliasName
                                                });
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    IL_8B0 :;
                }
                int    num   = list.Count;
                ILayer layer = null;
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is IRasterCatalogLayer)
                    {
                        this.method_0().AddLayer(layer);
                        (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                        list.RemoveAt(i);
                        num--;
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is IRasterLayer)
                    {
                        this.method_0().AddLayer(layer);
                        (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                        list.RemoveAt(i);
                        num--;
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is ITinLayer)
                    {
                        this.method_0().AddLayer(layer);
                        (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                        list.RemoveAt(i);
                        num--;
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is ICadLayer)
                    {
                        this.method_0().AddLayer(layer);
                        (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                        list.RemoveAt(i);
                        num--;
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is IFeatureLayer)
                    {
                        IFeatureLayer featureLayer = layer as IFeatureLayer;
                        IFeatureClass featureClass = featureLayer.FeatureClass;
                        if (featureClass.ShapeType == esriGeometryType.esriGeometryPolygon || featureClass.ShapeType == esriGeometryType.esriGeometryEnvelope)
                        {
                            this.method_0().AddLayer(layer);
                            (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                            list.RemoveAt(i);
                            num--;
                        }
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is IFeatureLayer)
                    {
                        IFeatureLayer featureLayer = layer as IFeatureLayer;
                        IFeatureClass featureClass = featureLayer.FeatureClass;
                        if (featureClass.ShapeType == esriGeometryType.esriGeometryLine || featureClass.ShapeType == esriGeometryType.esriGeometryBezier3Curve || featureClass.ShapeType == esriGeometryType.esriGeometryCircularArc || featureClass.ShapeType == esriGeometryType.esriGeometryEllipticArc || featureClass.ShapeType == esriGeometryType.esriGeometryPath || featureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                        {
                            try
                            {
                                this.method_0().AddLayer(layer);
                                goto IL_B56;
                            }
                            catch
                            {
                                goto IL_B56;
                            }
                            goto IL_B4D;
IL_B56:
                            (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                            list.RemoveAt(i);
                            num--;
                        }
                    }
                    IL_B4D :;
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is IFeatureLayer)
                    {
                        IFeatureLayer featureLayer = layer as IFeatureLayer;
                        IFeatureClass featureClass = featureLayer.FeatureClass;
                        if (featureClass.ShapeType == esriGeometryType.esriGeometryMultipoint || featureClass.ShapeType == esriGeometryType.esriGeometryPoint)
                        {
                            this.method_0().AddLayer(layer);
                            (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                            list.RemoveAt(i);
                            num--;
                        }
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    this.method_0().AddLayer(layer);
                    (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                    list.RemoveAt(i);
                    num--;
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        /// <summary>
        /// code to execute when command is run.
        /// </summary>
        protected override void Execute()
        {
            IList <string> errors = new List <string>();

            if (Args.Shape == null)
            {
                ErrorMessage = "To query a raster you must supply a shape";
                return;
            }

            IGeometry point = null;

            if (Args.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                point = Args.Shape;
            }
            else
            {
                var area = Args.Shape as IArea;
                if (area == null)
                {
                    errors.Add("Could not get centroid from input geometry. Best results are with point geometry types.");
                }
                else
                {
                    point = area.Centroid;
                }
            }

            if (errors.Any())
            {
                ErrorMessage = "Could not complete operation. {0}".With(string.Join(", ", errors));
                return;
            }

            var featureClass = FeatureWorkspace.OpenRasterDataset(Args.FeatureClass.Trim());

            var rasterLayer = new RasterLayer();

            rasterLayer.CreateFromDataset(featureClass);

            var table = rasterLayer as ITable;

            if (table == null)
            {
                ErrorMessage = "Could not complete operation. {0}".With("Accessing raster table.");
                return;
            }

            errors = ValidateFields(table, Args.ReturnValues);

            if (errors.Any())
            {
                ErrorMessage = "{0} does not contain an attribute {1}. Check your spelling."
                               .With(Args.FeatureClass, string.Join(" or ", errors));

                return;
            }

            var identify = rasterLayer as IIdentify;

            if (identify == null)
            {
                ErrorMessage = "Could not complete operation. {0}".With("Identifying raster.");
                return;
            }

            var results = identify.Identify(point);

            if (results == null || results.Count < 1)
            {
                Result = new ResponseContainer <SearchResult>
                {
                    Results = new List <SearchResult>()
                };

                return;
            }

            var container = AddResultsToContainer(results, table.Fields, Args.ReturnValues, Args.SpatialRefefence);

            Marshal.ReleaseComObject(identify);
            Marshal.ReleaseComObject(table);
            Marshal.ReleaseComObject(rasterLayer);
            Marshal.ReleaseComObject(featureClass);
            Marshal.ReleaseComObject(FeatureWorkspace);

            Result = container;
        }
Esempio n. 20
0
        public static void AddDataset(IBasicMap ibasicMap_0, IDataset idataset_0, string string_0)
        {
            if (string_0 == null)
            {
                string_0 = "";
            }
            switch (idataset_0.Type)
            {
            case esriDatasetType.esriDTFeatureDataset:
            {
                IEnumDataset subsets = idataset_0.Subsets;
                subsets.Reset();
                for (IDataset dataset2 = subsets.Next(); dataset2 != null; dataset2 = subsets.Next())
                {
                    AddDataset(ibasicMap_0, dataset2, string_0);
                }
                break;
            }

            case esriDatasetType.esriDTFeatureClass:
            {
                IFeatureLayer layer;
                IFeatureClass class2 = (IFeatureClass)idataset_0;
                if (class2.FeatureType != esriFeatureType.esriFTAnnotation)
                {
                    if (class2.FeatureType == esriFeatureType.esriFTDimension)
                    {
                        IFeatureLayer dimensionLayer = new DimensionLayer() as IFeatureLayer;
                        dimensionLayer.FeatureClass = class2;
                        dimensionLayer.Name         = string_0 + class2.AliasName;
                        layer = dimensionLayer as IFeatureLayer;
                        ibasicMap_0.AddLayer(layer);
                    }
                    else
                    {
                        layer = new FeatureLayer
                        {
                            FeatureClass = class2,
                            Name         = string_0 + class2.AliasName
                        };
                        ibasicMap_0.AddLayer(layer);
                    }
                    break;
                }
                layer = new FDOGraphicsLayer() as IFeatureLayer;
                try
                {
                    layer.FeatureClass = class2;
                    layer.Name         = string_0 + class2.AliasName;
                    ibasicMap_0.AddLayer(layer);
                }
                catch (Exception exception)
                {
                    exception.ToString();
                }
                break;
            }

            case esriDatasetType.esriDTGeometricNetwork:
            {
                IGeometricNetwork network = idataset_0 as IGeometricNetwork;
                if (network != null)
                {
                    IFeatureLayer     layer7;
                    IEnumFeatureClass class3 = network.get_ClassesByType(esriFeatureType.esriFTSimpleJunction);
                    class3.Reset();
                    IFeatureClass class4 = class3.Next();
                    while (class4 != null)
                    {
                        layer7 = new FeatureLayer
                        {
                            FeatureClass = class4,
                            Name         = string_0 + (class4 as IDataset).Name
                        };
                        ibasicMap_0.AddLayer(layer7);
                        class4 = class3.Next();
                    }
                    class3 = network.get_ClassesByType(esriFeatureType.esriFTComplexJunction);
                    class3.Reset();
                    for (class4 = class3.Next(); class4 != null; class4 = class3.Next())
                    {
                        layer7 = new FeatureLayer
                        {
                            FeatureClass = class4,
                            Name         = string_0 + (class4 as IDataset).Name
                        };
                        ibasicMap_0.AddLayer(layer7);
                    }
                    class3 = network.get_ClassesByType(esriFeatureType.esriFTSimpleEdge);
                    class3.Reset();
                    for (class4 = class3.Next(); class4 != null; class4 = class3.Next())
                    {
                        layer7 = new FeatureLayer
                        {
                            FeatureClass = class4,
                            Name         = string_0 + (class4 as IDataset).Name
                        };
                        ibasicMap_0.AddLayer(layer7);
                    }
                    class3 = network.get_ClassesByType(esriFeatureType.esriFTComplexEdge);
                    class3.Reset();
                    for (class4 = class3.Next(); class4 != null; class4 = class3.Next())
                    {
                        layer7 = new FeatureLayer
                        {
                            FeatureClass = class4,
                            Name         = string_0 + (class4 as IDataset).Name
                        };
                        ibasicMap_0.AddLayer(layer7);
                    }
                }
                break;
            }

            case esriDatasetType.esriDTTopology:
            {
                ITopologyLayer layer = new TopologyLayer() as ITopologyLayer;
                layer.Topology = idataset_0 as ITopology;
                ITopologyLayer layer3 = layer as ITopologyLayer;
                (layer3 as ILayer).Name = string_0 + idataset_0.Name;
                ibasicMap_0.AddLayer(layer3 as ILayer);
                break;
            }

            case esriDatasetType.esriDTTable:
                try
                {
                    IRasterCatalogTable pCatalog = new RasterCatalogTable
                    {
                        Table = (ITable)idataset_0
                    };
                    pCatalog.Update();
                    IRasterCatalogLayer pLayer = new RasterCatalogLayer() as IRasterCatalogLayer;
                    pLayer.Create(pCatalog);
                    pLayer.Name = string_0 + idataset_0.BrowseName;
                    ibasicMap_0.AddLayer(pLayer);
                }
                catch
                {
                    try
                    {
                        IStandaloneTableCollection tables = ibasicMap_0 as IStandaloneTableCollection;
                        IPropertySet connectionProperties = idataset_0.Workspace.ConnectionProperties;
                        bool         flag = false;
                        for (int i = 0; i < tables.StandaloneTableCount; i++)
                        {
                            ITable table = tables.get_StandaloneTable(i).Table;
                            if (connectionProperties.IsEqual((table as IDataset).Workspace.ConnectionProperties) &&
                                ((table as IDataset).Name == idataset_0.Name))
                            {
                                goto Label_03E1;
                            }
                        }
                        goto Label_03E4;
Label_03E1:
                        flag = true;
Label_03E4:
                        if (!flag)
                        {
                            IStandaloneTable table3 = new StandaloneTable
                            {
                                Table = idataset_0 as ITable
                            };
                            tables.AddStandaloneTable(table3);
                        }
                    }
                    catch (Exception exception2)
                    {
                        CErrorLog.writeErrorLog(null, exception2, "");
                    }
                }
                break;

            case esriDatasetType.esriDTRasterDataset:
            case esriDatasetType.esriDTRasterBand:
            {
                IRasterLayer layer5 = new RasterLayer();
                layer5.CreateFromDataset((IRasterDataset)idataset_0);
                layer5.Name = string_0 + idataset_0.Name;
                ibasicMap_0.AddLayer(layer5);
                break;
            }

            case esriDatasetType.esriDTTin:
            {
                ITinLayer layer4 = new TinLayer
                {
                    Dataset = (ITin)idataset_0,
                    Name    = string_0 + idataset_0.Name
                };
                ibasicMap_0.AddLayer(layer4);
                break;
            }

            case esriDatasetType.esriDTCadDrawing:
            {
                ICadLayer layer2 = new CadLayer() as ICadLayer;
                layer2.CadDrawingDataset = idataset_0 as ICadDrawingDataset;
                layer2.Name = idataset_0.Name;
                ibasicMap_0.AddLayer(layer2);
                break;
            }
            }
        }