Ejemplo n.º 1
0
 //public FeatureDatasetCatalogItem(IDataset dsFeatureDataset, ICatalogItem parent):base(dsFeatureDataset,parent)
 //{
 //    if (!(dsFeatureDataset is IFeatureDataset))
 //        throw new Exception("内部错误:FeatureClassCatalogItem构造参数必须为FeatueDataset");
 //}
 public FeatureDatasetCatalogItem(IDatasetName dsName, ICatalogItem parent) : base(dsName, parent)
 {
     if (!(dsName is IFeatureDatasetName))
     {
         throw new Exception("内部错误:FeatureClassCatalogItem构造参数必须为FeatueDataset");
     }
 }
Ejemplo n.º 2
0
        private void ExportFeature(IFeatureClass pInFeatureClass, string pPath)
        {
            //创建一个输出shp文件的工作空间
            IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
            string            parentPath        = pPath.Substring(0, pPath.LastIndexOf("\\"));
            string            fileName          = pPath.Substring(pPath.LastIndexOf("\\") + 1, pPath.Length - pPath.LastIndexOf("\\") - 1);
            IWorkspaceName    pWorkspaceName    = pWorkspaceFactory.Create(parentPath, fileName, null, 0);
            //创建一个要素类
            IName      name          = (IName)pWorkspaceName;
            IWorkspace pOutWorkspace = (IWorkspace)name.Open();

            IDataset          pInDataset        = pInFeatureClass as IDataset;
            IFeatureClassName pInFCName         = pInDataset.FullName as IFeatureClassName;
            IWorkspace        pInWorkspace      = pInDataset.Workspace;
            IDataset          pOutDataset       = pOutWorkspace as IDataset;
            IWorkspaceName    pOutWorkspaceName = pOutDataset.FullName as IWorkspaceName;
            IFeatureClassName pOutFCName        = new FeatureClassNameClass();
            IDatasetName      pDatasetName      = pOutFCName as IDatasetName;

            pDatasetName.WorkspaceName = pOutWorkspaceName;
            pDatasetName.Name          = pInFeatureClass.AliasName;
            IFieldChecker pFieldChecker = new FieldCheckerClass();

            pFieldChecker.InputWorkspace    = pInWorkspace;
            pFieldChecker.ValidateWorkspace = pOutWorkspace;
            IFields         pFields = pInFeatureClass.Fields;
            IFields         pOutFields;
            IEnumFieldError pEnumFieldError;

            pFieldChecker.Validate(pFields, out pEnumFieldError, out pOutFields);
            IFeatureDataConverter pFeatureDataConverter = new FeatureDataConverterClass();

            pFeatureDataConverter.ConvertFeatureClass(pInFCName, null, null, pOutFCName, null, pOutFields, "", 100, 0);
        }
Ejemplo n.º 3
0
        public void ExportFeature(IFeatureClass pInFeatureClass, string pPath)
        {
            // create a new Access workspace factory
            IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
            string            parentPath        = pPath.Substring(0, pPath.LastIndexOf('\\'));
            string            fileName          = pPath.Substring(pPath.LastIndexOf('\\') + 1, pPath.Length - pPath.LastIndexOf('\\') - 1);
            IWorkspaceName    pWorkspaceName    = pWorkspaceFactory.Create(parentPath, fileName, null, 0);
            // Cast for IName
            IName name = (IName)pWorkspaceName;
            //Open a reference to the access workspace through the name object
            IWorkspace pOutWorkspace = (IWorkspace)name.Open();

            IDataset          pInDataset        = pInFeatureClass as IDataset;
            IFeatureClassName pInFCName         = pInDataset.FullName as IFeatureClassName;
            IWorkspace        pInWorkspace      = pInDataset.Workspace;
            IDataset          pOutDataset       = pOutWorkspace as IDataset;
            IWorkspaceName    pOutWorkspaceName = pOutDataset.FullName as IWorkspaceName;
            IFeatureClassName pOutFCName        = new FeatureClassNameClass();
            IDatasetName      pDatasetName      = pOutFCName as IDatasetName;

            pDatasetName.WorkspaceName = pOutWorkspaceName;
            pDatasetName.Name          = pInFeatureClass.AliasName;
            IFieldChecker pFieldChecker = new FieldCheckerClass();

            pFieldChecker.InputWorkspace    = pInWorkspace;
            pFieldChecker.ValidateWorkspace = pOutWorkspace;
            IFields         pFields = pInFeatureClass.Fields;
            IFields         pOutFields;
            IEnumFieldError pEnumFieldError;

            pFieldChecker.Validate(pFields, out pEnumFieldError, out pOutFields);
            IFeatureDataConverter pFeatureDataConverter = new FeatureDataConverterClass();

            pFeatureDataConverter.ConvertFeatureClass(pInFCName, null, null, pOutFCName, null, pOutFields, "", 100, 0);
        }
