ArcEngine 删除线、面重叠节点

2024-05-11 13:18
文章标签 删除 节点 重叠 arcengine

本文主要是介绍ArcEngine 删除线、面重叠节点,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

//删除要素重叠节点
public bool DelOverlapVertex(IWorkspace workspace, string strTable, IProgressor progressor)
{bool result;try{IWorkspaceEdit workspaceEdit = null;IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace;IFeatureClass featureClass = featureWorkspace.OpenFeatureClass(strTable);switch (featureClass.ShapeType){case 3:this.DelLineOverlapVertex(featureClass, progressor);break;case 4:this.DelAreaOverlapVertex(featureClass, progressor);break;default:MessageBox.Show("删除多余节点,不支持的要素类型");break;}if (workspaceEdit != null){workspaceEdit.StopEditOperation();workspaceEdit.StopEditing(true);ComReleaser.ReleaseCOMObject(workspaceEdit);}return true;}catch (Exception ex){Trace.WriteLine(ex.Message);result = false;}return result;
}///删除面要素重复节点
public string DelAreaOverlapVertex(IFeatureClass featureClass, IProgressor progressor)
{progressor.Message = "删除重叠节点";featureClass.FeatureCount(null);StringBuilder stringBuilder = new StringBuilder();IFeatureCursor featureCursor = featureClass.Search(null, true);int num = featureCursor.FindField("OBJECTID");for (IFeature feature = featureCursor.NextFeature(); feature != null; feature = featureCursor.NextFeature()){progressor.Step();int num2 = (int)feature.get_Value(num);IPolygon4 polygon = feature.ShapeCopy as IPolygon4;IGeometryBag exteriorRingBag = polygon.ExteriorRingBag;IEnumGeometry enumGeometry = exteriorRingBag as IEnumGeometry;enumGeometry.Reset();int num3 = -1;for (IRing ring = enumGeometry.Next() as IRing; ring != null; ring = (enumGeometry.Next() as IRing)){IGeometryBag geometryBag = polygon.get_InteriorRingBag(ring);int num4 = polygon.get_InteriorRingCount(ring);IEnumGeometry enumGeometry2 = geometryBag as IEnumGeometry;enumGeometry2.Reset();bool flag = false;for (;;){ISegmentCollection segmentCollection;if (flag){if (num4 == 0){break;}IRing ring2 = enumGeometry2.Next() as IRing;if (ring2 == null){break;}num3++;segmentCollection = (ring2 as ISegmentCollection);}else{num3++;segmentCollection = (ring as ISegmentCollection);}IPointCollection pointCollection = segmentCollection as IPointCollection;IPoint point = pointCollection.get_Point(0);for (int i = 1; i < pointCollection.PointCount; i++){IPoint point2 = pointCollection.get_Point(i);double num5 = Math.Sqrt(Math.Pow(point2.X - point.X, 2.0) + Math.Pow(point2.Y - point.Y, 2.0));if (num5 <= 0.001){pointCollection.RemovePoints(i, 1);stringBuilder.AppendLine(string.Concat(new object[]{num2,"号图形part",num3,"删除了第",i,"个节点。"}));i--;}else{point = point2;}}polygon.SimplifyPreserveFromTo();flag = true;}}feature.Shape = polygon;feature.Store();}ComReleaser.ReleaseCOMObject(featureCursor);return stringBuilder.ToString();
}///删除线重叠节点
public string DelLineOverlapVertex(IFeatureClass featureClass, IProgressor progressor)
{progressor.Message = "删除重叠节点";featureClass.FeatureCount(null);StringBuilder stringBuilder = new StringBuilder();IFeatureCursor featureCursor = featureClass.Search(null, true);int num = featureCursor.FindField("OBJECTID");int num2 = 0;for (IFeature feature = featureCursor.NextFeature(); feature != null; feature = featureCursor.NextFeature()){progressor.Step();int num3 = (int)feature.get_Value(num);IPolyline4 polyline = feature.ShapeCopy as IPolyline4;polyline.SimplifyNetwork();IPointCollection pointCollection = polyline as IPointCollection;IPoint point = pointCollection.get_Point(0);for (int i = 1; i < pointCollection.PointCount; i++){IPoint point2 = pointCollection.get_Point(i);double num4 = Math.Sqrt(Math.Pow(point2.X - point.X, 2.0) + Math.Pow(point2.Y - point.Y, 2.0));if (num4 <= 0.001){pointCollection.RemovePoints(i, 1);stringBuilder.AppendLine(string.Concat(new object[]{num3,"号图形删除了第",i,"个节点。"}));i--;num2++;}else{point = point2;}}polyline.SimplifyNetwork();feature.Shape = polyline;feature.Store();}ComReleaser.ReleaseCOMObject(featureCursor);stringBuilder.AppendLine("共有" + num2.ToString() + "个节点被删除");return stringBuilder.ToString();
}

