zoukankan      html  css  js  c++  java
  • 修改Feature的属性表的值

    首先一定要获取Featureclass,利用Featureclass获取IWorkspace和IWorkspaceEdit:

                    IWorkspace workspace = ((IDataset)pFeatureClass).Workspace;
                    IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit;

    然后开启编辑状态:

                    bool startEdit = workspaceEdit.IsBeingEdited();
                    if (!startEdit)
                    {
                        workspaceEdit.StartEditing(false);
                    }
                    workspaceEdit.StartEditOperation();

    然后获取IFeatureCursor和IFeature:

                    pFeatureCursor = pFeatureClass.Search(pQueryFilter, false);

                    //注意这里一定要为false,因为http://forums.arcgis.com/threads/45879-Cannot-call-Store-on-a-recycled-row-while-editing

                    //如果为true可能会产生0x80040958的错误
                    pFeature = pFeatureCursor.NextFeature();

    然后用IFeature.set_Value()方法对Feature进行属性表值的修改:

                     pFeature.set_Value(i, valueToSet);

    修改完成,要用IFeature.store()方法保存:

                    pFeature.Store();

    然后最好将Feature释放掉,再进行接下来的修改:

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeature);
                    pFeature = null;
                    pFeature = pFeatureCursor.NextFeature();

    接下来用IFeatureCursor.Flush():

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

    最后停止编辑状态:
                    workspaceEdit.StopEditOperation();
                    startEdit = workspaceEdit.IsBeingEdited();
                    if (!startEdit)
                    {
                        workspaceEdit.StopEditing(true);
                    }

  • 相关阅读:
    PHP实现没有数据库提交form表单到后台并且显示出数据列表(Vuejs和Element-UI前端设计表单)
    vueJs开发音乐播放器第二篇(点击歌单跳出详情页)
    VueJs创建网易音乐播放器和vueJs常见错误处理
    VueJS和Javascript实现文字上下滚动效果
    Javascript返回顶部和砸金蛋,跑马灯等游戏代码实现
    md5 加密
    面向对象相关
    网络编程
    初始面向对象
    模块和包
  • 原文地址:https://www.cnblogs.com/henyihanwobushi/p/2947275.html
Copyright © 2011-2022 走看看