Ejemplo n.º 4
0
        private void btnAddList_Click(object sender, EventArgs e)
        {
            if (pListViewDT.Items.Count != 0)
            {
                //清空历史数据
                pListViewDT.Items.Clear();
            }

            //添加数据
            IEnumDatasetName pEnumRasterName = null;
            IDatasetName     pDT             = null;
            ListViewItem     pListViewItem   = null;

            //添加栅格编目图层

            pEnumRasterName = pworkSpace.get_DatasetNames(esriDatasetType.esriDTRasterCatalog);
            if (pEnumRasterName == null)
            {
                return;
            }
            pDT = pEnumRasterName.Next();
            while (pDT != null)
            {
                //将查到的结果,添加在列表中
                pListViewItem      = new ListViewItem();
                pListViewItem.Name = pDT.Name;
                pListViewItem.Text = pDT.Name;
                pListViewItem.Tag  = pDT;
                pListViewDT.Items.Add(pListViewItem);
                pDT = pEnumRasterName.Next();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取IEnumDataset中的所有FeatureClass名称
        /// </summary>
        /// <param name="datasetsEnum"></param>
        /// <returns></returns>
        static List <string> GetAllFeatureClassName(IEnumDatasetName datasetsEnumName)
        {
            List <string> lst = new List <string>();

            if (datasetsEnumName == null)
            {
                return(lst);
            }
            else
            {
                IDatasetName datasetName = datasetsEnumName.Next();
                while (datasetName != null)
                {
                    if (datasetName.Type == esriDatasetType.esriDTFeatureClass)
                    {
                        lst.Add(datasetName.Name);
                    }
                    else if (datasetName.Type == esriDatasetType.esriDTFeatureDataset)
                    {
                        lst.AddRange(GetAllFeatureClassName(datasetName.SubsetNames));
                    }
                    datasetName = datasetsEnumName.Next();
                }
            }
            return(lst);
        }
        private ITable getSettingsTable(IFeatureWorkspace fwspc)
        {
            ITable tbl = null;

            try
            {
                Workspace        mb_ws = (Workspace)fwspc;
                IEnumDatasetName names = mb_ws.get_DatasetNames(esriDatasetType.esriDTTable);
                names.Reset();

                IDatasetName name = names.Next();
                while (name != null)
                {
                    if (name.Name.Contains("AddressingSettings"))
                    {
                        SettingsTableName = name.Name;
                    }
                    name = names.Next();
                }

                tbl = fwspc.OpenTable(SettingsTableName);
            }
            catch (Exception ex)
            {
                tbl = null;
            }

            return(tbl);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 复制要素集(ConvertFeatureDataset)
        /// </summary>
        /// <param name="sourceWorkspace"></param>
        /// <param name="targetWorkspace"></param>
        /// <param name="nameOfSourceFeatureDataset"></param>
        /// <param name="nameOfTargetFeatureDataset"></param>
        public void IFeatureDataConverter_ConvertFeatureDataset(IWorkspace sourceWorkspace, IWorkspace targetWorkspace, string nameOfSourceFeatureDataset, string nameOfTargetFeatureDataset)
        {
            //create source workspace name
            IDataset       sourceWorkspaceDataset = (IDataset)sourceWorkspace;
            IWorkspaceName sourceWorkspaceName    = (IWorkspaceName)sourceWorkspaceDataset.FullName;

            //create source dataset name
            IFeatureDatasetName sourceFeatureDatasetName = new FeatureDatasetNameClass();
            IDatasetName        sourceDatasetName        = (IDatasetName)sourceFeatureDatasetName;

            sourceDatasetName.WorkspaceName = sourceWorkspaceName;
            sourceDatasetName.Name          = nameOfSourceFeatureDataset;

            //create target workspace name
            IDataset       targetWorkspaceDataset = (IDataset)targetWorkspace;
            IWorkspaceName targetWorkspaceName    = (IWorkspaceName)targetWorkspaceDataset.FullName;

            //create target dataset name
            IFeatureDatasetName targetFeatureDatasetName = new FeatureDatasetNameClass();
            IDatasetName        targetDatasetName        = (IDatasetName)targetFeatureDatasetName;

            targetDatasetName.WorkspaceName = targetWorkspaceName;
            targetDatasetName.Name          = nameOfTargetFeatureDataset;

            //Convert feature dataset
            IFeatureDataConverter featureDataConverter = new FeatureDataConverterClass();

            featureDataConverter.ConvertFeatureDataset(sourceFeatureDatasetName, targetFeatureDatasetName, null, "", 1000, 0);
            //Console.WriteLine("Conversion Complete");
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Adds a datasetname object to the listview of feature classes.
        /// </summary>
        /// <param name="dsName">name object to add</param>
        private void AddItemToListViewData(IDatasetName dsName)
        {
            ListViewItem item = new ListViewItem(dsName.Name);

            item.UseItemStyleForSubItems = false;
            esriGeometryType geomType = ((IFeatureClassName)dsName).ShapeType;

            if (geomType == esriGeometryType.esriGeometryPoint)
            {
                item.SubItems.Add("Point");
            }
            else if (geomType == esriGeometryType.esriGeometryPolyline)
            {
                item.SubItems.Add("Line");
            }
            else if (geomType == esriGeometryType.esriGeometryPolygon)
            {
                item.SubItems.Add("Polygon");
            }
            item.SubItems.Add("remove");
            item.SubItems[2].ForeColor = Color.Blue;
            item.Tag = dsName;
            if (dsName.Name == "EdgeofWater_Points_Unprojected" || dsName.Name == "Topo_Points_Unprojected")
            {
                item.Checked = true;
            }
            listViewData.Items.Add(item);
        }
Ejemplo n.º 9
0
        private void InitialComboxEx(ComboBoxEx cobox)
        {
            IMap       pMap       = pMapControl.Map;
            IEnumLayer pEnumLayer = pMap.get_Layers(null, true);

            pEnumLayer.Reset();
            ILayer pLayer = pEnumLayer.Next();

            while (pLayer != null)
            {
                cobox.Items.Add(pLayer.Name);
                //获取layer的完整路径
                IDataLayer2    pDatalayer   = pLayer as IDataLayer2;
                IDatasetName   pDatasetName = pDatalayer.DataSourceName as IDatasetName;
                IWorkspaceName pWPName      = pDatasetName.WorkspaceName;

                if (!pdic.ContainsKey(pLayer.Name))
                {
                    pdic.Add(pLayer.Name, pWPName.PathName + "\\" + pLayer.Name + ".shp");
                }
                if (!pdicLayer.ContainsKey(pLayer.Name))
                {
                    pdicLayer.Add(pLayer.Name, pLayer);
                }
                pLayer = pEnumLayer.Next();
            }
        }
Ejemplo n.º 10
0
 private void TestConnectSDEData(string server, string instance, string database, string user, string password, string version)
 {
     try
     {
         m_pWorkspaceFactory = new  SdeWorkspaceFactoryClass();
         m_pPropSet          = new PropertySetClass();
         //设置SDE连接属性信息
         m_pPropSet.SetProperty("SERVER", server);
         m_pPropSet.SetProperty("INSTANCE", instance);
         m_pPropSet.SetProperty("Database", database);
         m_pPropSet.SetProperty("User", user);
         m_pPropSet.SetProperty("password", password);
         m_pPropSet.SetProperty("version", version);
         m_pWorkspace        = m_pWorkspaceFactory.Open(m_pPropSet, 0);
         m_pFeatureWorkspace = m_pWorkspace as  IFeatureWorkspace;
         /////////////////////////////////////////////////////////
         IEnumDatasetName pEnumDSName = m_pWorkspace.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
         IDatasetName     pSDEDsName  = pEnumDSName.Next();
         treeView1.Nodes.Clear();
         TreeNode node1;
         while (pSDEDsName != null)
         {
             node1 = treeView1.Nodes.Add(pSDEDsName.Name);
             LoadAllFeatClass(node1, pSDEDsName.Name);
             pSDEDsName = pEnumDSName.Next();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 11
0
        private void btnSdeRcPath_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folder = new FolderBrowserDialog();

            //folder.ShowNewFolderButton = false;
            folder.Description = "还原的gdb路径:";
            if (folder.ShowDialog() == DialogResult.OK)
            {
                string str = folder.SelectedPath;
                this.txtSdeRcPath.Text = str;
            }
            IWorkspaceFactory pGDBWf = new FileGDBWorkspaceFactoryClass();

            pGDBWs      = pGDBWf.OpenFromFile(txtSdeRcPath.Text, 0);
            this.Cursor = Cursors.WaitCursor;
            lstSdeRcDs.Items.Clear();
            if (pGDBWs == null)
            {
                lblBottom.Text = "连接失败!请检查路径。";
                this.Cursor    = Cursors.Default;
                return;
            }
            IEnumDatasetName pEDN = pGDBWs.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
            IDatasetName     pDN  = pEDN.Next();

            while (pDN != null)
            {
                lstSdeRcDs.Items.Add(pDN.Name);
                pDN = pEDN.Next();
            }
            lstSdeRcDs.Refresh();
            this.Cursor = Cursors.Default;
        }
Ejemplo n.º 12
0
 private void NewRelationClassSetClass_Load(object sender, EventArgs e)
 {
     if (NewRelationClassHelper.m_pWorkspace != null)
     {
         IEnumDatasetName name = NewRelationClassHelper.m_pWorkspace.get_DatasetNames(esriDatasetType.esriDTAny);
         name.Reset();
         for (IDatasetName name2 = name.Next(); name2 != null; name2 = name.Next())
         {
             if (((name2.Type == esriDatasetType.esriDTFeatureClass) ||
                  (name2.Type == esriDatasetType.esriDTTable)) ||
                 (name2.Type == esriDatasetType.esriDTFeatureDataset))
             {
                 TreeNode node = new TreeNode(name2.Name)
                 {
                     Tag = (name2 as IName).Open()
                 };
                 this.treeViewSource.Nodes.Add(node);
                 if (name2.Type == esriDatasetType.esriDTFeatureDataset)
                 {
                     this.method_0(name2, node);
                 }
                 node = new TreeNode(name2.Name)
                 {
                     Tag = (name2 as IName).Open()
                 };
                 this.treeViewDest.Nodes.Add(node);
                 if (name2.Type == esriDatasetType.esriDTFeatureDataset)
                 {
                     this.method_0(name2, node);
                 }
             }
         }
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// 求交,暂时未用
        /// </summary>
        /// <param name="_pFtClass"></param>
        /// <param name="_pFtOverlay"></param>
        /// <param name="_FilePath"></param>
        /// <param name="_pFileName"></param>
        /// <returns></returns>
        public IFeatureClass Intsect(IFeatureClass _pFtClass, IFeatureClass _pFtOverlay, string _FilePath, string _pFileName)
        {
            //设置输出
            IFeatureClassName pOutPut = new FeatureClassNameClass();

            pOutPut.ShapeType      = _pFtClass.ShapeType;
            pOutPut.ShapeFieldName = _pFtClass.ShapeFieldName;
            pOutPut.FeatureType    = esriFeatureType.esriFTSimple;
            //set output location and feature class name
            IWorkspaceName pWsN = new WorkspaceNameClass();

            pWsN.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory";
            pWsN.PathName = _FilePath;
            //也可以用这种方法,IName 和IDataset的用法
//             IWorkspaceFactory pWsFc = new ShapefileWorkspaceFactoryClass();
//             IWorkspace pWs = pWsFc.OpenFromFile(_FilePath,0);
//             IDataset pDataset = pWs as IDataset;
//             IWorkspaceName pWsN = pDataset.FullName as IWorkspaceName;

            IDatasetName pDatasetName = pOutPut as IDatasetName;

            pDatasetName.Name          = _pFileName;
            pDatasetName.WorkspaceName = pWsN;

            IBasicGeoprocessor pBasicGeo     = new BasicGeoprocessorClass();
            IFeatureClass      pFeatureClass = pBasicGeo.Intersect(_pFtClass as ITable, false, _pFtOverlay as ITable, false, 0.1, pOutPut);

            return(pFeatureClass);
        }
Ejemplo n.º 14
0
        private void btnSetDataSourcePath_Click(object sender, EventArgs e)
        {
            string sDir = Application.StartupPath;

            System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
            openFileDialog.InitialDirectory = sDir + @"\..\Result\";
            openFileDialog.Filter           = "mdb|*.mdb";
            openFileDialog.Title            = "请选择数据库";

            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string strFileName = openFileDialog.FileName;

            IDataLayer   pDataLayer          = (IDataLayer)m_FeaLay;
            IName        pName               = pDataLayer.DataSourceName;
            IDatasetName pDatasetName        = pName as IDatasetName;
            string       strFeatureClassName = pDatasetName.Name;

            IWorkspaceFactory pFact      = new AccessWorkspaceFactoryClass();
            IWorkspace        pWorkspace = pFact.OpenFromFile(strFileName, 0);
            IFeatureWorkspace pFeatws    = pWorkspace as IFeatureWorkspace;
            IFeatureClass     pFeatcls   = pFeatws.OpenFeatureClass(strFeatureClassName);

            m_FeaLay.FeatureClass = pFeatcls;
        }
Ejemplo n.º 15
0
 private void FrmSurfaceOp_Load(object sender, EventArgs e)
 {
     cmbOutType.Items.Add("坡度");
     cmbOutType.Items.Add("坡向");
     cmbOutType.Items.Add("山体阴影");
     cmbOutType.Items.Add("等值线");
     cmbOutType.SelectedIndex = 0;
     cmbRenderType.Items.Add("无阴影");
     cmbRenderType.Items.Add("有阴影");
     cmbRenderType.SelectedIndex = 0;
     slider1.Maximum             = 90;
     slider1.Value   = 45;
     slider1.Minimum = 0;
     slider2.Maximum = 360;
     slider2.Value   = 315;
     slider2.Minimum = 0;
     txtContour.Text = "2";
     textBoxX3.Text  = "1";
     if (m_mapControl.Map != null)
     {
         //初始化图层列表
         IEnumLayer pEnumLayer = m_mapControl.Map.get_Layers(null, true);
         pEnumLayer.Reset();
         ILayer pLayer = null;
         while ((pLayer = pEnumLayer.Next()) != null)
         {
             if (pLayer is IRasterLayer)
             {
                 IDataLayer   pDatalayer = pLayer as IDataLayer;
                 IDatasetName pDname     = (IDatasetName)pDatalayer.DataSourceName;
                 cmbTargetRasterLayer.Items.Add(pDname.WorkspaceName.PathName + "\\" + pDname.Name);
             }
         }
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// 导出要素类到目标工作空间
        /// </summary>
        /// <param name="featureClass"></param>
        /// <param name="workspace"></param>
        /// <param name="queryGeometry"></param>
        /// <param name="spatialRelEnum"></param>
        /// <param name="whereClause"></param>
        /// <returns></returns>
        public static Boolean ExportToWorkspace(IFeatureClass featureClass, IWorkspace workspace, IGeometry queryGeometry = null, esriSpatialRelEnum spatialRelEnum = esriSpatialRelEnum.esriSpatialRelIntersects, string whereClause = "")
        {
            IDataset          inDataSet        = featureClass as IDataset;
            IFeatureClassName inFCName         = inDataSet.FullName as IFeatureClassName;
            IWorkspace        inWorkspace      = inDataSet.Workspace;
            IDataset          outDataSet       = workspace as IDataset;
            IWorkspaceName    outWorkspaceName = outDataSet.FullName as IWorkspaceName;
            IFeatureClassName outFCName        = new FeatureClassNameClass();
            IDatasetName      dataSetName      = outFCName as IDatasetName;

            dataSetName.WorkspaceName = outWorkspaceName;
            dataSetName.Name          = inDataSet.Name;

            IFieldChecker fieldChecker = new FieldCheckerClass
            {
                InputWorkspace    = inWorkspace,
                ValidateWorkspace = workspace
            };
            IFields fields = featureClass.Fields;

            fieldChecker.Validate(fields, out IEnumFieldError enumFieldError, out IFields outFields);
            IFeatureDataConverter featureDataConverter = null;

            IField geometryField;

            try
            {
                IGeometryDef   geometryDef = null;
                ISpatialFilter pSF         = new SpatialFilterClass();

                for (int i = 0; i < outFields.FieldCount; i++)
                {
                    if (outFields.get_Field(i).Type == esriFieldType.esriFieldTypeGeometry)
                    {
                        geometryField = outFields.get_Field(i);
                        geometryDef   = geometryField.GeometryDef;
                        IGeometryDefEdit targetFCGeoDefEdit = (IGeometryDefEdit)geometryDef;
                        targetFCGeoDefEdit.GridCount_2 = 1;
                        targetFCGeoDefEdit.set_GridSize(0, 0);
                        targetFCGeoDefEdit.SpatialReference_2 = geometryField.GeometryDef.SpatialReference;

                        pSF.Geometry      = queryGeometry;
                        pSF.GeometryField = featureClass.ShapeFieldName;
                        pSF.SpatialRel    = spatialRelEnum;
                        pSF.WhereClause   = whereClause;
                        break;
                    }
                }

                featureDataConverter = new FeatureDataConverterClass();
                featureDataConverter.ConvertFeatureClass(inFCName, pSF, null, outFCName, geometryDef, outFields, " ", 1000, 0);

                return(true);
            }
            catch (Exception ex)
            {
                LOG.Error("图层数据导出出错!" + ex.Message);
                throw ex;
            }
        }
        /// <summary>
        /// This function takes a raster object and returns the formatted name of
        /// the object for display in the UI.
        /// </summary>
        /// <param name="inputRaster">Object whose name is to be found</param>
        /// <returns>Name of the object</returns>
        private string GetInputRasterName(object inputRaster)
        {
            if ((inputRaster is IRasterDataset))
            {
                IRasterDataset rasterDataset = (IRasterDataset)inputRaster;
                return(rasterDataset.CompleteName);
            }

            if ((inputRaster is IRaster))
            {
                IRaster myRaster = (IRaster)inputRaster;
                return(((IRaster2)myRaster).RasterDataset.CompleteName);
            }

            if (inputRaster is IDataset)
            {
                IDataset dataset = (IDataset)inputRaster;
                return(dataset.Name);
            }

            if (inputRaster is IName)
            {
                if (inputRaster is IDatasetName)
                {
                    IDatasetName inputDSName = (IDatasetName)inputRaster;
                    return(inputDSName.Name);
                }

                if (inputRaster is IFunctionRasterDatasetName)
                {
                    IFunctionRasterDatasetName inputFRDName = (IFunctionRasterDatasetName)inputRaster;
                    return(inputFRDName.BrowseName);
                }

                if (inputRaster is IMosaicDatasetName)
                {
                    IMosaicDatasetName inputMDName = (IMosaicDatasetName)inputRaster;
                    return("MD");
                }

                IName inputName = (IName)inputRaster;
                return(inputName.NameString);
            }

            if (inputRaster is IRasterFunctionTemplate)
            {
                IRasterFunctionTemplate rasterFunctionTemplate =
                    (IRasterFunctionTemplate)inputRaster;
                return(rasterFunctionTemplate.Function.Name);
            }

            if (inputRaster is IRasterFunctionVariable)
            {
                IRasterFunctionVariable rasterFunctionVariable =
                    (IRasterFunctionVariable)inputRaster;
                return(rasterFunctionVariable.Name);
            }

            return("");
        }
Ejemplo n.º 18
0
        private void fillDatalayerProps(ILayer lyr)
        {
            IDataLayer   dlyr     = lyr as IDataLayer;
            IDatasetName dataName = dlyr.DataSourceName as IDatasetName;

            // nur für SDE-Layer werden die Connection-Infos ausgegeben
            // bei übrigen Layern wird nur der Pfad ausgegeben
            if (dataName.WorkspaceName.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
            {
                IPropertySet props = dataName.WorkspaceName.ConnectionProperties;
                username = props.GetProperty("user").ToString();
                server   = props.GetProperty("server").ToString();
                instance = props.GetProperty("instance").ToString();
                version  = props.GetProperty("version").ToString();
                string[] s = dataName.Name.Split('.');
                owner     = s[0];
                tablename = s[1];
            }
            else
            {
                tablename = dataName.Name;
                server    = dataName.WorkspaceName.PathName;
                type      = "kein SDE-Layer";
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Fills the control points combo box with the point feature classes from the data list.
        /// </summary>
        private void FillControlComboBox()
        {
            List <IDatasetName> nameList = new List <IDatasetName>();

            foreach (ListViewItem item in listViewData.Items)
            {
                if (((IFeatureClassName)item.Tag).ShapeType == esriGeometryType.esriGeometryPoint)
                {
                    nameList.Add((IDatasetName)item.Tag);
                }
            }
            nameList.Sort(_nameComparer);
            IDatasetName oldName = (IDatasetName)comboBoxControlPts.SelectedItem;

            comboBoxControlPts.DataSource = nameList;
            if (oldName != null)
            {
                foreach (System.Object item in comboBoxControlPts.Items)
                {
                    if (_nameComparer.Equal(oldName, (IDatasetName)item))
                    {
                        comboBoxControlPts.SelectedItem = item;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 20
0
 private void method_0()
 {
     this.bool_0 = true;
     this.igxObjectArray_0.Empty();
     if (this.idatasetName_0.Type == esriDatasetType.esriDTRasterDataset)
     {
         try
         {
             IEnumDatasetName subsetNames = this.idatasetName_0.SubsetNames;
             subsetNames.Reset();
             for (IDatasetName name2 = subsetNames.Next(); name2 != null; name2 = subsetNames.Next())
             {
                 IGxObject obj2 = new GxRasterDataset();
                 (obj2 as IGxDataset).DatasetName = name2;
                 obj2.Attach(this, this.igxCatalog_0);
             }
         }
         catch
         {
         }
     }
     else if (this.idatasetName_0.Type != esriDatasetType.esriDTRasterCatalog)
     {
     }
 }
Ejemplo n.º 21
0
        public static void UpdateName([NotNull] IModelElement modelElement,
                                      [NotNull] IDatasetName datasetName,
                                      bool useQualifiedName)
        {
            Assert.ArgumentNotNull(modelElement, nameof(modelElement));
            Assert.ArgumentNotNull(datasetName, nameof(datasetName));

            UpdateName(modelElement, datasetName.Name, useQualifiedName);

            var featureDatasetElement = modelElement as IFeatureDatasetElement;

            if (featureDatasetElement == null)
            {
                return;
            }

            IDatasetName featureDatasetName = DatasetUtils.GetFeatureDatasetName(datasetName);

            Assert.NotNull(featureDatasetName,
                           "Unable to determine feature dataset name for {0}",
                           datasetName.Name);

            featureDatasetElement.FeatureDatasetName =
                useQualifiedName
                                        ? featureDatasetName.Name
                                        : ModelElementNameUtils.GetUnqualifiedName(featureDatasetName.Name);
        }
        public override bool IsSatisfied(IDatasetName datasetName, out string reason)
        {
            IDatasetName featureDatasetName = DatasetUtils.GetFeatureDatasetName(datasetName);

            string tableName;
            string ownerName;
            string databaseName;

            if (featureDatasetName == null)
            {
                tableName    = null;
                ownerName    = null;
                databaseName = null;
            }
            else
            {
                DatasetUtils.ParseTableName(featureDatasetName,
                                            out databaseName,
                                            out ownerName,
                                            out tableName);
            }

            string pattern = GetFirstMatchedPattern(tableName, ownerName, databaseName);

            if (pattern == null)
            {
                reason = "Feature dataset name does not match any pattern";
                return(false);
            }

            reason = $"Feature dataset name matches pattern '{pattern}'";
            return(true);
        }
Ejemplo n.º 23
0
 public void Do()
 {
     try
     {
         this.panel1.Visible = true;
         Dataloaders dataloaders = new Dataloaders();
         (dataloaders.Converter as IFeatureProgress_Event).Step +=
             (new IFeatureProgress_StepEventHandler(this.method_12));
         this.progressBar1.Minimum = 0;
         this.progressBar1.Maximum = this.iarray_0.Count;
         for (int i = 0; i < this.iarray_0.Count; i++)
         {
             this.progressBar1.Increment(1);
             IDatasetName name = this.iarray_0.get_Element(i) as IDatasetName;
             this.method_4(this.method_1(name, "Point") as IName, dataloaders);
             this.method_4(this.method_1(name, "Polyline") as IName, dataloaders);
             this.method_4(this.method_1(name, "Polygon") as IName, dataloaders);
             this.method_4(this.method_1(name, "Annotation") as IName, dataloaders);
         }
         this.igxObject_1.Refresh();
         this.panel1.Visible = false;
     }
     catch (Exception exception)
     {
         Logger.Current.Error("", exception, "");
         MessageBox.Show(exception.Message);
     }
 }
Ejemplo n.º 24
0
        public IFeatureClass Intsect(IFeatureClass _pFtClass, IFeatureClass _pFtOverlay, string _FilePath, string _pFileName)
        {
            IFeatureClassName pOutPut = new FeatureClassNameClass();

            pOutPut.ShapeType = _pFtClass.ShapeType;

            pOutPut.ShapeFieldName = _pFtClass.ShapeFieldName;

            pOutPut.FeatureType = esriFeatureType.esriFTSimple;

            IWorkspaceName pWsN = new WorkspaceNameClass();

            pWsN.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory";

            pWsN.PathName = _FilePath;

            IDatasetName pDatasetName = pOutPut as IDatasetName;

            pDatasetName.Name = _pFileName;

            pDatasetName.WorkspaceName = pWsN;

            IBasicGeoprocessor pBasicGeo = new BasicGeoprocessorClass();

            IFeatureClass pFeatureClass = pBasicGeo.Intersect(_pFtClass as ITable, false, _pFtOverlay as ITable, false, 0.1, pOutPut);

            return(pFeatureClass);
        }
Ejemplo n.º 25
0
        private void method_1(IList ilist_0, IWorkspace iworkspace_0)
        {
            IEnumDatasetName name = iworkspace_0.get_DatasetNames(esriDatasetType.esriDTAny);

            name.Reset();
            for (IDatasetName name2 = name.Next(); name2 != null; name2 = name.Next())
            {
                if (name2.Type == esriDatasetType.esriDTFeatureClass)
                {
                    if ((name2 as IFeatureClassName).FeatureType == esriFeatureType.esriFTSimple)
                    {
                        ilist_0.Add(new ObjectWrap(name2));
                    }
                }
                else if (name2.Type == esriDatasetType.esriDTFeatureDataset)
                {
                    IEnumDatasetName subsetNames = name2.SubsetNames;
                    subsetNames.Reset();
                    for (IDatasetName name4 = subsetNames.Next(); name4 != null; name4 = subsetNames.Next())
                    {
                        if ((name4.Type == esriDatasetType.esriDTFeatureClass) &&
                            ((name4 as IFeatureClassName).FeatureType == esriFeatureType.esriFTSimple))
                        {
                            ilist_0.Add(new ObjectWrap(name4));
                        }
                    }
                }
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Gets the connection string.
        /// </summary>
        /// <param name="layer">The layer.</param>
        /// <returns></returns>
        private string GetConnectionString(ILayer layer)
        {
            try
            {
                string connectionstring = string.Empty;

                IDataLayer     dataLayer     = (IDataLayer)layer;
                IDatasetName   datasetName   = (IDatasetName)dataLayer.DataSourceName;
                IWorkspaceName workspaceName = (IWorkspaceName)datasetName.WorkspaceName;

                IPropertySet propertySet = workspaceName.ConnectionProperties;

                Dictionary <string, string> properties = Umbriel.ArcGIS.Layer.LayerHelper.BuildDictionary(propertySet);

                StringBuilder sb = new StringBuilder();
                foreach (KeyValuePair <string, string> property in properties)
                {
                    sb.Append(property.Key);
                    sb.Append("=");
                    sb.Append(property.Value);
                    sb.Append(";");
                }

                connectionstring = sb.ToString();

                return(connectionstring);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.StackTrace);
                return("ERROR: Cannot Access Connection Information");
            }
        }
Ejemplo n.º 27
0
 IEnumInvalidObject ESRI.ArcGIS.Geodatabase.IFeatureDataConverter2.ConvertFeatureClass(
     IDatasetName idatasetName_0, IQueryFilter iqueryFilter_0, ISelectionSet iselectionSet_0,
     IFeatureDatasetName ifeatureDatasetName_0, IFeatureClassName ifeatureClassName_0,
     IGeometryDef igeometryDef_0, IFields ifields_0, string string_0, int int_0, int int_1)
 {
     return(null);
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Checks if a FeatureClass with the specified name already exists in the workspace
        /// </summary>
        /// <param name="workspace">The workspace.</param>
        /// <param name="featureClassName">Name of the feature class.</param>
        /// <param name="isNameFullyQualified">if set to <c>true</c> the 'featureClassName' argument passed in must be fully qualified else it should be just the name of the featureclass.</param>
        /// <returns>TRUE if a FeatureClass with the specified name exists in the workspace else FASLE</returns>
        public static bool DoesFeatureClassExist(IWorkspace workspace, string featureClassName, bool isNameFullyQualified)
        {
            IEnumDatasetName eDSNames = workspace.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
            IDatasetName     DSName   = eDSNames.Next();

            while (DSName != null)
            {
                if (!isNameFullyQualified)
                {
                    string[] nameParts = DSName.Name.Split('.');
                    if (nameParts[nameParts.Length - 1].ToLower() == featureClassName.ToLower())
                    {
                        return(true);
                    }
                }
                else
                {
                    if (DSName.Name.ToLower() == featureClassName.ToLower())
                    {
                        return(true);
                    }
                }
                DSName = eDSNames.Next();
            }
            return(false);
        }
Ejemplo n.º 29
0
 /// <summary>
 /// 删除图层
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public static bool DeleteFeatureClass(this IWorkspace workspace, string name)
 {
     try
     {
         IEnumDatasetName pEnumDsName = workspace.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
         IDatasetName     datasetName = pEnumDsName.Next();
         while (datasetName != null)
         {
             string[] name_arr = datasetName.Name.Split(new char[] { '.', '/', '\\' });
             if (name_arr[name_arr.Length - 1].ToUpper() == (name.ToUpper()))
             {
                 IFeatureWorkspaceManage pFWSM = workspace as IFeatureWorkspaceManage;
                 if (pFWSM.CanDelete((IName)datasetName))
                 {
                     pFWSM.DeleteByName(datasetName);
                     break;
                 }
             }
             datasetName = pEnumDsName.Next();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Saves as shpfile.
        /// </summary>
        /// <param name="inputFeatureClass">The input feature class.</param>
        /// <param name="pInDataset">The p in dataset.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="pOutWorkspace">The p out workspace.</param>
        private void SaveAsShpfile(IFeatureClass inputFeatureClass, IDataset pInDataset, string fileName, IWorkspace pOutWorkspace)
        {
            IFeatureClassName inputDatasetName = pInDataset.FullName as IFeatureClassName;
            IWorkspace        workspace        = pInDataset.Workspace;
            IDataset          dataset          = pOutWorkspace as IDataset;
            IWorkspaceName    workspaceName    = dataset.FullName as IWorkspaceName;
            IFeatureClassName featureClassName = new FeatureClassNameClass();
            IDatasetName      datasetName      = featureClassName as IDatasetName;

            datasetName.WorkspaceName = workspaceName;
            datasetName.Name          = fileName;
            IFieldChecker fieldChecker = new FieldCheckerClass();

            fieldChecker.InputWorkspace    = workspace;
            fieldChecker.ValidateWorkspace = pOutWorkspace;
            IFields         fields = inputFeatureClass.Fields;
            IEnumFieldError enumFieldError;
            IFields         outputFields;

            fieldChecker.Validate(fields, out enumFieldError, out outputFields);
            IFeatureDataConverter featureDataConverter = new FeatureDataConverterClass();

            featureDataConverter.ConvertFeatureClass(inputDatasetName, null, null, featureClassName, null, outputFields, "", 100, 0);
            XtraMessageBox.Show(AppMessage.MSG0029, AppMessage.MSG0000, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Asterisk);
        }
Ejemplo n.º 31
0
        public static ICatalogItem CreateCatalog(IDatasetName dsNameSource,ICatalogItem parent,IWorkspaceCatalogItem workspaceItem)
        {
            if (dsNameSource == null)
                return null;

            if (dsNameSource is IWorkspaceName)
            {
                return new WorkspaceCatalogItem(dsNameSource, parent);
            }

            ICatalogItem catalogItem = null;
            switch (dsNameSource.Type)
            {
                case esriDatasetType.esriDTFeatureDataset:
                    catalogItem = new FeatureDatasetCatalogItem(dsNameSource, parent);
                    break;

                case esriDatasetType.esriDTFeatureClass:
                    catalogItem = new FeatureClassCatalogItem(dsNameSource, parent);
                    break;

                case esriDatasetType.esriDTTable:
                    catalogItem = new TableCatalogItem(dsNameSource, parent);
                    break;

                case esriDatasetType.esriDTTerrain:
                    catalogItem = new TerrainCatalogItem(dsNameSource, parent);
                    break;

                case esriDatasetType.esriDTTin:
                    catalogItem = new TinCatalogItem(dsNameSource, parent);
                    break;

                case esriDatasetType.esriDTTopology:
                    catalogItem = new TopologyCatalogItem(dsNameSource, parent);
                    break;

                case esriDatasetType.esriDTRasterCatalog:
                    catalogItem = new RasterCatalogCatalogItem(dsNameSource, parent);
                    break;

                case esriDatasetType.esriDTRasterDataset:
                case esriDatasetType.esriDTMosaicDataset:
                    catalogItem= new RasterSetCatalogItem(dsNameSource, parent);
                    break;

                case esriDatasetType.esriDTRasterBand:
                    catalogItem= new RasterBandCatalogItem(dsNameSource, parent);
                    break;

                default:
                    return null;
            }
            if (catalogItem != null)
                catalogItem.WorkspaceItem = workspaceItem;

            return catalogItem;
        }
Ejemplo n.º 32
0
        //public WorkspaceCatalogItem(IDataset dsWorkspace,ICatalogItem parent):base(dsWorkspace,parent)
        //{
        //    if (!(dsWorkspace is IWorkspace))
        //        throw new Exception("内部错误:WorksapceCatalogItem 的构造参数必须为Workspace");
        //    this.m_Dataset = dsWorkspace;
        //    m_Caption = this.m_Dataset.BrowseName ?? this.m_Dataset.Name;
        //    IWorkspace wsSource=(dsWorkspace as IWorkspace);
        //    m_WorkapcePropertySet = wsSource.ConnectionProperties;
        //    m_WorkspaceType = (wsSource.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace ? enumWorkspaceType.SDE :
        //        (wsSource.Type == esriWorkspaceType.esriFileSystemWorkspace ? enumWorkspaceType.File : enumWorkspaceType.Unknown));
        //}
        public WorkspaceCatalogItem(IDatasetName dsName, ICatalogItem parent)
            : base(dsName, parent)
        {
            if (!(dsName is IWorkspaceName))
                throw new Exception("内部错误:WorksapceCatalogItem 的构造参数必须为WorkspaceName");

            //this.m_Dataset = (dsName as IName).Open() as IDataset;
            this.m_DatasetName = dsName;
            m_Caption = this.m_DatasetName.WorkspaceName.BrowseName ?? this.m_DatasetName.Name;
            IWorkspaceName wsSource = this.m_DatasetName.WorkspaceName;
            m_WorkapcePropertySet = wsSource.ConnectionProperties;
            //m_WorkspaceType = (wsSource.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace ? enumWorkspaceType.SDE :
            //    (wsSource.Type == esriWorkspaceType.esriFileSystemWorkspace ? enumWorkspaceType.File : enumWorkspaceType.Unknown));
            if (wsSource.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
            {
                m_WorkspaceType = enumWorkspaceType.SDE;
            }
            else if (wsSource.Type == esriWorkspaceType.esriFileSystemWorkspace)
            {
                m_WorkspaceType = enumWorkspaceType.File;
            }
            else
            {
                string strPath = wsSource.PathName;
                string strType = System.IO.Path.GetExtension(strPath);
                if (string.IsNullOrEmpty(strType))
                    m_WorkspaceType = enumWorkspaceType.Unknown;

                strType = strType.ToUpper();
                if (strType == "MDB")
                    m_WorkspaceType = enumWorkspaceType.PGDB;
                else if (strType == "GDB")
                    m_WorkspaceType = enumWorkspaceType.FileGDB;
                else
                    m_WorkspaceType = enumWorkspaceType.Unknown;
            }
        }
Ejemplo n.º 33
0
 //public TopologyCatalogItem(IDataset dsTopology, ICatalogItem parent)
 //    : base(dsTopology, parent)
 //{
 //    if (!(dsTopology is ITopology))
 //        throw new Exception("内部错误:TopologyCatalogItem构造参数必须为Topology");
 //}
 public TopologyCatalogItem(IDatasetName dsName, ICatalogItem parent)
     : base(dsName, parent)
 {
     if (!(dsName is ITopologyName))
          throw new Exception("内部错误:TopologyCatalogItem构造参数必须为Topology");
 }
Ejemplo n.º 34
0
 //public FeatureDatasetCatalogItem(IDataset dsFeatureDataset, ICatalogItem parent):base(dsFeatureDataset,parent)
 //{
 //    if (!(dsFeatureDataset is IFeatureDataset))
 //        throw new Exception("内部错误:FeatureClassCatalogItem构造参数必须为FeatueDataset");
 //}
 public FeatureDatasetCatalogItem(IDatasetName dsName, ICatalogItem parent)
     : base(dsName,parent)
 {
     if (!(dsName is IFeatureDatasetName))
         throw new Exception("内部错误:FeatureClassCatalogItem构造参数必须为FeatueDataset");
 }
Ejemplo n.º 35
0
        /// <summary>
        /// Gets the dataset name objects from the given dataset name.
        /// </summary>
        /// <param name="dsName">The dataset name from which to get dataset name objects.</param>
        /// <param name="type">The type of dataset name objects to get.</param>
        /// <param name="names">A dictionary of dataset name objects by qualified name.</param>
        private static void GetDatasetNames(IWorkspace workspace, IDatasetName dsName, esriDatasetType type, string[] networkClasses, ref IDictionary<string, IDatasetName> names, ref IDictionary<string, int> objClassIdByName)
        {
            try
            {
                if (dsName != null)
                {
                    if (dsName.Type == type || type == esriDatasetType.esriDTAny)
                    {
                        string key = (DisplayMap.GetQualifiedName(dsName, workspace)).ToLower();
                        if (key != string.Empty)
                        {
                            foreach (string clsName in networkClasses)
                            {
                                if (string.Compare(key, clsName, true) == 0)
                                {
                                    names[clsName] = dsName;
                                    if (dsName is IObjectClassName)
                                        objClassIdByName[clsName] = ((IObjectClassName)dsName).ObjectClassID;
                                    break;
                                }
                            }
                        }
                    }

                    IEnumDatasetName dataNames = dsName.SubsetNames;
                    if (dataNames != null)
                    {
                        dataNames.Reset();
                        IDatasetName name = dataNames.Next();

                        try
                        {
                            while (name != null)
                            {
                                GetDatasetNames(workspace, name, type, networkClasses, ref names, ref objClassIdByName);
                                name = dataNames.Next();
                            }
                        }
                        catch (Exception e)
                        {
                            // _logger.LogAndDisplayException(e);
                        }
                    }
                }
                // else
                //   _logger.LogFormat("{0}: Null dataset name parameter.", methodName, LogLevel.enumLogLevelWarn);
            }
            catch (Exception e)
            {
                // _logger.LogAndDisplayException(e);
            }
        }
Ejemplo n.º 36
0
 public void DeleteByName(IDatasetName aName)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Ejemplo n.º 37
0
 //public ThreeDimenModelCatalogItem(IDataset dsFeatureClass, int featureOID, ICatalogItem parent)
 //    : base(dsFeatureClass, parent)
 //{
 //    m_FeatureOID = featureOID;
 //}
 public ThreeDimenModelCatalogItem(IDatasetName dsName, int featureOID, ICatalogItem parent)
     : base(dsName, parent)
 {
     m_FeatureOID = featureOID;
 }
Ejemplo n.º 38
0
 //public TableCatalogItem(IDataset dsTable, ICatalogItem parent)
 //    : base(dsTable, parent)
 //{
 //    if(!(dsTable is ITable))
 //        throw new Exception("内部错误:TableCatalogItem构造参数必须为线性属性表");
 //}
 public TableCatalogItem(IDatasetName dsName, ICatalogItem parent)
     : base(dsName, parent)
 {
     if(!(dsName is ITableName))
         throw new Exception("内部错误:TableCatalogItem构造参数必须为线性属性表");
 }
Ejemplo n.º 39
0
 //protected CatalogItem(IDataset ds, ICatalogItem parent)
 //{
 //    this.m_Dataset = ds;
 //    this.m_Parent = parent;
 //    this.m_Type = GetCatalogType();
 //}
 protected CatalogItem(IDatasetName dsName, ICatalogItem parent)
 {
     this.m_DatasetName = dsName;
     this.m_Parent = parent;
     this.m_Type = GetCatalogType(dsName);
 }
Ejemplo n.º 40
0
 //public RasterSetCatalogItem(IDataset dsRaster, ICatalogItem parent)
 //    : base(dsRaster, parent)
 //{
 //    if (!(dsRaster is IRasterDataset))
 //        throw new Exception("内部错误:RasterSetCatalogItem构造参数必须为Raster");
 //}
 public RasterSetCatalogItem(IDatasetName dsName, ICatalogItem parent)
     : base(dsName, parent)
 {
     if (!(dsName is IRasterDatasetName))
         throw new Exception("内部错误:RasterSetCatalogItem构造参数必须为Raster");
 }
Ejemplo n.º 41
0
        private enumCatalogType GetCatalogType(IDatasetName dsName)
        {
            if (dsName == null)
                return enumCatalogType.Undefine;
            if (dsName is IWorkspaceName)
                return enumCatalogType.Workpace;

            switch (dsName.Type)
            {
                case esriDatasetType.esriDTFeatureDataset:
                    return enumCatalogType.FeatureDataset;

                case esriDatasetType.esriDTFeatureClass:
                    IFeatureClassName fClassName = dsName as IFeatureClassName;
                    if (fClassName.FeatureType == esriFeatureType.esriFTAnnotation || fClassName.FeatureType == esriFeatureType.esriFTCoverageAnnotation)
                        return enumCatalogType.FeatureClassAnnotation;

                    switch (fClassName.ShapeType)
                    {
                        case esriGeometryType.esriGeometryMultiPatch:
                        case esriGeometryType.esriGeometrySphere:
                        case esriGeometryType.esriGeometryTriangleFan:
                        case esriGeometryType.esriGeometryTriangleStrip:
                        case esriGeometryType.esriGeometryTriangles:
                            return enumCatalogType.FeatureClass3D;

                        case esriGeometryType.esriGeometryPoint:
                        case esriGeometryType.esriGeometryMultipoint:
                            return enumCatalogType.FeatureClassPoint;

                        case esriGeometryType.esriGeometryLine:
                        case esriGeometryType.esriGeometryPolyline:
                            return enumCatalogType.FeatureClassLine;

                        case esriGeometryType.esriGeometryPolygon:
                        case esriGeometryType.esriGeometryBezier3Curve:
                        case esriGeometryType.esriGeometryCircularArc:
                        case esriGeometryType.esriGeometryEllipticArc:
                        case esriGeometryType.esriGeometryEnvelope:
                            return enumCatalogType.FeatureClassArea;

                        default:
                            return enumCatalogType.FeatureClassEmpty;
                    }

                case esriDatasetType.esriDTTable:
                    return enumCatalogType.Table;

                case esriDatasetType.esriDTTerrain:
                    return enumCatalogType.Terrain;
                case esriDatasetType.esriDTTin:
                    return enumCatalogType.Tin;

                case esriDatasetType.esriDTTopology:
                    return enumCatalogType.Topology;

                case esriDatasetType.esriDTRasterCatalog:
                    return enumCatalogType.RasterCatalog;

                case esriDatasetType.esriDTRasterDataset:
                    return enumCatalogType.RasterSet;

                case esriDatasetType.esriDTRasterBand:
                    return enumCatalogType.RasterBand;

                case esriDatasetType.esriDTMosaicDataset:
                    return enumCatalogType.RasterMosaic;

                default:
                    return enumCatalogType.Undefine;
            }
        }
Ejemplo n.º 42
0
        private void AddDataset(XmlWriter writer, IDatasetName datasetName) {
            // Check Parameters
            if (writer == null) { return; }
            if (datasetName == null) { return; }

            // Open Dataset
            IName name = datasetName as IName;
            if (name == null) { return; }
            object o = null;
            try {
                o = name.Open();
            }
            catch { }
            if (o == null) { return; }
            IDataset dataset = o as IDataset;
            if (dataset == null) { return; }
            IFeatureClass featureClass = dataset as IFeatureClass;

            // <Dataset>
            writer.WriteStartElement("Dataset");

            // <Dataset><Name>
            writer.WriteStartElement("Name");
            writer.WriteValue(dataset.Name);
            writer.WriteEndElement();

            // <Dataset><Type>
            string type = string.Empty;
            switch(dataset.Type){
                case esriDatasetType.esriDTFeatureClass:
                    if (featureClass == null) {
                        type += "Unknown";
                        break;
                    }
                    switch (featureClass.FeatureType) {
                        case esriFeatureType.esriFTAnnotation:
                        case esriFeatureType.esriFTDimension:
                        case esriFeatureType.esriFTSimple:
                            type += GeodatabaseUtility.GetDescription(esriDatasetType.esriDTFeatureClass);
                            break;
                        default:
                            type += GeodatabaseUtility.GetDescription(featureClass.FeatureType);
                            break;
                    }          
                    break;
                default:
                    type += GeodatabaseUtility.GetDescription(dataset.Type);
                    break;
            }
            writer.WriteStartElement("Type");
            writer.WriteValue(type);
            writer.WriteEndElement();

            // <Dataset><Geometry>
            string geometry = "-";
            if (featureClass != null) {
                switch (featureClass.FeatureType) {
                    case esriFeatureType.esriFTAnnotation:
                    case esriFeatureType.esriFTDimension:
                        geometry = GeodatabaseUtility.GetDescription(featureClass.FeatureType);
                        break;
                    default:
                        geometry = GeodatabaseUtility.GetDescription(featureClass.ShapeType);
                        break;
                }
            }
            writer.WriteStartElement("Geometry");
            writer.WriteValue(geometry);
            writer.WriteEndElement();

            //if (dataset is IFeatureClass) {
            //    IFeatureClass featureClass = (IFeatureClass)dataset;

            //    // <Dataset><FeatureType>
            //    writer.WriteStartElement("FeatureType");
            //    writer.WriteValue(GeodatabaseUtility.GetDescription(featureClass.FeatureType));
            //    writer.WriteEndElement();

            //    // Add ...<Dataset><ShapeType>
            //    switch (featureClass.FeatureType) {
            //        case esriFeatureType.esriFTAnnotation:
            //        case esriFeatureType.esriFTDimension:
            //            break;
            //        default:
            //            writer.WriteStartElement("ShapeType");
            //            writer.WriteValue(GeodatabaseUtility.GetDescription(featureClass.ShapeType));
            //            writer.WriteEndElement();
            //            break;
            //    }
            //}

            // Get Row Count
            ITable table = dataset as ITable;
            int intRowCount = -1;
            if (table != null) {
                try {
                    intRowCount = table.RowCount(null);
                }
                catch { }
            }

            // <Dataset><RowCount>
            writer.WriteStartElement("RowCount");
            switch(intRowCount){
                case -1:
                    writer.WriteValue("Error");
                    break;
                case 0:
                default:
                    writer.WriteValue(intRowCount.ToString());
                    break;
            }
            writer.WriteEndElement();

            if (intRowCount > 0) {
                if (dataset is IGeoDataset) {
                    IGeoDataset geoDataset = (IGeoDataset)dataset;
                    IEnvelope envelope = geoDataset.Extent;
                    if (envelope != null && !envelope.IsEmpty) {
                        // <Dataset><Extent>
                        writer.WriteStartElement("Extent");

                        // <Dataset><Extent><XMax>
                        writer.WriteStartElement("XMax");
                        writer.WriteValue(envelope.XMax.ToString());
                        writer.WriteEndElement();

                        // <Dataset><Extent><XMin>
                        writer.WriteStartElement("XMin");
                        writer.WriteValue(envelope.XMin.ToString());
                        writer.WriteEndElement();

                        // <Dataset><Extent><YMax>
                        writer.WriteStartElement("YMax");
                        writer.WriteValue(envelope.YMax.ToString());
                        writer.WriteEndElement();

                        // <Dataset><Extent><YMin>
                        writer.WriteStartElement("YMin");
                        writer.WriteValue(envelope.YMin.ToString());
                        writer.WriteEndElement();

                        // <Dataset></Extent>
                        writer.WriteEndElement();

                        // <Dataset><SmallImage>
                        if (DataReportSettings.Default.ShowSmallImage) {
                            string smallImage = System.IO.Path.GetTempFileName();
                            writer.WriteStartElement("SmallImage");
                            writer.WriteValue(smallImage);
                            writer.WriteEndElement();
                            GeodatabaseUtility.CreateBitmap(
                                dataset,
                                DataReportSettings.Default.SmallImageType,
                                DataReportSettings.Default.SmallImageSize,
                                DataReportSettings.Default.SmallImageResolution,
                                DataReportSettings.Default.SmallImageBackgroundColor,
                                smallImage);
                        }

                        // <Dataset><LargeImage>
                        if (DataReportSettings.Default.ShowLargeImage) {
                            string largeImage = System.IO.Path.GetTempFileName();
                            writer.WriteStartElement("LargeImage");
                            writer.WriteValue(largeImage);
                            writer.WriteEndElement();
                            GeodatabaseUtility.CreateBitmap(
                                dataset,
                                DataReportSettings.Default.LargeImageType,
                                DataReportSettings.Default.LargeImageSize,
                                DataReportSettings.Default.LargeImageResolution,
                                DataReportSettings.Default.LargeImageBackgroundColor,
                                largeImage);
                        }
                    }
                }
            }

            ISubtypes subtypes = dataset as ISubtypes;
            if (subtypes != null && subtypes.HasSubtype) {
                int subtypeCode = 0;
                IEnumSubtype enumSubtype = subtypes.Subtypes;
                string subtypeName = enumSubtype.Next(out subtypeCode);
                while (subtypeName != null) {
                    // <Dataset><Sybtype>
                    writer.WriteStartElement("Subtype");

                    // <Dataset><Sybtype><Name>
                    writer.WriteStartElement("Name");
                    writer.WriteValue(subtypeName);
                    writer.WriteEndElement();

                    // Get Row Count
                    IQueryFilter queryFilter = new QueryFilterClass();
                    queryFilter.WhereClause = string.Format("{0} = {1}", subtypes.SubtypeFieldName, subtypeCode.ToString());
                    int rowCount = table.RowCount(queryFilter);

                    // <Dataset><Sybtype><RowCount>
                    writer.WriteStartElement("RowCount");
                    writer.WriteValue(rowCount.ToString());
                    writer.WriteEndElement();

                    // <Dataset></Sybtype>
                    writer.WriteEndElement();

                    // Get Next Subtype
                    subtypeName = enumSubtype.Next(out subtypeCode);
                }
            }

            // </Dataset>
            writer.WriteEndElement();
        }
Ejemplo n.º 43
0
 //public TerrainCatalogItem(IDataset dsTerrain, ICatalogItem parent)
 //    : base(dsTerrain, parent)
 //{
 //}
 public TerrainCatalogItem(IDatasetName dsName, ICatalogItem parent)
     : base(dsName, parent)
 {
 }