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

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

 

/// <summary>  
/// 通过IFeature.Delete方法删除要素  
/// </summary>  
/// <param name="pFeatureclass">要素类</param>  
/// <param name="strWhereClause">查询条件</param>  
public static void DeleteFeatureByIFeature(IFeatureClass pFeatureclass, string strWhereClause)  
{  
    IQueryFilter pQueryFilter = new QueryFilterClass();  
    pQueryFilter.WhereClause = strWhereClause;  
    IFeatureCursor pFeatureCursor = pFeatureclass.Search(pQueryFilter, false);  
    IFeature pFeature = pFeatureCursor.NextFeature();  
    while (pFeature != null)  
    {  
        pFeature.Delete();  
        pFeature = pFeatureCursor.NextFeature();  
    }  
}  

/// <summary>  
/// 通过IFeatureCursor.DeleteFeature方法删除要素  
/// </summary>  
/// <param name="pFeatureclass">要素类</param>  
/// <param name="strWhereClause">查询条件</param>  
public static void DeleteFeatureByIFeatureCursor(IFeatureClass pFeatureclass, string strWhereClause)  
 {  
     IQueryFilter pQueryFilter = new QueryFilterClass();  
     pQueryFilter.WhereClause = strWhereClause;  
     IFeatureCursor pFeatureCursor = pFeatureclass.Update(pQueryFilter, false);  
     IFeature pFeature = pFeatureCursor.NextFeature();  
     while (pFeature != null)  
     {  
         pFeatureCursor.DeleteFeature();  
         pFeature = pFeatureCursor.NextFeature();  
     }  
 }  


/// <summary>  
/// 通过ITable.DeleteSearchedRows方法删除要素  
/// </summary>  
/// <param name="pFeatureclass">要素类</param>  
/// <param name="strWhereClause">查询条件</param>  
public static void DeleteFeatureByITable(IFeatureClass pFeatureclass, string strWhereClause)  
{  
    IQueryFilter pQueryFilter = new QueryFilterClass();  
    pQueryFilter.WhereClause = strWhereClause;  
    ITable pTable = pFeatureclass as ITable;  
pTable.DeleteSearchedRows(pQueryFilter);  
}

 

posted @ 2017-05-21 17:04  wenglabs  阅读(3771)  评论(0编辑  收藏  举报