Exemplo n.º 1
0
        private void CoverageGeneralPropertyPage_Load(object sender, EventArgs e)
        {
            this.txtName.Text = (this.icoverageName_0 as IDatasetName).Name;
            IEnumDatasetName featureClassNames = (this.icoverageName_0 as IFeatureDatasetName2).FeatureClassNames;

            featureClassNames.Reset();
            IDatasetName name2 = featureClassNames.Next();

            string[] items = new string[3];
            while (name2 != null)
            {
                items[0] = name2.Name;
                items[1] = this.string_0[(int)(name2 as ICoverageFeatureClassName).Topology];
                if ((name2 as ICoverageFeatureClassName).HasFAT)
                {
                    items[2] = "True";
                }
                else
                {
                    items[2] = "False";
                }
                ListViewItem item = new ListViewItem(items)
                {
                    Tag = name2
                };
                this.listView1.Items.Add(item);
                name2 = featureClassNames.Next();
            }
        }
Exemplo n.º 2
0
        public IList <RasterName> get_RasterDataSetNames()
        {
            IList <RasterName> names = new List <RasterName>();

            if (this.m_workSpace != null)
            {
                IEnumDatasetName   enumDatasetName   = m_workSpace.get_DatasetNames(esriDatasetType.esriDTRasterCatalog);
                IDatasetName       datasetName       = enumDatasetName.Next();//DataSet的名字
                IRasterWorkspaceEx rasterWorkspaceEx = m_workSpace as IRasterWorkspaceEx;
                while (datasetName != null)
                {
                    RasterName name = new RasterName();
                    name.RasDCName = datasetName.Name.ToString();
                    IRasterCatalogName rasterCaName  = (IRasterCatalogName)datasetName;
                    IRasterCatalog     rasterCatalog = rasterWorkspaceEx.OpenRasterCatalog(name.RasDCName);
                    ITable             table         = rasterCatalog as ITable;
                    ICursor            cursor        = table.Search(null, false);
                    IRow row = cursor.NextRow();
                    while (row != null)
                    {
                        name.RDSName.Add(row.get_Value(cursor.FindField("NAME")).ToString());

                        row = cursor.NextRow();
                    }
                    names.Add(name);
                    datasetName = enumDatasetName.Next();
                }
            }
            return(names);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets feature class names in the feature dataset with the given name. Pass the empty string
        /// to get all feature classes in all feature datasets. Right now it only works with the
        /// following esriGeometryType values: esriGeometryPoint, esriGeometryPolyline,
        /// esriGeometryPolygon, esriGeometryAny (point, line, polygon).
        /// </summary>
        /// <param name="geomType">geometry type to get</param>
        /// <param name="ws">workspace</param>
        /// <param name="datasetName">name of feature dataset to get feature classes in</param>
        /// <returns>list of IDatasetName objects for the feature classes</returns>
        public static List <IDatasetName> GetFeatureClassNames(esriGeometryType geomType, IWorkspace ws,
                                                               string datasetName)
        {
            List <IDatasetName> outDsNames = new List <IDatasetName>();

            if (datasetName != "")
            {
                IEnumDatasetName dsNames = ws.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
                IDatasetName     dsName  = dsNames.Next();
                while (dsName != null)
                {
                    if (dsName.Name == datasetName)
                    {
                        outDsNames.AddRange(GetFeatureClassNames(geomType, (IFeatureDatasetName)dsName));
                        break;
                    }
                }
            }
            else
            {
                outDsNames.AddRange(GetFeatureClassNames(geomType, ws));
                IEnumDatasetName dsNamesFds = ws.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
                IDatasetName     dsNameFds  = dsNamesFds.Next();
                while (dsNameFds != null)
                {
                    outDsNames.AddRange(GetFeatureClassNames(geomType, (IFeatureDatasetName)dsNameFds));
                    dsNameFds = dsNamesFds.Next();
                }
            }
            return(outDsNames);
        }
Exemplo n.º 4
0
        public IList <FeatureName> get_FeatureDataSetNames() //遍历矢量要素集
        {
            IList <FeatureName> names = new List <FeatureName>();

            if (this.m_workSpace != null)
            {
                IFeatureClass    feaClass;
                IEnumDatasetName enumDatasetName = m_workSpace.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
                IDatasetName     datasetName     = enumDatasetName.Next();//DataSet的名字
                while (datasetName != null)
                {
                    FeatureName name = new FeatureName();
                    name.FeatDSName = datasetName.Name.ToString();
                    IFeatureDatasetName featureDatasetName = (IFeatureDatasetName)datasetName;
                    IEnumDatasetName    enumDatasetNameFC  = featureDatasetName.FeatureClassNames; //是FeatureClass的名字集合
                    IDatasetName        datasetNameFC      = enumDatasetNameFC.Next();
                    while (datasetNameFC != null)
                    {
                        //添加FeatureClass的名字
                        name.FCName.Add(datasetNameFC.Name.ToString());
                        feaClass = ((IFeatureWorkspace)m_workSpace).OpenFeatureClass(datasetNameFC.Name.ToString());
                        name.ShapType.Add(feaClass.ShapeType);
                        name.FeatureType.Add(feaClass.FeatureType);
                        datasetNameFC = enumDatasetNameFC.Next();
                    }
                    names.Add(name);

                    datasetName = enumDatasetName.Next();
                }
            }
            return(names);
        }
Exemplo n.º 5
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);
                 }
             }
         }
     }
 }
 private bool method_1(IWorkspace iworkspace_0, esriDatasetType esriDatasetType_1, string string_0)
 {
     try
     {
         if (esriDatasetType_1 == esriDatasetType.esriDTFeatureDataset)
         {
             IEnumDatasetName name = iworkspace_0.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
             name.Reset();
             for (IDatasetName name2 = name.Next(); name2 != null; name2 = name.Next())
             {
                 string[] strArray = name2.Name.Split(new char[] { '.' });
                 string   str      = strArray[strArray.Length - 1].ToLower();
                 if (string_0 == str)
                 {
                     return(true);
                 }
             }
             return(false);
         }
         if ((iworkspace_0 as IWorkspace2).get_NameExists(esriDatasetType_1, string_0))
         {
             return(true);
         }
     }
     catch
     {
     }
     return(false);
 }