这篇关于ArcEngine 删除线、面重叠节点的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/979636

相关文章

MySQL 数据库表操作完全指南:创建、读取、更新与删除实战

《MySQL数据库表操作完全指南:创建、读取、更新与删除实战》本文系统讲解MySQL表的增删查改(CURD)操作,涵盖创建、更新、查询、删除及插入查询结果,也是贯穿各类项目开发全流程的基础数据交互原... 目录mysql系列前言一、Create(创建)并插入数据1.1 单行数据 + 全列插入1.2 多行数据

mybatisplus的逻辑删除过程

《mybatisplus的逻辑删除过程》:本文主要介绍mybatisplus的逻辑删除过程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录myBATisplus的逻辑删除1、在配置文件中添加逻辑删除的字段2、在实体类上加上@TableLogic3、业务层正常删除即

MybatisPlus中removeById删除数据库未变解决方案

《MybatisPlus中removeById删除数据库未变解决方案》MyBatisPlus中,removeById需实体类标注@TableId注解以识别数据库主键,若字段名不一致,应通过value属... 目录MyBATisPlus中removeBypythonId删除数据库未变removeById(Se

MySQL逻辑删除与唯一索引冲突解决方案

《MySQL逻辑删除与唯一索引冲突解决方案》本文探讨MySQL逻辑删除与唯一索引冲突问题,提出四种解决方案:复合索引+时间戳、修改唯一字段、历史表、业务层校验,推荐方案1和方案3,适用于不同场景,感兴... 目录问题背景问题复现解决方案解决方案1.复合唯一索引 + 时间戳删除字段解决方案2:删除后修改唯一字

使用Python删除Excel中的行列和单元格示例详解

《使用Python删除Excel中的行列和单元格示例详解》在处理Excel数据时,删除不需要的行、列或单元格是一项常见且必要的操作,本文将使用Python脚本实现对Excel表格的高效自动化处理,感兴... 目录开发环境准备使用 python 删除 Excphpel 表格中的行删除特定行删除空白行删除含指定

Linux下删除乱码文件和目录的实现方式

《Linux下删除乱码文件和目录的实现方式》:本文主要介绍Linux下删除乱码文件和目录的实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux下删除乱码文件和目录方法1方法2总结Linux下删除乱码文件和目录方法1使用ls -i命令找到文件或目录

Mysql实现范围分区表(新增、删除、重组、查看)

《Mysql实现范围分区表(新增、删除、重组、查看)》MySQL分区表的四种类型(范围、哈希、列表、键值),主要介绍了范围分区的创建、查询、添加、删除及重组织操作,具有一定的参考价值,感兴趣的可以了解... 目录一、mysql分区表分类二、范围分区(Range Partitioning1、新建分区表:2、分

MySQL 删除数据详解(最新整理)

《MySQL删除数据详解(最新整理)》:本文主要介绍MySQL删除数据的相关知识,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录一、前言二、mysql 中的三种删除方式1.DELETE语句✅ 基本语法: 示例:2.TRUNCATE语句✅ 基本语

一文详解Git中分支本地和远程删除的方法

《一文详解Git中分支本地和远程删除的方法》在使用Git进行版本控制的过程中,我们会创建多个分支来进行不同功能的开发,这就容易涉及到如何正确地删除本地分支和远程分支,下面我们就来看看相关的实现方法吧... 目录技术背景实现步骤删除本地分支删除远程www.chinasem.cn分支同步删除信息到其他机器示例步骤

python删除xml中的w:ascii属性的步骤

《python删除xml中的w:ascii属性的步骤》使用xml.etree.ElementTree删除WordXML中w:ascii属性,需注册命名空间并定位rFonts元素,通过del操作删除属... 可以使用python的XML.etree.ElementTree模块通过以下步骤删除XML中的w:as