汽车精品网站建设,钓鱼网站制作的报告,学校网站建设年度总结,无忧网站建设费用ArcGIS Pro SDK中的Editing#xff08;编辑#xff09;模块提供了一系列API和工具#xff0c;允许开发人员在ArcGIS Pro中实现各种地图数据编辑操作#xff0c;从简单的要素绘制到复杂的数据集编辑。
下面列举一些常用编辑工具的实现方法。 1、获取所选要素的…ArcGIS Pro SDK中的Editing编辑模块提供了一系列API和工具允许开发人员在ArcGIS Pro中实现各种地图数据编辑操作从简单的要素绘制到复杂的数据集编辑。
下面列举一些常用编辑工具的实现方法。 1、获取所选要素的属性及赋值
// 获取当前所选择的要素
var selectedFeatures MapView.Active.Map.GetSelection();
// 获取所选要素中的第一个取单个要素
var firstSelectionSet selectedFeatures.ToDictionary().First();
// 创建【inspector】实例
var inspector new Inspector();
// 将选定要素加载到【inspector】实例
inspector.LoadAsync(firstSelectionSet.Key, firstSelectionSet.Value);
// 获取要素属性或字段值
string xzmc inspector[XZMC].ToString();
var myGeometry inspector.Shape;
// 给字段赋值
inspector[XZMC] 清凉镇;
// 执行编辑操作
inspector.ApplyAsync();
2、通过【inspector】获取字段属性
// 获取所选要素
var firstFeatureLayer MapView.Active.Map.GetLayersAsFlattenedList().OfTypeFeatureLayer().FirstOrDefault();
// 创建【inspector】实例
var inspector new Inspector();
// 将选定要素加载到【inspector】实例
inspector.LoadSchema(firstFeatureLayer);// 查看属性
foreach (var attribute in inspector)
{var fldName attribute.FieldName; // 字段名称var fldAlias attribute.FieldAlias; // 字段别名var fldType attribute.FieldType; // 字段类型int idxFld attribute.FieldIndex; // 字段序号var fld attribute.GetField(); // 字段var isNullable attribute.IsNullable; // 是否可为空var isEditable attribute.IsEditable; // 是否可编辑var isVisible attribute.IsVisible; // 是否可见var isSystemField attribute.IsSystemField; // 是否系统字段var isGeometryField attribute.IsGeometryField; // 是否几何属性字段var fldLength attribute.Length; // 字段长度
}
3、裁剪面
// 创建编辑器
var clipFeatures new EditOperation();
clipFeatures.Name Clip Features;
// 执行
clipFeatures.Clip(featureLayer, oid, clipPoly, ClipMode.PreserveArea);
if (!clipFeatures.IsEmpty)
{var result clipFeatures.Execute();
}
4、用线分割面
// 获取分割线
var select MapView.Active.SelectFeatures(clipPoly);
// 创建编辑器
var cutFeatures new EditOperation();
cutFeatures.Name Cut Features;// 执行要素类通过oid选择出要素
cutFeatures.Split(featureLayer, oid, cutLine);
// 执行要素则直接使用
cutFeatures.Split(sset, cutLine);if (!cutFeatures.IsEmpty)
{var result cutFeatures.Execute();
}
5、对所选的线要素进行平行复制
// 找到图层作模板用
var roadsLayer MapView.Active.Map.FindLayers(Roads).FirstOrDefault();// 建立【平行复制生成器】并设置参数
var parOffsetBuilder new ParallelOffset.Builder()
{Selection MapView.Active.Map.GetSelection(), // 所选要素Template roadsLayer.GetTemplate(Freeway), // 模板可以不选Distance 200, // 偏移距离Side ParallelOffset.SideType.Both, // 偏移方式左右两侧Corner ParallelOffset.CornerType.Mitered, // 拐角处理方式圆角斜接角斜面角Iterations 1, // 重复偏移的次数AlignConnected false, // 是否对齐连接线的方向CopyToSeparateFeatures false, // 是否复制到独立要素RemoveSelfIntersectingLoops true // 是否移除自相交环
};// 创建编辑器并执行
var parallelOp new EditOperation();
parallelOp.Create(parOffsetBuilder);
if (!parallelOp.IsEmpty)
{var result parallelOp.Execute();
}
6、删除要素
var deleteFeatures new EditOperation();
deleteFeatures.Name Delete Features;
// 删除表中的某一行
var table MapView.Active.Map.StandaloneTables[0];
deleteFeatures.Delete(table, oid);// 删除所选要素
var selection MapView.Active.SelectFeatures(polygon);
deleteFeatures.Delete(selection);if (!deleteFeatures.IsEmpty)
{var result deleteFeatures.Execute();
}
7、全属性复制一个要素并移位
// 创建编辑器
var duplicateFeatures new EditOperation();
duplicateFeatures.Name Duplicate Features;
// 创建【inspector】实例
var insp2 new Inspector();
// 加载
insp2.Load(featureLayer, oid);
// 获取几何
var geom insp2[SHAPE] as Geometry;
// 复制要素
var rtoken duplicateFeatures.Create(insp2.MapMember, insp2.ToDictionary(a a.FieldName, a a.CurrentValue));
if (!duplicateFeatures.IsEmpty)
{if (duplicateFeatures.Execute()){// 移动位置var modifyOp duplicateFeatures.CreateChainedOperation();modifyOp.Modify(featureLayer, (long)rtoken.ObjectID, GeometryEngine.Instance.Move(geom, 100.0, 100.0));if (!modifyOp.IsEmpty){var result modifyOp.Execute();}}
}
8、炸开多部件
var explodeFeatures new EditOperation();
explodeFeatures.Name Explode Features;
// 执行
explodeFeatures.Explode(featureLayer, new Listlong() { oid }, true);
if (!explodeFeatures.IsEmpty)
{var result explodeFeatures.Execute();
}
9、合并要素
var mergeFeatures new EditOperation();
mergeFeatures.Name Merge Features;// 创建【inspector】实例
var inspector new Inspector();
// 加载
inspector.Load(featureLayer, oid);
// 执行
mergeFeatures.Merge(featureLayer, new Listlong() { 5, 6, 7 }, inspector);if (!mergeFeatures.IsEmpty)
{var result mergeFeatures.Execute();
}
10、更新单个要素
var modifyFeature new EditOperation();
modifyFeature.Name Modify a feature;// 创建【inspector】实例
var modifyInspector new Inspector();
// 加载
modifyInspector.Load(featureLayer, oid);// 更改属性【包括几何属性】
modifyInspector[SHAPE] polygon;
modifyInspector[NAME] Updated name;
// 更新
modifyFeature.Modify(modifyInspector);// 涉及更改几何要素的情况
var featureAttributes new Dictionarystring, object();
featureAttributes[NAME] Updated name;// 更改属性
modifyFeature.Modify(featureLayer, oid, polygon, featureAttributes);if (!modifyFeature.IsEmpty)
{var result modifyFeature.Execute();
}
11、更新多个要素
// 通过筛选获取要更新的要素
var queryFilter new QueryFilter();
queryFilter.WhereClause OBJECTID 1000000;
// 获取筛选结果的oid
var oidSet new Listlong();
using (var rc featureLayer.Search(queryFilter))
{while (rc.MoveNext()){using (var record rc.Current){oidSet.Add(record.GetObjectID());}}
}// 创建编辑器
var modifyFeatures new EditOperation();
modifyFeatures.Name Modify features;
modifyFeatures.ShowProgressor true;
// 创建【inspector】实例
var muultipleFeaturesInsp new Inspector();
muultipleFeaturesInsp.Load(featureLayer, oidSet);
muultipleFeaturesInsp[MOMC] 24;
// 更新
modifyFeatures.Modify(muultipleFeaturesInsp);
if (!modifyFeatures.IsEmpty)
{var result modifyFeatures.ExecuteAsync();
}
12、筛选要素并更新
// 筛选
var filter new ArcGIS.Core.Data.QueryFilter();
filter.WhereClause CONTRACTOR KCGM;
// 获取所选的oid
var oids new Listlong();
using (var rc disLayer.Search(filter))
{while (rc.MoveNext()){using (var record rc.Current){oidSet.Add(record.GetObjectID());}}
}var modifyOp new ArcGIS.Desktop.Editing.EditOperation();
modifyOp.Name Update date;// 执行
var dateInsp new ArcGIS.Desktop.Editing.Attributes.Inspector();
dateInsp.Load(disLayer, oids);
dateInsp[InspDate] 9/21/2013;modifyOp.Modify(insp);
if (!modifyOp.IsEmpty)
{var result modifyOp.Execute();
}