当前位置:   article > 正文

ArcEngine向要素类中插入数据,采用效率更高的IFeatureBuffer接口_ifeatureclass添加数据

ifeatureclass添加数据

对于ArcEngine重复地向要素类中添加数据,一般的方法是

1通过IFeatureClass.FeatureClass.CreateFeature()方法返回一个IFeature对象,

2再通过IFeature接口下的set_Value(int index,object obj)方法属性赋值等

3设置IFeature.shape属性

4最后再通过IFeature.store()方法进行存储

这种方法重复新建要素,数据量小还没影响,数据量大时,则会浪费很多时间。

推荐使用IFeatureBuffer接口

实例化方法:IFeatureBuffer pFeatureBuffer = pFeatureClass.CreateFeatureBuffer()

具体例子:

        IFeatureBuffer pFeatureBuffer = pFeatureClass.CreateFeatureBuffer();
            IFeatureCursor featurecursor = pFeatureClass.Insert(true);
            foreach (IFeature fttt in FeatureDictionary.Keys)
            {

                pFeatureBuffer.Shape = fttt.Shape;
                pFeatureBuffer.set_Value(2, fttt.get_Value(0).ToString());
                pFeatureBuffer.set_Value(3, FeatureDictionary[fttt].ToString());
                featurecursor.InsertFeature(pFeatureBuffer);

            }
            
            featurecursor.Flush();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/341081
推荐阅读
  

闽ICP备14008679号