Exemplo n.º 7
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);
     }
 }
Exemplo n.º 8
0
        /// 获得个人地理数据库中要素类的名称
        /// </summary>
        /// <param name="pAccessWorkSpace">个人地理数据库工作空间</param>
        /// <returns pArrayFeatureClassName>个人地理数据库中要素类的名称</returns>
        public static IArray GetFeactureClassName_From_AccessWorkSpace(IWorkspace pAccessWorkSpace)
        {
            IArray pArrayFeatureClassName = new ArrayClass();

            //遍历直接位于地理数据库下的要素类FeatureClass
            IEnumDatasetName enumDatasetName = ((IWorkspace)pAccessWorkSpace).get_DatasetNames(esriDatasetType.esriDTFeatureClass);
            IDatasetName     datasetName     = enumDatasetName.Next();

            while (datasetName != null)
            {
                pArrayFeatureClassName.Add(datasetName.Name.ToString());
                datasetName = enumDatasetName.Next();//推进器
            }

            //遍历位于地理数据库数据集featuredataset下的要素类
            enumDatasetName = ((IWorkspace)pAccessWorkSpace).get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
            datasetName     = enumDatasetName.Next();
            while (datasetName != null)
            {
                IFeatureDatasetName featureDatasetName = (IFeatureDatasetName)datasetName;
                IEnumDatasetName    enumDatasetNameFC  = featureDatasetName.FeatureClassNames;
                IDatasetName        datasetNameFC      = enumDatasetNameFC.Next();
                while (datasetNameFC != null)
                {
                    pArrayFeatureClassName.Add(datasetNameFC.Name.ToString());
                    datasetNameFC = enumDatasetNameFC.Next();//推进器
                }
                datasetName = enumDatasetName.Next();
            }

            return(pArrayFeatureClassName);
        }
