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. > Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED

    > Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED D8: Cannot fit requested ...

  2. 学习:数学----gcd及扩展gcd

    gcd及扩展gcd可以用来求两个数的最大公因数,扩展gcd甚至可以用来求一次不定方程ax+by=c的解   辗转相除法与gcd 假设有两个数a与b,现在要求a与b的最大公因数,我们可以设 a=b*q+ ...

  3. 牛客练习赛43F(推式子)

    要点 题目链接 1e18的数据无法\(O(n)\)的容斥,于是推式子,官解,其中式子有点小错误 不必预处理mu,直接按照素数的个数判断正负即可 #include <bits/stdc++.h&g ...

  4. idea中导入githup项目

    转载大神: https://blog.csdn.net/m0_37630602/article/details/69950528

  5. 10----padding(内边距)

    padding padding:就是内边距的意思,它是边框到内容之间的距离 另外padding的区域是有背景颜色的.并且背景颜色和内容的颜色一样.也就是说background-color这个属性将填充 ...

  6. 转 xshell 图像化展示

    http://www.cnblogs.com/kellyseeme/p/7965830.html 限制: 无法显示通过堡垒机登录的机器的图形接界面. 只能显示直接登录的服务到期的图像化界面 Xshel ...

  7. 2 - Bootstrap-引导类-Bootstrap/ServerBootstrap

    2.1 ChannelOption和属性 //设置属性 bootstrap.option("xxx", 1231231); bootstrap.attr("xxx&quo ...

  8. 关于docker下容器和宿主机器时间不一致问题

    在前几天,在阿里云的ECS上部署一个docker应用时,发现部署的应用在请求第三方应用时,一直出现超时的异常提示,刚开始以为是第三方应用系统的问题(此系统无赖躺枪,反正也不是一次两次了,多躺几次也就习 ...

  9. 在Azure上搭架***代理服务器

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:在Azure上搭架***代理服务器.

  10. CCflow6 的使用

    sELECT * FROM WF_GENERWORKFLOW        WHERE WorkID=00000 -- 查看流程状态 wf_selectaccpter --查看流程某个节点下的人员 M ...