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

不会折腾底层直接怼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. 概率DP自学

    转自https://blog.csdn.net/zy691357966/article/details/46776199 zy691357966的blog 有关概率和期望问题的研究 摘要 在各类信息学 ...

  2. 【CF487E】Tourists(圆方树)

    [CF487E]Tourists(圆方树) 题面 UOJ 题解 首先我们不考虑修改,再来想想这道题目. 我们既然要求的是最小值,那么,在经过一个点双的时候,走的一定是具有较小权值的那一侧. 所以说,我 ...

  3. [CF52C]Circular RMQ【线段树】

    题目大意 给你一个环形数列,完成环形数列上区间加法和区间求最小值. 分析 算是一道比较水的线段树模板题. 如果l>r的话,那么修改l,n和1,r区间. 不然的话那么就修改l,r区间. 其他的基础 ...

  4. CF1106E Lunar New Year and Red Envelopes

    比赛时看到这题懵逼了,比完赛仔细一想是个很简单的dp = = 由于题目限制,可以发现\(B\)取红包的策略是唯一的,可以用优先队列预处理出\(B\)在第\(i\)秒可以拿到的红包的收益\(w_i\)和 ...

  5. 【ZJOI2007】粒子运动

    若此段起始点为(stx,sty),速度为(vx,vy),设碰撞时间为t,则(stx+vx·t)²+(sty+vy·t)²=r² → stx²+vx²·t²+2·stx·vx·t+sty²+vy²·t² ...

  6. poj1958 strange towers of hanoi

    说是递推,其实也算是个DP吧. 就是4塔的汉诺塔问题. 考虑三塔:先从a挪n-1个到b,把最大的挪到c,然后再把n-1个从b挪到c,所以是 f[i] = 2 * f[i-1] + 1; 那么4塔类似: ...

  7. A1003. Emergency

    As an emergency rescue team leader of a city, you are given a special map of your country. The map s ...

  8. MVC WebAPI框架里设置异常返回格式统一

    webApi里设置全局异常返回格式今天为了设置api返回格式统一,在网上找了一推资料,各种资料参差不齐的,最后自己捣鼓,终于弄出来了,直接上代码 /// <summary> /// 消息代 ...

  9. java 常用的类

    一.日期操作:Calendar类和SimpleDateFormat类 public void Test1() { Calendar calendar=Calendar.getInstance(); S ...

  10. POJ 1971 Parallelogram Counting (Hash)

          Parallelogram Counting Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 6895   Acc ...