Exemplo n.º 9
0
        public IList <FCName> get_FeatureClassName()
        {
            IList <FCName> names = new List <FCName>();

            if (this.m_workSpace != null)
            {
                FCName           fcname;
                IFeatureClass    feaClass          = null;
                IEnumDatasetName enumDatasetNameFC = m_workSpace.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
                IDatasetName     datasetNameFC     = enumDatasetNameFC.Next();
                try
                {
                    while (datasetNameFC != null)
                    {
                        feaClass           = ((IFeatureWorkspace)m_workSpace).OpenFeatureClass(datasetNameFC.Name.ToString());
                        fcname.Name        = datasetNameFC.Name.ToString();
                        fcname.ShapType    = feaClass.ShapeType.ToString();
                        fcname.FeatureType = feaClass.FeatureType.ToString();
                        names.Add(fcname);
                        datasetNameFC = enumDatasetNameFC.Next();
                    }
                }
                catch (Exception ee)
                {
                }
            }
            return(names);
        }
Exemplo n.º 10
0
        public void CheckIWorkspaceMethods()
        {
            IEnumDatasetName edsn = ws.get_DatasetNames(esriDatasetType.esriDTFeatureClass);

            Assert.IsTrue(edsn != null);
            IDatasetName dsn;
            //test IEnumDatasetName.Next
            int layerCount = 0;

            while ((dsn = edsn.Next()) != null)
            {
                Assert.IsNotNull(dsn);
                layerCount += 1;
                System.Diagnostics.Debug.WriteLine(dsn.Name);
                System.Diagnostics.Debug.WriteLine(dsn.Category);
                System.Diagnostics.Debug.WriteLine(dsn.Type);
            }
            //test IEnumDatasetName.Reset
            edsn.Reset();
            for (int i = 0; i < layerCount; i++)
            {
                dsn = edsn.Next();
                Assert.IsNotNull(dsn);
            }
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 13
0
        public static IFeatureClassName GetFeatureClassName(IFeatureDatasetName pFeatureDatasetName, string featureClassName)
        {
            IDatasetName pContainDSName;

            pContainDSName = (IDatasetName)pFeatureDatasetName;
            IEnumDatasetName  pEnumDsName4FC = (IEnumDatasetName)pFeatureDatasetName.FeatureClassNames;
            IFeatureClassName pfeaClsName    = (IFeatureClassName)pEnumDsName4FC.Next();

            IDatasetName pFC_DSName;

            try
            {
                while (pfeaClsName != null)
                {
                    pFC_DSName = (IDatasetName)pfeaClsName;
                    if (pFC_DSName.Name == featureClassName)
                    {
                        return(pfeaClsName);
                    }

                    pfeaClsName = (IFeatureClassName)pEnumDsName4FC.Next();
                }
            }
            catch
            {
            }
            return(null);
        }
Exemplo n.º 14
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);
     }
 }
Exemplo n.º 15
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();
            }
        }
