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'.

如果许多Feature要更新,使用Update比单独更新Feature快.

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接口.

做完这个后,可以导致Geodatabase回避这个Feature用来更新插入cursors的实现

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

[C#]

    //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");
            featureCursor.UpdateFeature(feature);
            Console.WriteLine("The new type: {0}", feature.get_Value(fieldIndex));
            feature = featureCursor.NextFeature();
        }

        System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor);
    }

 

 

相关文章推荐

关于使用featurecursor.updatefeature批量更新要素时遇到的问题

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

UpdateFeature

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

IFeatureCursor.UpdateFeature不能更新MDB的问题

       上周有个同事要我帮忙把土地利用图斑的村名写到BLOCK_CODE字段中,因为只能根据空间关系来做,所以最好写程序。刚开始以为这样的小问题,半个小时不到应该就能解决,没想到折腾了一个下午也...

总结:GIS数据的查找,插入,删除,更新

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接口获取要素类类型、获取满足查询...

Mongodb学习日志(二):UPDATE及修改器

UPDATE 修改器
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:IFeatureClass.Update 修改Feature
举报原因:
原因补充:

(最多只允许输入30个字)