IProximityOperator接口用于获取两个几何图形的距离,以及给定一个Point,求另一个几何图形上离离给定点最近的点。IProximityOperator接口的主要方法有:QueryNearesPoint,ReturnDistance, ReturnNearestPoint
ReturnDistance方法用于返回两个几何对象间的最短距离,QueryNearesPoint方法用于查询获取几何对象上离给定输入点的最近距离的点的引用,ReturnNearestPoint方法用于创建并返回几何对象上离给定输入点的最近距离的点

  1. IMap pMap = axMapControl1.Map;
  2.            ILayer pLayer = null;
  3.            IPoint po=null;
  4.            IPolyline pl=null;
  5.            IFeatureLayer featurelayer=null;
  6.            IFeatureClass featureclass = null;
  7.            IGraphicsContainer gra;
  8.            IElement ptele;
  9.            IPointCollection lineptcol;
  10.            gra = axMapControl1.Map as IGraphicsContainer;
  11.            lineptcol = new PolylineClass();
  12.            for (int i = 0; i < pMap.LayerCount; i++)
  13.            {
  14.                pLayer = pMap.get_Layer(i);
  15.                 featurelayer = pLayer as IFeatureLayer;
  16.                 featureclass = featurelayer.FeatureClass;
  17.                IFeature feature = featureclass.GetFeature(0);
  18.  
  19.                if (feature.Shape is IPoint)
  20.                {
  21.                    po = feature.Shape as IPoint;
  22.                }
  23.                else {
  24.                     pl = feature.Shape as IPolyline;
  25.                }
  26.                //MessageBox.Show("qqqq");
  27.            }
  28.  
  29.            double dis = GetTwoGeometryDistance(po, pl);
  30.            IPoint po2 = NearestPoint(po, pl);
  31.            object a = Type.Missing;
  32.            lineptcol.AddPoint(po, ref a, ref a);
  33.            lineptcol.AddPoint(po2, ref a, ref a);
  34.            IElement lineele = new LineElementClass();
  35.            IPolyline pline = new PolylineClass();
  36.            pline = lineptcol as IPolyline;
  37.            lineele.Geometry = pline as IGeometry;
  38.            gra.AddElement(lineele, 0);
  39.            axMapControl1.Refresh();
  40.            MessageBox.Show(dis.ToString());

计算几何图形之间的距离

  1. public
    double GetTwoGeometryDistance(IGeometry pGeometryA, IGeometry pGeometryB)
  2.         {
  3.             IProximityOperator pProOperator = pGeometryA as IProximityOperator;
  4.             if (pGeometryA != null || pGeometryB != null)
  5.             {
  6.                 double distance = pProOperator.ReturnDistance(pGeometryB);
  7.                 return distance;
  8.             }
  9.             else
  10.             {
  11.                 return 0;
  12.             }
  13.         }