Exemplo n.º 16
0
        private void button5_Click(object sender, EventArgs e)
        {
            axMapControl1.Map.ClearLayers();
            string     _pInstance = "sde:oracle11g:172.31.2.90/orcl";
            string     _pUser     = "******";
            string     _pPassword = "******";
            string     _pVersion  = "sde.DEFAULT";
            IWorkspace pWS        = null;

            pWS = GetSDEWorkspace(_pInstance, _pUser, _pPassword, _pVersion) as IWorkspace;

            try
            {
                IEnumDatasetName pEDatasetNames = pWS.get_DatasetNames(esriDatasetType.esriDTAny);



                IDatasetName pDatasetName = pEDatasetNames.Next();
                while (pDatasetName != null)
                {
                    string name = pDatasetName.Name;
                    if (pDatasetName.Name.Equals("CSTEST.QDTEST"))
                    {
                        if (pDatasetName.Type.Equals(esriDatasetType.esriDTFeatureDataset))
                        {
                            IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pWS;
                            IFeatureDataset   pFeatureDataset   = pFeatureWorkspace.OpenFeatureDataset("CSTEST.QDTEST");
                            IEnumDataset      pEnumDataset      = pFeatureDataset.Subsets;
                            pEnumDataset.Reset();
                            IDataset pDataset = pEnumDataset.Next();
                            comboBox1.Items.Clear();

                            while (pDataset != null)
                            {
                                if (pDataset.Type == esriDatasetType.esriDTFeatureClass)
                                {
                                    comboBox1.Items.Add(pDataset.Name);
                                    if (pDataset is IFeatureClass)
                                    {
                                        IFeatureLayer pFeatureLayer = new FeatureLayerClass();
                                        pFeatureLayer.FeatureClass = pFeatureWorkspace.OpenFeatureClass(pDataset.Name);
                                        pFeatureLayer.Name         = pFeatureLayer.FeatureClass.AliasName;

                                        axMapControl1.Map.AddLayer(pFeatureLayer);
                                    }
                                }
                                pDataset = pEnumDataset.Next();
                            }
                            comboBox1.Text = comboBox1.Items[0].ToString();
                        }
                    }

                    pDatasetName = pEDatasetNames.Next();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }
        }
Exemplo n.º 17
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));
                        }
                    }
                }
            }
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
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;
        }
Exemplo n.º 20
0
 private void method_1()
 {
     if (this.idatasetName_0 != null)
     {
         this.txtruleIDFldName.ReadOnly       = true;
         this.txtoverrideFldName.ReadOnly     = true;
         this.txtruleIDFldName.Text           = (this.idatasetName_0 as IRepresentationClassName).RuleIDFieldName;
         this.txtoverrideFldName.Text         = (this.idatasetName_0 as IRepresentationClassName).OverrideFieldName;
         this.txtRepresentationName.Text      = this.idatasetName_0.Name;
         this.rdoRequireShapeOverride.Checked = this.irepresentationClass_0.RequireShapeOverride;
     }
     else
     {
         IRepresentationWorkspaceExtension extension = this.method_0(this.ifeatureClass_0);
         string str  = this.ifeatureClass_0.AliasName + "_Rep";
         string str2 = "RuleID";
         string str3 = "Override";
         if (extension.get_FeatureClassHasRepresentations(this.ifeatureClass_0))
         {
             IList <string>   list = new List <string>();
             IEnumDatasetName name = extension.get_FeatureClassRepresentationNames(this.ifeatureClass_0);
             for (IDatasetName name2 = name.Next(); name2 != null; name2 = name.Next())
             {
                 list.Add(name2.Name);
             }
             int    num  = 1;
             string item = str;
             while (list.IndexOf(item) != -1)
             {
                 item = str + num.ToString();
                 num++;
             }
             str  = item;
             num  = 1;
             item = str2;
             while (this.ifeatureClass_0.FindField(item) != -1)
             {
                 item = str2 + "_" + num.ToString();
                 num++;
             }
             str2 = item;
             num  = 1;
             item = str3;
             while (this.ifeatureClass_0.FindField(item) != -1)
             {
                 item = str3 + "_" + num.ToString();
                 num++;
             }
             str3 = item;
         }
         this.txtruleIDFldName.Text      = str2;
         this.txtoverrideFldName.Text    = str3;
         this.txtRepresentationName.Text = str;
     }
 }
