C源码ArcEngine最短路径分析

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

C源码ArcEngine最短路径分析ArcEngine 最短路径分析(源码)几何网络

using System;

using ESRI.ArcGIS.Carto;

using ESRI.ArcGIS.Geometry;

using ESRI.ArcGIS.Geodatabase;

using workAnalysis; namespace GisEditor {

///

/// 最短路径分析

///

public class ClsPathFinder

{

private IGeometricNetwork m_ipGeometricNetwork;

private IMap m_ipMap;

private IPointCollection 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;}

get{return m_ipMap;}

}

//打开几何数据集的网络工作空间

public void OpenFeatureDatasetNetwork(IFeatureDataset FeatureDa taset)

{

CloseWorkspace();

if (!InitializeNetworkAndMap(FeatureDataset))

Console.WriteLine( "打开network出错");

}

//输入点的集合

public IPointCollection StopPoints

{

set{m_ipPoints= value;}

get{return m_ipPoints;}

}

//路径成本

public double PathCost

{

get {return 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 IGeome tryCollection;

ISpatialReference ipSpatialReference = m_ipMap.SpatialReferenc e;

IEIDHelper ipEIDHelper = new EIDHelperClass();

ipEIDHelper.GeometricNetwork = m_ipGeometricNetwork; ipEIDHelper.OutputSpatialReference = ipSpatialReference; ipEIDHelper.ReturnGeometries = true;

IEnumEIDInfo ipEnumEIDInfo = ipEIDHelper.CreateEnumEIDInfo(m_i pEnumNetEID_Edges);

int count = ipEnumEIDInfo.Count;

ipEnumEIDInfo.Reset();

for(int i =0;i

{

ipEIDInfo = ipEnumEIDInfo.Next();

ipGeometry = ipEIDInfo.Geometry;

ipNewGeometryColl.AddGeometryCollection( ipGeometry as IGeome

tryCollection);

}

return m_ipPolyline;

}

//解决路径

public void SolvePath(string WeightName)

{

try

{

int intEdgeUserClassID;

int intEdgeUserID;

int intEdgeUserSubID;

int intEdgeID;

IPoint ipFoundEdgePoint;

double dblEdgePercent;

/*PutEdgeOrigins方法的第二个参数要求是IEdgeFlag类型的数组,

* 在VB等其他语言的代码中,只需传人该类型数组的第一个元素即

* 可,但C#中的机制有所不同,需要作出如下修改:使用

* ITraceFlowSolverGEN替代ITraceFlowSolver

*/

ITraceFlowSolverGEN ipTraceFlowSolver = new TraceFlowSolverClass() as ITraceFlowSolverGEN;

INetSolver ipNetSolver = ipTraceFlowSolver as INetSolver;

INetwork ipNetwork = m_work;

相关文档
最新文档