首页 > 代码库 > ArcGIS Engine检索要素集、要素类和要素

ArcGIS Engine检索要素集、要素类和要素

转自原文 ArcGIS Engine检索要素集、要素类和要素

 

[csharp] view plain copy print?
  1.         /// <summary>  
  2.         /// 获取所有要素集  
  3.         /// </summary>  
  4.         /// <param name="workspace">工作空间对象</param>  
  5.         /// <returns>要素集列表</returns>  
  6.         public static List<IFeatureDataset> GetAllFeatureClass(IWorkspace workspace)  
  7.         {  
  8.             IEnumDataset dataset = workspace.get_Datasets(esriDatasetType.esriDTFeatureDataset);  
  9.             IFeatureDataset featureDataset = dataset.Next() as IFeatureDataset;  
  10.   
  11.   
  12.             List<IFeatureDataset> featureDatasetList = new List<IFeatureDataset>();  
  13.             while (featureDataset != null)  
  14.             {  
  15.                 featureDatasetList.Add(featureDataset);  
  16.                 featureDataset = dataset.Next() as IFeatureDataset;  
  17.             }  
  18.             return featureDatasetList;  
  19.         }  
[csharp] view plain copy print?
  1. /// <summary>  
  2. /// 获取所有要素类  
  3. /// </summary>  
  4. /// <param name="featureDataset">要素集</param>  
  5. /// <returns>要素类列表</returns>  
  6. public static List<IFeatureClass> GetAllFeatureClass(IFeatureDataset featureDataset)  
  7. {  
  8.     IFeatureClassContainer featureClassContainer = (IFeatureClassContainer)featureDataset;  
  9.     IEnumFeatureClass enumFeatureClass = featureClassContainer.Classes;  
  10.     IFeatureClass featureClass = enumFeatureClass.Next();  
  11.   
  12.     List<IFeatureClass> featureClassList = new List<IFeatureClass>();  
  13.     while (featureClass != null)  
  14.     {  
  15.         featureClassList.Add(featureClass);  
  16.         featureClass = enumFeatureClass.Next();  
  17.     }  
  18.     return featureClassList;  
  19. }  
[csharp] view plain copy print?
  1. /// <summary>  
  2. /// 获取所有要素  
  3. /// </summary>  
  4. /// <param name="featureClass">要素类</param>  
  5. /// <returns>要素列表</returns>  
  6. public static List<IFeature> GetAllFeatureClass(IFeatureClass featureClass)  
  7. {  
  8.     List<IFeature> featureList = new List<IFeature>();  
  9.     IFeatureCursor featureCursor = featureClass.Search(null, false);  
  10.     IFeature feature = featureCursor.NextFeature();  
  11.   
  12.     while (feature != null)  
  13.     {  
  14.         featureList.Add(feature);  
  15.         feature = featureCursor.NextFeature();  
  16.     }  
  17.     return featureList;  

 

ArcGIS Engine检索要素集、要素类和要素