/// <summary> /// 将换乘方案的概述添加到ComboBox中 /// Add the transfer guide to ComboBox /// </summary> private void FillComboBox() { try { m_comboGuide.Items.Clear(); TransferSolution solution = null; String summary = ""; for (int i = 0; i < m_solutions.Count; i++) { solution = m_solutions[i]; if (SuperMap.Data.Environment.CurrentCulture != "zh-CN") { summary = "Method " + (i + 1) + ":"; } else { summary = "方案 " + (i + 1) + ":"; } TransferLines lines = null; for (int j = 0; j < solution.TransferTime + 1; j++) { lines = solution[j]; for (int k = 0; k < lines.Count; k++) { if (k == 0) { summary += lines[0].LineName; } else { summary += "/" + lines[k].LineName; } } if (solution.TransferTime > 0) { if (j != solution.TransferTime) { if (SuperMap.Data.Environment.CurrentCulture != "zh-CN") { summary += "Transfer"; } else { summary += "换乘"; } } } } m_comboGuide.Items.Add(summary); } m_comboGuide.SelectedIndex = 0; } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
/// <summary> /// 拷贝构造函数。 /// </summary> /// <param name="transferSolution">TransferSolution对象。</param> public TransferSolution(TransferSolution transferSolution) { if (transferSolution == null||transferSolution.LinesItems==null) { throw new ArgumentNullException(); } this.TransferCount = transferSolution.TransferCount; this.LinesItems = new TransferLines[transferSolution.LinesItems.Length]; for (int i = 0; i < transferSolution.LinesItems.Length; i++) { this.LinesItems[i] = new TransferLines(transferSolution.LinesItems[i]); } }
/// <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("抱歉!公交方案详细信息提取出错!"); } } }