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

不会折腾底层直接怼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. Debian 系统安装 Nagios 服务器监控端

    安装apt-get updateapt-get install nagios* perlapt-get install --no-install-recommends pnp4nagiosapt-ge ...

  2. Hdoj 1213.How Many Tables 题解

    Problem Description Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. ...

  3. 【COGS2652】秘术「天文密葬法」(长链剖分,分数规划)

    [COGS2652]秘术「天文密葬法」(长链剖分,分数规划) 题面 Cogs 上面废话真多,建议直接拉到最下面看一句话题意吧: 给个树,第i个点有两个权值ai和bi,现在求一条长度为m的路径,使得Σa ...

  4. EasyFlash 的初始化配置

    @2019-02-18 [小记] EasyFlash的初始化流程 easyflash_init ---> ef_port_init ---> sfud_init ---> sfud_ ...

  5. JS简易弹出层

    目标 实现简易的js弹出框.为了简单灵活的在小项目中使用. 实现思路 研究bootstrap的弹出框效果后,认为层级示意图如下: 层说明 弹出层分为三层.最底层的遮罩层,覆盖在浏览器视口上.它之上是弹 ...

  6. 纯CSS画的基本图形(圆形、三角形、多边形、爱心、八卦等)

    1.圆形 .circle { width: 100px; height: 100px; background: red; border-radius: 50px; } 2.椭圆 .oval { wid ...

  7. 136.137.260. Single Number && 位运算

    136. Single Number 意思就是给你一堆数,每个数都出现了两次,只有一个数只出现了一次,找出这个数 位运算(和c艹一样) &:按位与 |:按位或 ^:异或(一样为0,不一样为1) ...

  8. QBXT Day2主要是数据结构(没写完先占坑)

    简单数据结构 本节课可能用到的一些复杂度: O(log n). 1/1+1/1/.....1/N+O(n log n) 在我们初学OI的时候,总会遇到这么一道题. 给出N次操作,每次加入一个数,或者询 ...

  9. js jquery 数组的合并 对象的合并

    转载自:http://www.cnblogs.com/xingxiangyi/p/6416468.html 1 数组合并 1.1 concat 方法 1 2 3 4 var a=[1,2,3],b=[ ...

  10. 1062.Talent and Virtue

    About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about ...