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中处理大数据量时速度是相当的慢,这时如果你的程序是单线 ...
随机推荐
- [Inside HotSpot] Epsilon GC
1. Epsilon GC简介 Epsilon GC源于RedHat开发者Aleksey Shipilëv提交的一份JEP 318: Epsilon: A No-Op Garbage Collecto ...
- java中的String,StringBuffrer,Stringbuilder的区别
简单描述下 效率:StringBuilder>StringBuffer>String 使用场景: 如果要操作少量的数据用 = String 单线程操作字符串缓冲区 下操作大量数据 = St ...
- 简单的vue.js的表单提交数据至flask然后数据库入库,再将表里面的数据展示在网页
一.先在数据库中创建表格 在mysql中建users库并建立一个含有ID,username,email三个字段的user表 二.去vue的组件里面写页面的表单代码,注意form标签里的action需要 ...
- nagios客户端之nrpe3.2.1安装(Ubuntu)
1.删除dpkg安装的nrpedpkg -l | grep nrpedkpg -P nagios-nrpe-server 2.ubuntu下nrpe3.2.1安装 下载nrpe3.2.1的源码包:ht ...
- angular学习笔记【ng2-charts】插件添加
原文:https://segmentfault.com/a/1190000008077830 1. 安装 ng2-charts npm install ng2-charts --save2. 还必须引 ...
- 016 3Sum Closest 最接近的三数之和
Given an array S of n integers, find three integers in S such that the sum is closest to a given num ...
- C# 或与非
或 ||与 &&非 ! 逻辑或 | 逻辑与 & 逻辑非 ~
- Murano PTL&Core
PTL: Serg Melikyan Core: Ekaterina Chernova efedorova@mirantis.com Kirill Zaitsev kzaitsev@mirantis. ...
- 车牌号校验js
var regExp = /(^[\u4E00-\u9FA5]{1}[A-Z0-9]{6}$)|(^[A-Z]{2}[A-Z0-9]{2}[A-Z0-9\u4E00-\u9FA5]{1}[A-Z0-9 ...
- Oracle子查询和多表查询
多表查询需要用到表的连接 连接可以分为:(自行百度) 交叉连接(数字逻辑的笛卡尔积,不做解释) 等值连接 例如:select * from t_a, t_b where t_a.xx = t_b.xx ...