IFeatureClass.Update 修改Feature

转载 2007年09月20日 10:59:00

Update opens an update cursor on the features specified by an attribute and/or spatial query as specified in an IQueryDef. If a number of features selected by a particular query are to be updated and each feature is to be updated to a separate value then the update cursor is faster than doing an individual feature level update for each feature. The update is performed on the current 'cursor position'.


Update cursors can be used on a custom object, with guaranteed polymorphic behavior. Update cursors can be used either inside or outside of an edit session. If used inside an edit session, the changes are not committed to the base table until the edit session is saved. Network feature classes, Topology feature classes, feature classes that participate in composite relationships or other relationships with messaging and some custom feature classes may only be updated within an edit session. If you attempt to use an update cursor on one of these classes outside of an edit session, it will fail.  In addition, edits to features that participate in a Topology or Geometric Network must be bracketed within an edit operation.

If the insert cursor is used on non-simple features (such as network features), the cursor will revert to using IFeature::Store.

If you are creating custom features that do not have polymorphic behavior on creation, update and deletion you can implement the IObjectClassInfo interface to set the CanBypassStoreMethod property to true. Doing this will cause the Geodatabase to bypass the custom feature implementation for update and insert cursors used with that custom feature class. Also, you can implement the IObjectClassInfo2 interface on the object class extension and return true to CanBypassEditSession method to indicate the those custom features can be updated outside of an edit session.

如果你要创建自定义的Features(且在建立/修改/删除时不包含多态行为),你可以通过将CanBypassStoreMethod 属性设为true来实现 IObjectClassInfo接口.


你也可以实现IObjectClassInfo2接口,CanBypassEditSession 返回true,表明这些Features可以在一个edit session外被更新.


    //The following function uses an update cursor to change the value of a particular
    //field for a set of features in a feature class.
    public void IFeatureClass__Update(IFeatureClass featureClass)
        //cast the spatial filter to the IQueryFilter interface
        IQueryFilter queryFilter = new QueryFilterClass();
        queryFilter.WhereClause = "subtype = 'COM'";
        queryFilter.SubFields = "FID, Type";
        //preform the search on the supplied feature class; use a cursor to hold the results
        IFeatureCursor featureCursor = featureClass.Update(queryFilter, false);

        //get the first feature returned
        IFeature feature = featureCursor.NextFeature();

        //get the "Area" field
        IFields fields = featureCursor.Fields;
        int fieldIndex = fields.FindField("Type");

        //loop through all of the features and update the field to its new value
        while (feature != null)
            Console.WriteLine("The old type: {0}", feature.get_Value(fieldIndex));
            feature.set_Value(fieldIndex, "ABC");
            Console.WriteLine("The new type: {0}", feature.get_Value(fieldIndex));
            feature = featureCursor.NextFeature();






IFeatureLayer zdlyr = AEmethod.FindFeatLyr(this.axMapControl1.Map, "ZD");             IFeatureCurso...


Updating features This topic explains how to updates features in a geodatabase feature class. Two a...




1、查找数据 1)、利用FeaturCursor进行空间查询 //利用构造的Envelope(矩形框),查找和Envelope相交的FeatureClass的要素集 //结果数据利用循环Feat...

《IFeatureClass接口》的继续讨论 - [ArcEnine接口]

IFeatureClass.Select Method 返回包含对象IDs的选择。 [Visual Basic.NET]        Public Function Select(ByVal Q...

IFeatureClass 空间查询与属性查询示例

/// /// pFeatureLayer空间查询 /// /// /// /// publi...

IFeatureClass.Search(IQuery Filter,bool Recycling)参数说明

IFeatureClass的Search方法大家经常用到,很多人对Search方法的其中一个参数bool Recycling不是很理解。 目前网上关于这个参数的意义的解释有两个版本: 1.第一版本...


IFeatureClass 用于访问控制要素类行为和属性的成员 IFeatureClass接口是获取和设置要素类属性的主要接口。例如,使用IFeatureClass接口获取要素类类型、获取满足查询...


您举报文章:IFeatureClass.Update 修改Feature