Exemplo n.º 21
0
        /// <summary>
        /// 导入图层(导入一个MDB中的所有图层)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_InputLayer_Click(object sender, EventArgs e)
        {
            OpenFileDialog OpenMDBFrm = new OpenFileDialog();

            OpenMDBFrm.Filter = "ArcGis PDB 文件|*.mdb";
            if (DialogResult.OK == OpenMDBFrm.ShowDialog())
            {
                string sGetPDBFileName = OpenMDBFrm.FileName;
                try
                {
                    IWorkspace             pWS         = null;
                    IPropertySet           pPropSet    = new PropertySetClass();
                    AccessWorkspaceFactory pAccessFact = new AccessWorkspaceFactoryClass();
                    pPropSet.SetProperty("DATABASE", sGetPDBFileName);
                    pWS         = pAccessFact.Open(pPropSet, 0);
                    pAccessFact = null;
                    IEnumDatasetName pEnumDatasetName = pWS.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
                    IDatasetName     pDataSetName     = pEnumDatasetName.Next();
                    if (m_Layers == null)
                    {
                        m_Layers = new List <IFeatureClass>();
                    }
                    this.combox_layers.Items.Clear();
                    while (pDataSetName != null)
                    {
                        IFeatureClass pGetFeaCls = (pWS as IFeatureWorkspace).OpenFeatureClass(pDataSetName.Name);
                        if (pGetFeaCls != null)
                        {
                            m_Layers.Add(pGetFeaCls);
                            this.combox_layers.Items.Add(pDataSetName.Name);
                        }
                        pDataSetName = pEnumDatasetName.Next();
                    }
                    ////////将这些图层加载到界面上////////
                    ////////默认选中一个
                    if (this.combox_layers.Items.Count > 0)
                    {
                        this.combox_layers.SelectedIndex = 0;
                    }
                    string        sSelectLayerName = this.combox_layers.Text.Trim();
                    IFeatureClass GetLayerFeacls   = GetFeaClsByName(sSelectLayerName);
                    AddALayer(GetLayerFeacls);
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pEnumDatasetName);
                }
                catch (Exception eError)
                {
                    if (ModData.SysLog == null)
                    {
                        ModData.SysLog = new SysCommon.Log.clsWriteSystemFunctionLog();
                    }
                    ModData.SysLog.Write(eError);
                }
            }
        }
Exemplo n.º 22
0
        private static IEnumerable <string> GetFeatureDataSetNames(IWorkspace workspace)
        {
            IEnumDatasetName datasetNames = workspace.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
            IDatasetName     name         = datasetNames.Next();

            while (name != null)
            {
                yield return(name.Name);

                name = datasetNames.Next();
            }
        }
Exemplo n.º 23
0
        private void btnGetNames_Click(object sender, EventArgs e)
        {
            //
            this.dataBaseSets.AppendFeaTB.Clear();//yjl20110815
            this.Cursor = Cursors.WaitCursor;
            IFeatureWorkspace pWksSource = this.ucDataConnectSource.GetWks() as IFeatureWorkspace;

            if (pWksSource == null)
            {
                this.Cursor = Cursors.Default;
                return;
            }

            //获得名称
            IWorkspace       pWks      = pWksSource as IWorkspace;
            IEnumDatasetName pEnumName = pWks.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
            IDatasetName     pName     = pEnumName.Next();

            while (pName != null)
            {
                DataRow dr = this.dataBaseSets.AppendFeaTB.NewRow();
                dr["colChecked"]     = false;
                dr["colDatasetName"] = pName.Name;
                dr["colAliasName"]   = pName.Name;
                dr["colDataType"]    = "数据集";

                this.dataBaseSets.AppendFeaTB.Rows.Add(dr);

                pName = pEnumName.Next();
            }

            //要素类
            pEnumName = pWks.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
            pName     = pEnumName.Next();
            while (pName != null)
            {
                DataRow dr = this.dataBaseSets.AppendFeaTB.NewRow();
                dr["colChecked"]     = false;
                dr["colDatasetName"] = pName.Name;

                //要素类
                IFeatureWorkspace pFeawks = pWks as IFeatureWorkspace;
                IFeatureClass     pFeacls = pFeawks.OpenFeatureClass(pName.Name);
                dr["colAliasName"] = pFeacls.AliasName;
                dr["colDataType"]  = "要素类";

                this.dataBaseSets.AppendFeaTB.Rows.Add(dr);

                pName = pEnumName.Next();
            }

            this.Cursor = Cursors.Default;
        }
