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...
  • wd_chenzihui
  • wd_chenzihui
  • 2016年01月05日 15:21
  • 1094

IFeatureCursor.UpdateFeature不能更新MDB的问题

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

UpdateFeature

Updating features This topic explains how to updates features in a geodatabase feature class. Two a...
  • kone0611
  • kone0611
  • 2016年03月10日 09:28
  • 674

获取和更新FeatureClass的Extent

在FeatureClass中编辑,删除,或添加要素后,可用如下的代码手动更新一下其Extent   ((IFeatureClassManage)pFeatureClass).UpdateE...
  • kone0611
  • kone0611
  • 2017年06月12日 20:09
  • 207

ArcEngine修改字段名称

修改字段名称需注意设置锁模式为执行模式锁(esriExclusiveSchemaLock),当其他应用已经锁定要素类,不管是(esriExclusiveSchemaLock,还是esriSharedS...
  • gis_101
  • gis_101
  • 2015年12月13日 22:22
  • 1361

修改Client Feature的图标

如前篇文章看到的,Client Feature默认有个图标,类似方程式的样子。那可不可以设置自己的图标呢?是可以的。 方法很简单。只需要调用Client Feature对应浏览节点的Bro...
  • autodeskinventorapi
  • autodeskinventorapi
  • 2015年02月02日 14:25
  • 621

Feature (mapxtreme)

Feature图元由它们的几何体、样式、数据源、键和属性描述。通常,图元为表中的行。图元的几何体是 FeatureGeometry 对象。FeatureGeometries 可以包含给定的区域 (Mu...
  • chenshizero
  • chenshizero
  • 2007年10月25日 17:47
  • 1679

ArcGIS Engine效率探究之(二)要素的添加和删除、属性的读取和更新(例:面积、周长字段的更新)

原文链接: 1. 要素的添加 ArcGIS Engine中,主要有两个方法用于要素的添加: Using IFeatureClass.CreateFeature followed by IF...
  • mrbaolong
  • mrbaolong
  • 2015年08月20日 10:20
  • 1902

直接修改内存数据

下面是修改进程的某片地址的数据: #include #include #include #include #define NAME "mspaint.exx" //要修改的进程名 void r...
  • liuguangsh
  • liuguangsh
  • 2016年09月27日 16:53
  • 1736

arcengine 开发几个注意释放内存的地方

在循环、查询过程中经常出现如下错误:  1 、循环的 游标一定要释放不然会报错。    //按图形查找重复路段 private void find_CFLD(IFeature...
  • huluanchushou
  • huluanchushou
  • 2017年01月12日 12:21
  • 1060
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:IFeatureClass.Update 修改Feature
举报原因:
原因补充:

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