ArcGis 拓扑检查——缺顶点、悬挂检查代码 C#
看了些源码,效率挺垃圾的,折腾了一个垃圾得不太彻底的代码,还是慢。
不会折腾底层直接怼COM的悲伤……
实现思路是这样的:
1、把面层的点都塞进List,去重,取坐标4位,后边的检查使用容差0.001
2、遍历点,通过点在面层寻相交的面
3、如果结果是1,那么这个面在这个点处没有毗邻面,把点缓冲区一下给定距离,如果能找到面了,那么悬挂悬挂。
如果结果>1,那么遍历所有相交面,如果面的PointCollection里有这个点,那么计数+1;如果存在PointCollection里不包含这个点的面 ,那么缺顶点缺顶点
下面贴代码
取点集,去个重:
class UserPoints { public static List<IPoint> FeatureLayer2PointList(IFeatureLayer pFeatureLayer) { List<IPoint> pointList = new List<IPoint>(); IFeatureCursor pFeatureCursor = pFeatureLayer.FeatureClass.Search(null, true); try { IFeature pFeatuare = pFeatureCursor.NextFeature(); while (pFeatuare != null) { IPointCollection pcol = pFeatuare.Shape as IPointCollection; ; i < pcol.PointCount - ; i++) { pointList.Add(pcol.Point[i]); } pFeatuare = pFeatureCursor.NextFeature(); } pointList = pointList.Distinct(new Compare()).ToList<IPoint>(); } catch (Exception exp) { ErrorF err = new ErrorF(exp.Message + "\r\n" + exp.StackTrace); err.Show(); } finally { System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor); } return pointList; } } class Compare : IEqualityComparer<IPoint> { bool IEqualityComparer<IPoint>.Equals(IPoint a, IPoint b) { if (a == null && b == null) return false; else ) == Math.Round(b.X, ) && Math.Round(a.Y, ) == Math.Round(b.Y, ); } int IEqualityComparer<IPoint>.GetHashCode(IPoint obj) { return obj.ToString().GetHashCode(); } }
拓扑一下:
public static List<IPoint> CheckLackJunctionPointOrSuspendedPoint(IFeatureLayer pFeatureLayer, double distance) { IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)m_hookHelper.FocusMap.ActiveGraphicsLayer; pGraphicsContainer.DeleteAllElements(); IColor innerColor = new RgbColorClass(); innerColor.NullColor = true; IColor outLineColor = DisplayUtils.RGBColor(, , ); IElement pElement; List<IPoint> listError = new List<IPoint>(); IFeatureCursor pFeatureCursor=null; IFeature pFeature; try { IGeometry pGeometry; foreach (IPoint point in UserPoints.FeatureLayer2PointList(pFeatureLayer)) { ITopologicalOperator pTopologicalOperator = point as ITopologicalOperator; ISpatialFilter pSpatialFilter = FilterUtil.SpatialFilter(point as IGeometry, esriSpatialRelEnum.esriSpatialRelIntersects); int count = pFeatureLayer.FeatureClass.FeatureCount(pSpatialFilter); ) { IGeometry pGeometryPointBuffer =pTopologicalOperator.Buffer(distance); pGeometry = pTopologicalOperator.Buffer(distance) ; pSpatialFilter = FilterUtil.SpatialFilter(pGeometry, esriSpatialRelEnum.esriSpatialRelIntersects); ) { pElement = DisplayUtils.CircleMarkElement(point, innerColor, outLineColor, 8.0); pGraphicsContainer.AddElement(pElement, ); listError.Add(point); } } ) { pFeatureCursor = pFeatureLayer.FeatureClass.Search(pSpatialFilter, true); pFeature = pFeatureCursor.NextFeature(); ; while (pFeature != null) { IPointCollection pPointCollection = pFeature.Shape as IPointCollection; IPoint pPointtemp = new PointClass(); ; k < pPointCollection.PointCount - ; k++) { pPointCollection.QueryPoint(k, pPointtemp); if (Math.Abs(pPointtemp.X - point.X) < 0.001 && Math.Abs(pPointtemp.Y - point.Y) < 0.001) { count2++; break; } } pFeature = pFeatureCursor.NextFeature(); } if (count2 < count) { pElement = DisplayUtils.CircleMarkElement(point, innerColor, outLineColor, 8.0); pGraphicsContainer.AddElement(pElement, ); listError.Add(point); } } } } catch (Exception exp) { ErrorF err = new ErrorF(exp.Message + "\r\n" + exp.StackTrace); err.Show(); } finally { Marshal.FinalReleaseComObject(pFeatureCursor); } return listError; }
哪位有高效率的代码,求侮辱!
ArcGis 拓扑检查——缺顶点、悬挂检查代码 C#的更多相关文章
- 解析ArcGis拓扑——根据拓扑错误记录提取shp文件、导出Excel表格
在ArcGis拓扑检查的流程——以面重叠检查为例中讲述了如何在ArcGis进行拓扑检查与修改. 在实际操作中,有时我们还需要将ArcGis拓扑检查的结果制作成报告或者提取错误信息反馈作业方. 本文仍然 ...
- Java检查异常、非检查异常、运行时异常、非运行时异常的区别
Java把所有的非正常情况分为两种:异常(Exception)和错误(Error),它们都继承Throwable父类. Java的异常(Exception和Error)分为检查异常和非检查的异常. 其 ...
- Java检查异常和非检查异常,运行时异常和非运行时异常的区别
通常,Java的异常(包括Exception和Error)分为检查异常(checked exceptions)和非检查的异常(unchecked exceptions).其中根据Exception异常 ...
- Java:检查异常与未检查异常
一.异常的介绍 Throwable 是 Java 中所有错误和异常的超类.Java 虚拟机仅抛出属于此类(或其子类之一)的实例对象,或者是 throw 语句也可以抛出该对象.同样,catch 子句中的 ...
- MyEclipse 关闭拼写检查、JavaScript的检查Build、xml、JSP的Bulid检查
前言 MyEclipse 的拼写检查.JavaScript的检查Build.xml.JSP的Bulid检查很讨厌,有时不仅会一直build卡住,而且明明是对的它却报错,示例: 关闭方法 1.关闭拼写检 ...
- java 检查异常 和 非检查异常
个人见解 ,如果有问题 ,还希望大神们 指正 1. 非检查异常 又称运行时 异常 ,所有 继承自 RuntimeException 的异常都是 非检查异常 ,, 如果你不处理 会有 虚拟机 mai ...
- ArcGis 拓扑检查——狭长角锐角代码C#
中学的时候醉心于研究怎么“逃课”,大学的时候豁然开悟——最牛逼的逃课是准时准地儿去上每一课,却不知到老师讲的啥,“大隐隐于市”大概就是这境界吧. 用到才听说有“余弦定理”这么一个东西,遂感叹“白上了大 ...
- ArcGIS拓扑检查
对于拓扑检查中的等级参数一直不理解,经过参考资料才明白过来: 注:如果有两个要素参与到拓扑,在修复拓扑错误时会优先移动拓扑级别低的要素来满足匹配拓扑规则要求. 参考资料: https://wenku. ...
- 解析ArcGis拓扑——检查的流程,以面重叠检查为例
最简单的面重叠错误检查是使用“地理处理”——“面相交”进行检查,其结果是重叠部分提取而成的新面要素类.本例不讲述此种方法. step1 准备待拓扑检查数据 名词: 数据库 DataBase→顾名思义, ...
随机推荐
- 【C++】VS2015/VS2017连接Mysql数据库教程
要给C++程序连接MySQL数据库,分别需要: 安装MySQL Server 下载MySQL Connector/C++ 在IDE中配置依赖 然后就可以在代码中调用API,来连接以及操作数据库. 一. ...
- SDOI2017 Round1 简要题解
我们 TM 怎么又要上文化课..我 哔哔哔哔哔哔 「SDOI2017」数字表格 题意 有 \(T\) 组数据,求 \[ \prod_{i = 1}^{n} \prod_{j = 1}^{m} fib[ ...
- 【BZOJ5315】[JSOI2018]防御网络(动态规划,仙人掌)
[BZOJ5315][JSOI2018]防御网络(动态规划,仙人掌) 题面 BZOJ 洛谷 题解 显然图是仙人掌. 题目给了斯坦纳树就肯定不是斯坦纳树了,,,, 总不可能真让你\(2^n\)枚举点集再 ...
- Nginx log日志切割shell
#!/bin/bash#此脚本用于自动分割Nginx的日志,包括access.log和error.log#每天00:00执行此脚本 将前一天的access.log重命名为access-xxxx-xx- ...
- linux deb系 rpm系 配置永久IP
rpm: 1.IP a 查看网卡名 ens256 2.uuidgen ens256 生成UUID 3./etc/sysconfig/network-scripts add ifcfg-ens256 4 ...
- 【docker】docker安装和使用
一.docker简介: docker是容器技术的一个代表,而容器技术是将程序打包和隔离的一种技术,其实它并不是一个新技术,之前在linux内核中早已存在,真正被大众所用所了解是因为docker的出现. ...
- 课后选做题:MyOD
目录 OD命令了解 MyOD实现 OD命令了解 作用:od命令用于输出文件的八进制.十六进制或其它格式编码的字节,通常用于显示或查看文件中不能直接显示在终端的字符.常见的文件为文本文件和二进制文件.此 ...
- js 打开标签
JS打开新标签的2种方式 1.超链接<a href="http://www.jb51.net" title="脚本之家">Welcome</a ...
- Arch更新时failed to prepare transaction
error: failed to prepare transaction (could not satisfy dependencies) :: ffmpeg2.8: installing x265 ...
- 洛谷P2150 寿司晚宴
解:发现每个质数只能属于一个人,于是想到每个质数有三种情况:属于a,属于b,都不属于. 然后考虑状压每个人的质数集合,可以得到30分. 转移就是外层枚举每个数,内层枚举每个人的状态,然后看能否转移.能 ...