/// 路径分析
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Analyst_Click(object sender, EventArgs e)
{
try
{
if (point3ds.Count <2)
{
MessageBox.Show("请选择两个以上经过点");
return;
}
DatasetVector datasetvector = workspace.Datasources[0].Datasets["ResultNetWork"] as DatasetVector;
TransportationAnalystSetting3D transportationAnalystSetting = new TransportationAnalystSetting3D();
transportationAnalystSetting.NetworkDataset = datasetvector;
transportationAnalystSetting.NodeIDField = "SmNodeID";
transportationAnalystSetting.EdgeIDField = "SmEdgeID";
transportationAnalystSetting.FNodeIDField = "SmFNode";
transportationAnalystSetting.TNodeIDField = "SmTNode";
transportationAnalystSetting.Tolerance = 20;
//设置权重信息
WeightFieldInfo3D weightFieldInfo = new WeightFieldInfo3D();
weightFieldInfo.Name = "SmLength";
weightFieldInfo.FTWeightField = "SmLength";
weightFieldInfo.TFWeightField = "SmLength";
WeightFieldInfos3D weightFieldInfos = new WeightFieldInfos3D();
weightFieldInfos.Add(weightFieldInfo);
transportationAnalystSetting.WeightFieldInfos = weightFieldInfos;
//构造一个三维交通网络分析对象,并设置分析环境
TransportationAnalyst3D transportationAnalyst = new TransportationAnalyst3D();
transportationAnalyst.AnalystSetting = transportationAnalystSetting;
//加载网络模型
Boolean isLoad = transportationAnalyst.Load();
if (isLoad)
{
//构造三维交通网络分析参数对象,并设置相关参数
TransportationAnalystParameter3D parameter = new TransportationAnalystParameter3D();
parameter.Points = point3ds;
parameter.WeightName = "SmLength";
parameter.IsNodesReturn = true;
parameter.IsEdgesReturn = true;
parameter.IsRoutesReturn = true;
parameter.IsStopIndexesReturn = true;
//进行最佳路径分析
TransportationAnalystResult3D result = transportationAnalyst.FindPath(parameter);
GeoLine3D geoline3d = result.Routes[0];
GeoStyle3D geostyle3d = new GeoStyle3D();
geostyle3d.LineColor = Color.Blue;
geostyle3d.AltitudeMode = AltitudeMode.ClampToGround;
geostyle3d.LineWidth = 5;
geoline3d.Style3D = geostyle3d;
scenecontrol.Scene.TrackingLayer.Add(geoline3d,"line");
}
}
catch
{