arcgis engine计算点到线的最短距离
IProximityOperator接口用于获取两个几何图形的距离,以及给定一个Point,求另一个几何图形上离离给定点最近的点。IProximityOperator接口的主要方法有:QueryNearesPoint,ReturnDistance, ReturnNearestPoint
ReturnDistance方法用于返回两个几何对象间的最短距离,QueryNearesPoint方法用于查询获取几何对象上离给定输入点的最近距离的点的引用,ReturnNearestPoint方法用于创建并返回几何对象上离给定输入点的最近距离的点
- IMap pMap = axMapControl1.Map;
- ILayer pLayer = null;
- IPoint po=null;
- IPolyline pl=null;
- IFeatureLayer featurelayer=null;
- IFeatureClass featureclass = null;
- IGraphicsContainer gra;
- IElement ptele;
- IPointCollection lineptcol;
- gra = axMapControl1.Map as IGraphicsContainer;
- lineptcol = new PolylineClass();
- for (int i = 0; i < pMap.LayerCount; i++)
- {
- pLayer = pMap.get_Layer(i);
- featurelayer = pLayer as IFeatureLayer;
- featureclass = featurelayer.FeatureClass;
- IFeature feature = featureclass.GetFeature(0);
- if (feature.Shape is IPoint)
- {
- po = feature.Shape as IPoint;
- }
- else {
- pl = feature.Shape as IPolyline;
- }
- //MessageBox.Show("qqqq");
- }
- double dis = GetTwoGeometryDistance(po, pl);
- IPoint po2 = NearestPoint(po, pl);
- object a = Type.Missing;
- lineptcol.AddPoint(po, ref a, ref a);
- lineptcol.AddPoint(po2, ref a, ref a);
- IElement lineele = new LineElementClass();
- IPolyline pline = new PolylineClass();
- pline = lineptcol as IPolyline;
- lineele.Geometry = pline as IGeometry;
- gra.AddElement(lineele, 0);
- axMapControl1.Refresh();
- MessageBox.Show(dis.ToString());
计算几何图形之间的距离
- public
double GetTwoGeometryDistance(IGeometry pGeometryA, IGeometry pGeometryB) - {
- IProximityOperator pProOperator = pGeometryA as IProximityOperator;
- if (pGeometryA != null || pGeometryB != null)
- {
- double distance = pProOperator.ReturnDistance(pGeometryB);
- return distance;
- }
- else
- {
- return 0;
- }
- }
离给定的几何图形最近的点
- //离给定的几何图形最近的点
- public IPoint NearestPoint(IPoint pInputPoint, IGeometry pGeometry)
- {
- try
- {
- IProximityOperator pProximity = (IProximityOperator)pGeometry;
- IPoint pNearestPoint = pProximity.ReturnNearestPoint(pInputPoint, esriSegmentExtension.esriNoExtension);
- return pNearestPoint;
- }
- catch (Exception Err)
- {
- MessageBox.Show(Err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return
null; - }
- }
计算出来最近的点,然后和初始的那个点连成一个线,也就做出了直线的中垂线

arcgis engine计算点到线的最短距离的更多相关文章
- ArcGIS Engine中添加点、线、面元素
转自原文 ArcGIS Engine中添加点.线.面元素 此种方式为IElement的方式在axMapControl的GraphicsContainer中好绘制图形. //画点 IPoint pt = ...
- ArcGIS Engine开发之旅04---ARCGIS接口详细说明
原文:ArcGIS Engine开发之旅04---ARCGIS接口详细说明 ArcGIS接口详细说明... 1 1. IField接口(esriGeoDatabase)... 2 2. ...
- [转载]ArcGIS Engine 中的多线程使用
ArcGIS Engine 中的多线程使用 原文链接 http://anshien.blog.163.com/blog/static/169966308201082441114173/ 一直都想写 ...
- ArcGIS engine中Display类库——Display
转自原文 ArcGIS engine中Display类库——Display Display类库包括了用于显示GIS数据的对象.除了负责实际输出图像的主要显示对象(display object)外,这 ...
- ArcGIS Engine中的Symbols详解
转自原文ArcGIS Engine中的Symbols详解 本文由本人翻译ESRI官方帮助文档.尊重劳动成果,转载请注明来源. Symbols ArcObjects用了三种类型的Symbol(符号样式) ...
- ArcGIS Engine 中的多线程使用
转自原文ArcGIS Engine 中的多线程使用 一直都想写写AE中多线程的使用,但一直苦于没有时间,终于在中秋假期闲了下来.呵呵,闲话不说了,进入正题! 大家都了解到ArcGIS中处理大数据量时速 ...
- ArcGIS engine中Display类库 (局部刷新)
转自原文 ArcGIS engine中Display类库 (局部刷新) Display类库包括了用于显示GIS数据的对象.除了负责实际输出图像的主要显示对象(display object)外,这个类库 ...
- ArcGIS Engine能够做什么?
转自原文ArcGIS Engine能够做什么? ArcGIS Engine是一组跨平台的嵌入式ArcObjects,它是ArcGIS软件产品的底层组件,用来构建定制的GIS和桌面制图应用程序,或是向原 ...
- ArcGIS Engine 中的多线程使用[转载]
一直都想写写AE中多线程的使用,但一直苦于没有时间,终于在中秋假期闲了下来.呵呵,闲话不说了,进入正题! 大家都了解到ArcGIS中处理大数据量时速度是相当的慢,这时如果你的程序是单线 ...
随机推荐
- ELK系列(4) - Elasticsearch cannot write xcontent for unknown value of type class java.math.BigDecimal
问题与分析 在使用Elasticsearch进行index数据时,发现报错如下: java.lang.IllegalArgumentException: cannot write xcontent f ...
- PAT甲级——1095 Cars on Campus (排序、映射、字符串操作、题意理解)
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/93135047 1095 Cars on Campus (30 分 ...
- js index of()用法
含义: indexOf() 方法可返回某个指定的字符串值在字符串中首次出现的位置.(工作中常用) 提示和注释: 注释:indexOf() 方法对大小写敏感! 注释:如果要检索的字符串值没有出现,则该方 ...
- (1009) HDU 6446 Tree and Permutation(规律+树上各个点的距离和)
题意: 给一棵N个点的树,对应于一个长为N的全排列,对于排列的每个相邻数字a和b,他们的贡献是对应树上顶点a和b的路径长,求所有排列的贡献和. 分析: 经过简单的分析可以得知,全部的贡献其实相当与(这 ...
- 每次打开 excel2010 都要配置如何解决
遇到这种情况有以下几种解决方法 1.修改原有office启动名称 打开"C:/Program Files/Common Files/Microsoft Shared/OFFICE14/Off ...
- 11g 配置 dgmgrl 以及报错 DataGuard ORA-00313,
1参考 https://gavinsoorma.com/2010/03/11g-data-guard-broker-dgmgrl-configuration-quick-steps/ This not ...
- 性能测试学习第十天_controller
集合点设置 controller虚拟多个用户执行脚本启动步骤不一定同步,集合点在脚本的某处设置一个标记,当有虚拟用户运行到这个标记的时候,停下等待所有用户都达到这个标记,再一同进行下面的步骤.这样可以 ...
- linux下的idea的界面问题,错位以及各种...
问题 ’ 方法 主题设置为GTK,多余的点会消失,而且字体也会好很多
- 命名空间namespace、smarty使用(视图分离,MVC)、smarty模板语法、smarty缓存、MVC模式
一.命名空间:namespace 命名空间 可以理解为逻辑上的使用,为了防止重名 namespace :关键字 加载:require_once();//加载一次 include_once() 申明命名 ...
- 使用CMake生成VS2010项目查看OpenCV源代码
近期项目需要用到OpenCV中的几个函数,但其函数无法全部实现自己需要的功能,故而需要改进部分函数,为安全及效率起见,想参考OpenCV的源码来改进,这样节省时间的同时亦可提供代码的鲁棒性和通用性.那 ...