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中处理大数据量时速度是相当的慢,这时如果你的程序是单线 ...
随机推荐
- > Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED D8: Cannot fit requested ...
- 学习:数学----gcd及扩展gcd
gcd及扩展gcd可以用来求两个数的最大公因数,扩展gcd甚至可以用来求一次不定方程ax+by=c的解 辗转相除法与gcd 假设有两个数a与b,现在要求a与b的最大公因数,我们可以设 a=b*q+ ...
- 牛客练习赛43F(推式子)
要点 题目链接 1e18的数据无法\(O(n)\)的容斥,于是推式子,官解,其中式子有点小错误 不必预处理mu,直接按照素数的个数判断正负即可 #include <bits/stdc++.h&g ...
- idea中导入githup项目
转载大神: https://blog.csdn.net/m0_37630602/article/details/69950528
- 10----padding(内边距)
padding padding:就是内边距的意思,它是边框到内容之间的距离 另外padding的区域是有背景颜色的.并且背景颜色和内容的颜色一样.也就是说background-color这个属性将填充 ...
- 转 xshell 图像化展示
http://www.cnblogs.com/kellyseeme/p/7965830.html 限制: 无法显示通过堡垒机登录的机器的图形接界面. 只能显示直接登录的服务到期的图像化界面 Xshel ...
- 2 - Bootstrap-引导类-Bootstrap/ServerBootstrap
2.1 ChannelOption和属性 //设置属性 bootstrap.option("xxx", 1231231); bootstrap.attr("xxx&quo ...
- 关于docker下容器和宿主机器时间不一致问题
在前几天,在阿里云的ECS上部署一个docker应用时,发现部署的应用在请求第三方应用时,一直出现超时的异常提示,刚开始以为是第三方应用系统的问题(此系统无赖躺枪,反正也不是一次两次了,多躺几次也就习 ...
- 在Azure上搭架***代理服务器
博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:在Azure上搭架***代理服务器.
- CCflow6 的使用
sELECT * FROM WF_GENERWORKFLOW WHERE WorkID=00000 -- 查看流程状态 wf_selectaccpter --查看流程某个节点下的人员 M ...