最短路径分析(代码)

上传人:ji****72 文档编号:37818830 上传时间:2018-04-23 格式:DOC 页数:7 大小:43KB
返回 下载 相关 举报
最短路径分析(代码)_第1页
第1页 / 共7页
最短路径分析(代码)_第2页
第2页 / 共7页
最短路径分析(代码)_第3页
第3页 / 共7页
最短路径分析(代码)_第4页
第4页 / 共7页
最短路径分析(代码)_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《最短路径分析(代码)》由会员分享,可在线阅读,更多相关《最短路径分析(代码)(7页珍藏版)》请在金锄头文库上搜索。

1、最短路径分析(源码)using System; ArcEngine using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Geometry; using ESRI.ArcGIS.Geodatabase; using ESRI.ArcGIS.NetworkAnalysis;/12namespace GisEditor / / 最短路径分析 / public class ClsPathFinder private IGeometricNetwork m_ipGeometricNetwork;private IMap m_ipMap;private IPointCol

2、lection m_ipPoints;private IPointToEID m_ipPointToEID;private double m_dblPathCost =0;private IEnumNetEID m_ipEnumNetEID_Junctions;private IEnumNetEID m_ipEnumNetEID_Edges;private IPolyline m_ipPolyline;#region Public Function/返回和设置当前地图public IMap SetOrGetMap set m_ipMap = value;getreturn m_ipMap;/打

3、开几何数据集的网络工作空间public void OpenFeatureDatasetNetwork(IFeatureDataset FeatureDataset) CloseWorkspace(); if (!InitializeNetworkAndMap(FeatureDataset)Console.WriteLine( “打开 network 出错“);/输入点的集合public IPointCollection StopPointssetm_ipPoints= value;getreturn m_ipPoints;/路径成本public double PathCostget retur

4、n m_dblPathCost;/返回路径的几何体public IPolyline PathPolyLine()IEIDInfo ipEIDInfo;IGeometry ipGeometry; if(m_ipPolyline!=null)return m_ipPolyline;m_ipPolyline = new PolylineClass();IGeometryCollection ipNewGeometryColl = m_ipPolyline as IGeometryCollection;ISpatialReference ipSpatialReference = m_ipMap.Spa

5、tialReference;IEIDHelper ipEIDHelper = new EIDHelperClass();ipEIDHelper.GeometricNetwork = m_ipGeometricNetwork; ipEIDHelper.OutputSpatialReference = ipSpatialReference;ipEIDHelper.ReturnGeometries = true;IEnumEIDInfo ipEnumEIDInfo = ipEIDHelper.CreateEnumEIDInfo(m_ipEnumNetEID_Edges);int count = ip

6、EnumEIDInfo.Count;ipEnumEIDInfo.Reset();for(int i =0;i dblHeight)dblSearchTol = dblWidth / 100;elsedblSearchTol = dblHeight / 100;m_ipPointToEID.SnapTolerance = dblSearchTol;return true ;/关闭工作空间 private void CloseWorkspace()m_ipGeometricNetwork = null;m_ipPoints = null;m_ipPointToEID = null;m_ipEnum

7、NetEID_Junctions = null;m_ipEnumNetEID_Edges = null;m_ipPolyline = null;#endregion 备注:在调用该类时的次序:ClsPathFinder m_ipPathFinder;if(m_ipPathFinder=null)/打开几何网络工作空间m_ipPathFinder = new ClsPathFinder();ipMap = this.m_ActiveView.FocusMap;ipLayer = ipMap.get_Layer(0);ipFeatureLayer = ipLayer as IFeatureLaye

8、r;ipFDB = ipFeatureLayer.FeatureClass.FeatureDataset;m_ipPathFinder.SetOrGetMap = ipMap;m_ipPathFinder.OpenFeatureDatasetNetwork(ipFDB);private void ViewMap_OnMouseDown(object sender, ESRI.ArcGIS.MapControl.IMapControlEvents2_OnMouseDownEvent e)/获取地 图上鼠标输入的点IPoint ipNew ; if( m_ipPoints=null)m_ipPoi

9、nts = new MultipointClass();m_ipPathFinder.StopPoints = m_ipPoints;ipNew = ViewMap.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x,e .y);object o = Type.Missing;m_ipPoints.AddPoint(ipNew,ref o,ref o); m_ipPathFinder.SolvePath(“Weight“);/先解析路径IPolyline ipPolyResult = m_ipPathFinder.PathPolyLine();/最后返回最短 路径

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号