离给定的几何图形最近的点

  1. //离给定的几何图形最近的点
  2.         public IPoint NearestPoint(IPoint pInputPoint, IGeometry pGeometry)
  3.         {
  4.             try
  5.             {
  6.                 IProximityOperator pProximity = (IProximityOperator)pGeometry;
  7.                 IPoint pNearestPoint = pProximity.ReturnNearestPoint(pInputPoint, esriSegmentExtension.esriNoExtension);
  8.                 return pNearestPoint;
  9.             }
  10.             catch (Exception Err)
  11.             {
  12.                 MessageBox.Show(Err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  13.                 return
    null;
  14.             }
  15.         }

计算出来最近的点,然后和初始的那个点连成一个线,也就做出了直线的中垂线

arcgis engine计算点到线的最短距离的更多相关文章

  1. ArcGIS Engine中添加点、线、面元素

    转自原文 ArcGIS Engine中添加点.线.面元素 此种方式为IElement的方式在axMapControl的GraphicsContainer中好绘制图形. //画点 IPoint pt = ...

  2. ArcGIS Engine开发之旅04---ARCGIS接口详细说明

    原文:ArcGIS Engine开发之旅04---ARCGIS接口详细说明 ArcGIS接口详细说明... 1 1.      IField接口(esriGeoDatabase)... 2 2.    ...

  3. [转载]ArcGIS Engine 中的多线程使用

    ArcGIS Engine 中的多线程使用 原文链接 http://anshien.blog.163.com/blog/static/169966308201082441114173/   一直都想写 ...

  4. ArcGIS engine中Display类库——Display

    转自原文  ArcGIS engine中Display类库——Display Display类库包括了用于显示GIS数据的对象.除了负责实际输出图像的主要显示对象(display object)外,这 ...

  5. ArcGIS Engine中的Symbols详解

    转自原文ArcGIS Engine中的Symbols详解 本文由本人翻译ESRI官方帮助文档.尊重劳动成果,转载请注明来源. Symbols ArcObjects用了三种类型的Symbol(符号样式) ...

  6. ArcGIS Engine 中的多线程使用

    转自原文ArcGIS Engine 中的多线程使用 一直都想写写AE中多线程的使用,但一直苦于没有时间,终于在中秋假期闲了下来.呵呵,闲话不说了,进入正题! 大家都了解到ArcGIS中处理大数据量时速 ...

  7. ArcGIS engine中Display类库 (局部刷新)

    转自原文 ArcGIS engine中Display类库 (局部刷新) Display类库包括了用于显示GIS数据的对象.除了负责实际输出图像的主要显示对象(display object)外,这个类库 ...

  8. ArcGIS Engine能够做什么?

    转自原文ArcGIS Engine能够做什么? ArcGIS Engine是一组跨平台的嵌入式ArcObjects,它是ArcGIS软件产品的底层组件,用来构建定制的GIS和桌面制图应用程序,或是向原 ...

  9. ArcGIS Engine 中的多线程使用[转载]

    一直都想写写AE中多线程的使用,但一直苦于没有时间,终于在中秋假期闲了下来.呵呵,闲话不说了,进入正题!         大家都了解到ArcGIS中处理大数据量时速度是相当的慢,这时如果你的程序是单线 ...

随机推荐

  1. ELK系列(4) - Elasticsearch cannot write xcontent for unknown value of type class java.math.BigDecimal

    问题与分析 在使用Elasticsearch进行index数据时,发现报错如下: java.lang.IllegalArgumentException: cannot write xcontent f ...

  2. PAT甲级——1095 Cars on Campus (排序、映射、字符串操作、题意理解)

    本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/93135047 1095 Cars on Campus (30 分 ...

  3. js index of()用法

    含义: indexOf() 方法可返回某个指定的字符串值在字符串中首次出现的位置.(工作中常用) 提示和注释: 注释:indexOf() 方法对大小写敏感! 注释:如果要检索的字符串值没有出现,则该方 ...

  4. (1009) HDU 6446 Tree and Permutation(规律+树上各个点的距离和)

    题意: 给一棵N个点的树,对应于一个长为N的全排列,对于排列的每个相邻数字a和b,他们的贡献是对应树上顶点a和b的路径长,求所有排列的贡献和. 分析: 经过简单的分析可以得知,全部的贡献其实相当与(这 ...

  5. 每次打开 excel2010 都要配置如何解决

    遇到这种情况有以下几种解决方法 1.修改原有office启动名称 打开"C:/Program Files/Common Files/Microsoft Shared/OFFICE14/Off ...

  6. 11g 配置 dgmgrl 以及报错 DataGuard ORA-00313,

    1参考 https://gavinsoorma.com/2010/03/11g-data-guard-broker-dgmgrl-configuration-quick-steps/ This not ...

  7. 性能测试学习第十天_controller

    集合点设置 controller虚拟多个用户执行脚本启动步骤不一定同步,集合点在脚本的某处设置一个标记,当有虚拟用户运行到这个标记的时候,停下等待所有用户都达到这个标记,再一同进行下面的步骤.这样可以 ...

  8. linux下的idea的界面问题,错位以及各种...

    问题 ’ 方法 主题设置为GTK,多余的点会消失,而且字体也会好很多

  9. 命名空间namespace、smarty使用(视图分离,MVC)、smarty模板语法、smarty缓存、MVC模式

    一.命名空间:namespace 命名空间 可以理解为逻辑上的使用,为了防止重名 namespace :关键字 加载:require_once();//加载一次 include_once() 申明命名 ...

  10. 使用CMake生成VS2010项目查看OpenCV源代码

    近期项目需要用到OpenCV中的几个函数,但其函数无法全部实现自己需要的功能,故而需要改进部分函数,为安全及效率起见,想参考OpenCV的源码来改进,这样节省时间的同时亦可提供代码的鲁棒性和通用性.那 ...