Exemplo n.º 24
0
        /// <summary>
        /// 获取工作空间下指定类型数据集名称
        /// </summary>
        /// <param name="pWorkspace">工作空间</param>
        /// <param name="aDatasetTyp">数据集类型</param>
        /// <returns></returns>
        private List <string> GetDatasetNames(IWorkspace pWorkspace, esriDatasetType aDatasetTyp)
        {
            List <string>    DatasetNames     = new List <string>();
            IEnumDatasetName pEnumDatasetName = pWorkspace.get_DatasetNames(aDatasetTyp);
            IDatasetName     pDatasetName     = pEnumDatasetName.Next();

            while (pDatasetName != null)
            {
                DatasetNames.Add(pDatasetName.Name);
                pDatasetName = pEnumDatasetName.Next();
            }
            return(DatasetNames);
        }
Exemplo n.º 25
0
 public void FillTreeViewWithDatasetNames(IWorkspace iworkspace_1, TreeView treeView_0)
 {
     try
     {
         treeView_0.Nodes.Clear();
         if (iworkspace_1 != null)
         {
             TreeNode         node;
             IEnumDatasetName subsetNames;
             IDatasetName     name4;
             IEnumDatasetName name = iworkspace_1.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
             name.Reset();
             for (IDatasetName name2 = name.Next(); name2 != null; name2 = name.Next())
             {
                 node = new TreeNode(name2.Name)
                 {
                     Tag = name2.Name
                 };
                 treeView_0.Nodes.Add(node);
                 subsetNames = name2.SubsetNames;
                 subsetNames.Reset();
                 name4 = subsetNames.Next();
                 while (name4 != null)
                 {
                     if (name4.Type == esriDatasetType.esriDTFeatureClass)
                     {
                         TreeNode node2 = new TreeNode(name4.Name)
                         {
                             Tag = name4
                         };
                         node.Nodes.Add(node2);
                     }
                     name4 = subsetNames.Next();
                 }
             }
             subsetNames = iworkspace_1.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
             subsetNames.Reset();
             for (name4 = subsetNames.Next(); name4 != null; name4 = subsetNames.Next())
             {
                 node = new TreeNode(name4.Name)
                 {
                     Tag = name4.Name
                 };
                 treeView_0.Nodes.Add(node);
             }
         }
     }
     catch
     {
     }
 }
Exemplo n.º 26
0
        private static IDatasetName GetDatasetNameFromContainer(IWorkspace workspace, string container, string dataset, esriDatasetType type)
        {
            //look for data in all FeatureDatasets
            IEnumDatasetName containers = workspace.DatasetNames[esriDatasetType.esriDTFeatureDataset];
            IDatasetName     name1      = containers.Next();

            while (name1 != null)
            {
                if (name1.Name.ToLower() == container.ToLower())
                {
                    break;
                }
                name1 = containers.Next();
            }

            //look for data in all containers (feature datasets are not containers, why I don't know)
            //containers are rasters (contain bands), coverage feature classes (contain arc, lines, ...), etc.
            //find the container
            if (name1 == null)
            {
                containers = workspace.DatasetNames[esriDatasetType.esriDTContainer];
                name1      = containers.Next();
                while (name1 != null)
                {
                    if (name1.Name.ToLower() == container.ToLower())
                    {
                        break;
                    }
                    name1 = containers.Next();
                }
                if (name1 == null)
                {
                    return(null);
                }
            }

            // look for data in the feature dataset
            IEnumDatasetName names = name1.SubsetNames;
            IDatasetName     name2 = names.Next();

            while (name2 != null)
            {
                if (name2.Name.ToLower() == dataset.ToLower())
                {
                    return(name2);
                }
                name2 = names.Next();
            }
            return(null);
        }
