ArcGIS Engine中删除要素的几种方法总结

转自原文 ArcGIS Engine中删除要素的几种方法总结

 

  1. /// <summary>  
  2. /// 通过IFeature.Delete方法删除要素  
  3. /// </summary>  
  4. /// <param name="pFeatureclass">要素类</param>  
  5. /// <param name="strWhereClause">查询条件</param>  
  6. public static void DeleteFeatureByIFeature(IFeatureClass pFeatureclass, string strWhereClause)  
  7. {  
  8.     IQueryFilter pQueryFilter = new QueryFilterClass();  
  9.     pQueryFilter.WhereClause = strWhereClause;  
  10.     IFeatureCursor pFeatureCursor = pFeatureclass.Search(pQueryFilter, false);  
  11.     IFeature pFeature = pFeatureCursor.NextFeature();  
  12.     while (pFeature != null)  
  13.     {  
  14.         pFeature.Delete();  
  15.         pFeature = pFeatureCursor.NextFeature();  
  16.     }  
  17. }  
  1. /// <summary>  
  2.  /// 通过IFeatureCursor.DeleteFeature方法删除要素  
  3.  /// </summary>  
  4.  /// <param name="pFeatureclass">要素类</param>  
  5.  /// <param name="strWhereClause">查询条件</param>  
  6.  public static void DeleteFeatureByIFeatureCursor(IFeatureClass pFeatureclass, string strWhereClause)  
  7.  {  
  8.      IQueryFilter pQueryFilter = new QueryFilterClass();  
  9.      pQueryFilter.WhereClause = strWhereClause;  
  10.      IFeatureCursor pFeatureCursor = pFeatureclass.Update(pQueryFilter, false);  
  11.      IFeature pFeature = pFeatureCursor.NextFeature();  
  12.      while (pFeature != null)  
  13.      {  
  14.          pFeatureCursor.DeleteFeature();  
  15.          pFeature = pFeatureCursor.NextFeature();  
  16.      }  
  17.  }  
  1. /// <summary>  
  2. /// 通过ITable.DeleteSearchedRows方法删除要素  
  3. /// </summary>  
  4. /// <param name="pFeatureclass">要素类</param>  
  5. /// <param name="strWhereClause">查询条件</param>  
  6. public static void DeleteFeatureByITable(IFeatureClass pFeatureclass, string strWhereClause)  
  7. {  
  8.     IQueryFilter pQueryFilter = new QueryFilterClass();  
  9.     pQueryFilter.WhereClause = strWhereClause;  
  10.     ITable pTable = pFeatureclass as ITable;  
  11.     pTable.DeleteSearchedRows(pQueryFilter);  

 

posted @ 2017-01-19 09:14  wenglabs  阅读(562)  评论(0编辑  收藏  举报