• 修改 ArcGis Engine 图层字段值


    直接上代码:

            /// <summary>
            /// 修改空间数据库列值
            /// </summary>
            private void EditSdeField()
            {
                //找到你的图层名
                IFeatureClass featureCls = GetFeatureClass("平衡单元");
    
                //得到该图层下有多少数据
                int featureCount = featureCls.FeatureCount(null);
     
                //查询指定列名在表中的索引
                int fieldIndex = featureCls.FindField("MAPDOCID");
     
                IDataset ds = featureCls as IDataset;
    
                IWorkspace workspace = ds.Workspace;
    
                IWorkspaceEdit edit = workspace as IWorkspaceEdit; 
                edit.StartEditing(false);
                edit.DisableUndoRedo();
    
                IFeatureCursor updateCursor = featureCls.Update(null, false);
    
                edit.StartEditOperation();
    
                IFeature feature = updateCursor.NextFeature(); 
                while (feature != null)
                { 
                    feature.set_Value(fieldIndex, Guid.NewGuid().ToString("B")); 
    
                    updateCursor.UpdateFeature(feature);
                    feature = updateCursor.NextFeature();
                }
    
                edit.StopEditOperation();
                edit.StopEditing(true);
            }
    
            public IFeatureClass GetFeatureClass(string layerName)
            {
                try
                {
                    IFeatureWorkspace pFeatureWorkspace =
                        DCIEngine.FrameWork.Global.m_pSDEWorkspace as IFeatureWorkspace;
    
                    IFeatureClass pFeatureClass =
                        pFeatureWorkspace.OpenFeatureClass(layerName);
    
                    return pFeatureClass;
                }
                catch (Exception)
                {
                    return null;
                }
            }

    要注意一点的就是arcgis的guid为{00000000-0000-0000-0000-000000000000} 形式,所以.net的guid 需要         ToString(“B”)转换为 他的格式。

  • 相关阅读:
    HTML5小时钟
    简单画板
    li样式不显示使用overflow:hidden导致Li前面点、圈等样式不见
    Dede 列表页 缩略图 有显示无则不显示
    CSS3的position:sticky介绍
    json 包含字段及函数的写法
    PHP+Ajax 异步通讯注册验证
    find命令结合cp bash mv 命令使用的4种方式
    markdown完整语法规范3.0+编辑工具介绍
    几款 ping tcping 工具总结
  • 原文地址:https://www.cnblogs.com/jiguixin/p/2280994.html
Copyright © 2020-2023  润新知