Exemplo n.º 27
0
        private void Load3DLayers()
        {
            IWorkspace wsSource = GISOpr.getInstance().WorkSpace;
            // get 3D FeatureClass
            IEnumDatasetName enDatasetName = wsSource.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
            IDatasetName     dsName3D      = enDatasetName.Next();

            while (dsName3D != null)
            {
                if ((dsName3D as IFeatureClassName).ShapeType == esriGeometryType.esriGeometryMultiPatch)
                {
                    ICatalogItem curItem = new FeatureClassCatalogItem(dsName3D, null);
                    TreeNode     node3D  = this.m_Node3D.Nodes.Add(curItem.Name);
                    node3D.ImageIndex         = 19;
                    node3D.SelectedImageIndex = 19;

                    node3D.Tag = curItem;
                }

                dsName3D = enDatasetName.Next();
            }

            // FeatureDataset底下的3维FeatureClass
            enDatasetName = wsSource.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
            IDatasetName dsContainer = enDatasetName.Next();

            while (dsContainer != null)
            {
                IEnumDatasetName enDsName3D = dsContainer.SubsetNames;
                dsName3D = enDsName3D.Next();
                while (dsName3D != null)
                {
                    if ((dsName3D as IFeatureClass).ShapeType == esriGeometryType.esriGeometryMultiPatch)
                    {
                        ICatalogItem curItem = new FeatureClassCatalogItem(dsName3D, null);
                        TreeNode     node3D  = this.m_Node3D.Nodes.Add(curItem.Name);
                        node3D.ImageIndex         = 19;
                        node3D.SelectedImageIndex = 19;

                        node3D.Tag = curItem;
                    }

                    dsName3D = enDsName3D.Next();
                }

                dsContainer = enDatasetName.Next();
            }

            m_Node3D.Expand();
        }
Exemplo n.º 28
0
        public static List <string> list_fcs_in_gdb(string ws)
        {
            List <string>     fc_names = new List <string>();
            IWorkspaceFactory GdbWsF   = new FileGDBWorkspaceFactory();
            IWorkspace        GdbWs    = GdbWsF.OpenFromFile(ws, 0);
            IEnumDatasetName  ds_names = GdbWs.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
            IDatasetName      ds_name  = ds_names.Next();

            while (ds_name != null)
            {
                fc_names.Add(ds_name.Name);
                ds_name = ds_names.Next();
            }
            return(fc_names);
        }
Exemplo n.º 29
0
        private void CargarModelos(string sRuta)
        {
            IWorkspaceFactory pWF        = new RasterWorkspaceFactoryClass();
            IWorkspace        pWorkspace = pWF.OpenFromFile(sRuta, 0);

            IEnumDatasetName pEnumDS = pWorkspace.get_DatasetNames(esriDatasetType.esriDTRasterDataset);
            IDatasetName     pDS     = pEnumDS.Next();

            lvwModelos.Items.Clear();
            while (pDS != null)
            {
                lvwModelos.Items.Add(pDS.Name.ToUpper());
                pDS = pEnumDS.Next();
            }
        }
Exemplo n.º 30
0
        public void Tranversal()
        {
            if (this.Source == null)
            {
                return;
            }

            IEnumDatasetName enDSN  = Source.get_DatasetNames(esriDatasetType.esriDTAny);
            IDatasetName     dsName = enDSN.Next();

            while (dsName != null)
            {
                dsName = enDSN.Next();
            }
        }