看了些源码,效率挺垃圾的,折腾了一个垃圾得不太彻底的代码,还是慢。

不会折腾底层直接怼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#的更多相关文章

  1. 解析ArcGis拓扑——根据拓扑错误记录提取shp文件、导出Excel表格

    在ArcGis拓扑检查的流程——以面重叠检查为例中讲述了如何在ArcGis进行拓扑检查与修改. 在实际操作中,有时我们还需要将ArcGis拓扑检查的结果制作成报告或者提取错误信息反馈作业方. 本文仍然 ...

  2. Java检查异常、非检查异常、运行时异常、非运行时异常的区别

    Java把所有的非正常情况分为两种:异常(Exception)和错误(Error),它们都继承Throwable父类. Java的异常(Exception和Error)分为检查异常和非检查的异常. 其 ...

  3. Java检查异常和非检查异常,运行时异常和非运行时异常的区别

    通常,Java的异常(包括Exception和Error)分为检查异常(checked exceptions)和非检查的异常(unchecked exceptions).其中根据Exception异常 ...

  4. Java:检查异常与未检查异常

    一.异常的介绍 Throwable 是 Java 中所有错误和异常的超类.Java 虚拟机仅抛出属于此类(或其子类之一)的实例对象,或者是 throw 语句也可以抛出该对象.同样,catch 子句中的 ...

  5. MyEclipse 关闭拼写检查、JavaScript的检查Build、xml、JSP的Bulid检查

    前言 MyEclipse 的拼写检查.JavaScript的检查Build.xml.JSP的Bulid检查很讨厌,有时不仅会一直build卡住,而且明明是对的它却报错,示例: 关闭方法 1.关闭拼写检 ...

  6. java 检查异常 和 非检查异常

    个人见解 ,如果有问题 ,还希望大神们 指正 1. 非检查异常 又称运行时 异常 ,所有 继承自 RuntimeException 的异常都是 非检查异常  ,, 如果你不处理  会有 虚拟机 mai ...

  7. ArcGis 拓扑检查——狭长角锐角代码C#

    中学的时候醉心于研究怎么“逃课”,大学的时候豁然开悟——最牛逼的逃课是准时准地儿去上每一课,却不知到老师讲的啥,“大隐隐于市”大概就是这境界吧. 用到才听说有“余弦定理”这么一个东西,遂感叹“白上了大 ...

  8. ArcGIS拓扑检查

    对于拓扑检查中的等级参数一直不理解,经过参考资料才明白过来: 注:如果有两个要素参与到拓扑,在修复拓扑错误时会优先移动拓扑级别低的要素来满足匹配拓扑规则要求. 参考资料: https://wenku. ...

  9. 解析ArcGis拓扑——检查的流程,以面重叠检查为例

    最简单的面重叠错误检查是使用“地理处理”——“面相交”进行检查,其结果是重叠部分提取而成的新面要素类.本例不讲述此种方法. step1 准备待拓扑检查数据 名词: 数据库 DataBase→顾名思义, ...

随机推荐

  1. luogu1919 A*BProblem升级版 (FFT)

    把一个n位数看做n-1次的多项式,每一项的系数是反过来的每一位最后每一项系数进进位搞一搞就行了(数组一定要开到2的次数..要不然极端数据会RE) #include<cstdio> #inc ...

  2. Cannot set property 'innerHTML' of null

    异常处理汇总-前端系列 http://www.cnblogs.com/dunitian/p/4523015.html 看如下错误代码: 知道是加载的问题就好解决了

  3. springAop @AfterReturning注解 获取返回值

    @AfterReturning(returning="rvt", pointcut="@annotation(com.sinosoft.redis.cache.PutCa ...

  4. limits.conf文件工作原理

    1. limits.conf 描述 limits.conf文件实际是Linux PAM(插入式认证模块,Pluggable Authentication Modules)中 pam_limits.so ...

  5. P1379 八数码naive题,STL的胜利

    八数码:我使用了map判重 结果一遍就轻松A题了. 关于map的用法: ①创建一个map map<char,int>m; map<string,long long int>m1 ...

  6. 【洛谷P1024一元三次方程求解】

    题目描述 有形如: ax3 + bx2 + cx1 + dx0 = 0 这样的一个一元三次方程.给出该方程中各项的系数( a,b,c,d 均为实数),并约定该方程存在三个不同实根(根的范围在 -100 ...

  7. 【译】5. Java反射——方法

    原文地址:http://tutorials.jenkov.com/java-reflection/methods.html ====================================== ...

  8. 2019阿里校招测评题,光明小学完全图最短路径问题(python实现)

    题目:光明小学的小朋友们要举行一年一度的接力跑大赛了,但是小朋友们却遇到了一个难题:设计接力跑大赛的线路,你能帮助他们完成这项工作么?光明小学可以抽象成一张有N个节点的图,每两点间都有一条道路相连.光 ...

  9. 测试唯一ID支持多大的并发量

    昨天突然考虑到这个问题,在并发比较大的情况下,你用于生成唯一ID的函数是否还能正常运行?也就是说比如我一下子进来40000个订单,你需要生成不重复的订单ID吧? 对于这个问题我以前没考虑过,但是可能是 ...

  10. mongodb安装和运行

    转载来源:https://blog.csdn.net/IT_wanghe/article/details/53884229 参考教程:http://www.runoob.com/mongodb/mon ...