/// <summary> /// 拷贝构造函数。 /// </summary> /// <param name="transferGuideItem">TransferGuideItem对象。</param> public TransferGuideItem(TransferGuideItem transferGuideItem) { if (transferGuideItem == null) { throw new ArgumentNullException(); } this.Distance = transferGuideItem.Distance; this.EndIndex = transferGuideItem.EndIndex; if (transferGuideItem.EndPosition != null) { this.EndPosition = new Point2D(transferGuideItem.EndPosition); } this.EndStopName = transferGuideItem.EndStopName; this.IsWalking = transferGuideItem.IsWalking; this.LineName = transferGuideItem.LineName; this.PassStopCount = transferGuideItem.PassStopCount; if (transferGuideItem.Route != null) { this.Route = new Geometry(transferGuideItem.Route); } this.StartIndex = transferGuideItem.StartIndex; if (transferGuideItem.StartPosition != null) { this.StartPosition = new Point2D(transferGuideItem.StartPosition); } this.StartStopName = transferGuideItem.StartStopName; }
/// <summary> /// 拷贝构造函数。 /// </summary> /// <param name="transferGuides">TransferGuide对象。</param> public TransferGuide(TransferGuide transferGuides) { if (transferGuides == null) { throw new ArgumentNullException(); } Count = transferGuides.Count; TotalDistance = transferGuides.TotalDistance; TransferCount = transferGuides.TransferCount; if (transferGuides.Items != null && transferGuides.Items.Length > 0) { Items = new TransferGuideItem[transferGuides.Items.Length]; for (int i = 0; i < transferGuides.Items.Length; i++) { if (transferGuides.Items[i] != null) { Items[i] = new TransferGuideItem(transferGuides.Items[i]); } } } }
/// <summary> /// 将换乘方案信息添加到DataGridView上 /// Add transfer information to DataGridView /// </summary> /// <param name="transferGuide"></param> private void FillGuidesInfo(TransferGuide transferGuide) { // 清除DataGridView中的数据 // Clear data of DataGridView m_dataGridView.Rows.Clear(); // 添加换乘方案详细信息到m_dataGridView // Add detailed transfer information to m_dataGridView Object[] values = new Object[4]; // 步行的距离 //Walking distance Double disWalk = 0.0; //乘车经过的距离 //Bus path distance Double disRide = 0.0; for (Int32 i = 0; i < transferGuide.Count; i++) { TransferGuideItem item = transferGuide[i]; values[0] = (i + 1).ToString(); if (item.IsWalking) { if (i == transferGuide.Count - 1) { if (SuperMap.Data.Environment.CurrentCulture != "zh-CN") { values[1] = "Walk to the destination"; } else { values[1] = "步行至终点"; } } else { if (SuperMap.Data.Environment.CurrentCulture != "zh-CN") { values[1] = "Walk to" + transferGuide[i + 1].StartName; } else { values[1] = "步行至" + transferGuide[i + 1].StartName; } } disWalk += item.Distance; } else { if (SuperMap.Data.Environment.CurrentCulture != "zh-CN") { values[1] = "From " + item.StartName + ", take " + item.LineName + " with " + (item.PassStopCount - 1) + " stops, and get off at " + item.EndName; } else { values[1] = "从" + item.StartName + "乘坐" + item.LineName + "经过" + (item.PassStopCount - 1) + "站,在" + item.EndName + "下车"; } disRide += item.Distance; } values[2] = item.Distance; values[3] = item.Fare; m_dataGridView.Rows.Add(values); } values[0] = transferGuide.Count + 1; values[1] = "乘车总距离:" + disRide + ",步行总距离:" + disWalk; values[2] = "总距离:" + transferGuide.TotalDistance; values[3] = "总费用:" + transferGuide.TotalFare; if (SuperMap.Data.Environment.CurrentCulture != "zh-CN") { values[1] = "Bus distance: " + disRide + ", walking distance: " + disWalk; values[2] = "Total distance: " + transferGuide.TotalDistance; values[3] = "Total cost: " + transferGuide.TotalFare; } else { values[1] = "乘车总距离:" + disRide + ",步行总距离:" + disWalk; values[2] = "总距离:" + transferGuide.TotalDistance; values[3] = "总费用:" + transferGuide.TotalFare; } m_dataGridView.Rows.Add(values); }
/// <summary> /// 在地图上显示换乘的图形导引,在DataGridView中显示详细信息 /// Display the graphical guide on the map. And display the details on DataGridView /// </summary> public void ShowReslut() { if (SuperMap.Data.Environment.CurrentCulture != "zh-CN") { m_dataGridView.Columns[1].HeaderText = "Guilde"; m_dataGridView.Columns[2].HeaderText = "Distance"; m_dataGridView.Columns[3].HeaderText = "Cost"; } else { m_dataGridView.Columns[1].HeaderText = "导引"; m_dataGridView.Columns[2].HeaderText = "距离"; m_dataGridView.Columns[3].HeaderText = "费用"; } // 删除跟踪图层上除起始、终止站点及其名称外的几何对象 // Delete objects on the tracking layer except the start and end stop for (Int32 i = m_trackingLayer.Count - 1; i >= 0; i--) { String tag = m_trackingLayer.GetTag(i); if (tag != "StartStop" && tag != "EndStop" && tag != "StartStopName" && tag != "EndStopName") { m_trackingLayer.Remove(i); } } m_mapControl.Map.RefreshTrackingLayer(); TransferSolution solution = null; if (m_comboGuide.SelectedIndex == -1) { solution = m_solutions[0]; } else { solution = m_solutions[m_comboGuide.SelectedIndex]; } // 提取换乘方案中的第一条换乘路线,即每段乘车段集合中的第一段乘车路线的组合对应的完整路线 // Extract the first transfer path TransferLine[] linesOnOne = new TransferLine[solution.TransferTime + 1]; for (int j = 0; j < solution.TransferTime + 1; j++) { linesOnOne[j] = solution[j][0]; } // 获取换乘导引 // gat the transfer guide TransferGuide transferGuide = m_transferAnalyst.GetDetailInfo(m_startStopID, m_endStopID, linesOnOne); // 从换乘导引中提取详细的导引信息 // Extract the details from transfer guide if (transferGuide != null) { for (Int32 i = 0; i < transferGuide.Count; i++) { TransferGuideItem item = transferGuide[i]; // 获取换乘导引子项的路径对象 // Get the path objects of the guide items GeoLine path = item.Route; GeoStyle style = new GeoStyle(); if (item.IsWalking) { style.LineColor = Color.FromArgb(255, 87, 87); style.LineWidth = 0.6; style.LineSymbolID = 12; } else { style.LineColor = Color.Blue; style.LineWidth = 1.0; } path.Style = style; // 在跟踪层上绘制每个换乘导引子项的路径对象 // Draw the path object of transfer guide item on the tracking layer m_trackingLayer.Add(path, "Path"); // 绘制中间站点 // Draw mid-stops GeoPoint transferStop = new GeoPoint(item.StartPosition.X, item.StartPosition.Y); transferStop.Style = GetStopStyle(new Size2D(5, 5), Color.FromArgb(87, 255, 255)); GeoText transferStopName = new GeoText(); TextPart part = new TextPart(item.StartName, new Point2D(transferStop.X, transferStop.Y)); transferStopName.AddPart(part); transferStopName.TextStyle = GetStopTextStyle(5.0, Color.FromArgb(89, 89, 89)); if (i != 0) { m_trackingLayer.Add(transferStop, "transferStop"); } m_trackingLayer.Add(transferStopName, "transferStopName"); transferStop = new GeoPoint(item.EndPosition.X, item.EndPosition.Y); transferStop.Style = GetStopStyle(new Size2D(5, 5), Color.FromArgb(87, 255, 255)); transferStopName = new GeoText(); part = new TextPart(item.EndName, new Point2D(transferStop.X, transferStop.Y)); transferStopName.AddPart(part); transferStopName.TextStyle = GetStopTextStyle(5.0, Color.FromArgb(89, 89, 89)); if (i != transferGuide.Count - 1) { m_trackingLayer.Add(transferStop, "transferStop"); } m_trackingLayer.Add(transferStopName, "transferStopName"); m_mapControl.Map.RefreshTrackingLayer(); } m_mapControl.Map.RefreshTrackingLayer(); // 添加信息到DataGridView // Add information to DataGridView FillGuidesInfo(transferGuide); } else { if (SuperMap.Data.Environment.CurrentCulture != "zh-CN") { MessageBox.Show("Sorry! There is no proper transfer line!"); } else { MessageBox.Show("抱歉!公交方案详细信息提取出错!"); } } }