[C#] [ArcGIS] [Engine] 对选择的要素进行数据更新操作

/// <summary>
/// 获取选择要素并进行更新操作
/// </summary>
/// <param name="featureLayer">图层要素对象</param>
/// <returns>返回游标对象</returns>
public static IFeatureCursor get_SelectedFeatures_Update(IFeatureLayer featureLayer)
{
    ICursor cursor = null;
    IFeatureCursor featureCursor = null;
    if (featureLayer== null) 
    {
        return null;
    }
    // 选定的特征集
    IFeatureSelection featureSelection = featureLayer as IFeatureSelection;

    // 由于 ISelectionSet2 继承自 ISelectionSet 接口并且可以通过 SelectionSet 类对象进行实现
    // 所以这里将 ISelectionSet 类型的 SelectionSet 转换为 ISelectionSet2
    ISelectionSet2 selectionSet2= featureSelection.SelectionSet as ISelectionSet2;       

    // 在 ISelectionSet 中只有 Search 方法,可以进行搜索
    // 在 ISelectionSet2 中添加了 Update 方法,可以进行更新、搜索
    selectionSet2.Update(null, false, out cursor);
    featureCursor = cursor as IFeatureCursor;
    return featureCursor;         
}

猜你喜欢

转载自blog.csdn.net/weixin_42015762/article/details/83068264