Esempio n. 1
0
        /// <summary>
        /// 捕捉公交站点
        /// Snap the bus stops
        /// </summary>
        public void SnapPoint()
        {
            try
            {
                if (m_selection != null)
                {
                    // 获取被选中的站点对象
                    // Get the selected stop object
                    Recordset recordset = m_selection.ToRecordset();
                    GeoPoint  snapPoint = recordset.GetGeometry() as GeoPoint;

                    // 构造文本对象,用于在跟踪层上显示站点的名称
                    // Construct the text object, which is used to display the stop name on the tracking name
                    GeoText stopText = new GeoText();
                    // 站点名称
                    // Stop name
                    String stopName = "";
                    if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
                    {
                        stopName = recordset.GetFieldValue("Name_en").ToString();
                    }
                    else
                    {
                        stopName = recordset.GetFieldValue("Name").ToString();
                    }
                    TextPart textPart = new TextPart(stopName, new Point2D(snapPoint.X, snapPoint.Y));
                    stopText.AddPart(textPart);

                    if (m_isStartPoint)
                    {
                        // 绘制之前先清空跟踪层上的点和文字
                        // Clear all points and words on the tracking layer before drawing
                        Int32 indexStartStop = m_trackingLayer.IndexOf("StartStop");
                        if (indexStartStop != -1)
                        {
                            m_trackingLayer.Remove(indexStartStop);
                        }
                        Int32 indexStartText = m_trackingLayer.IndexOf("StartStopName");
                        if (indexStartText != -1)
                        {
                            m_trackingLayer.Remove(indexStartText);
                        }
                        // 分别设置站点及其名称文本的风格,并添加到跟踪层上
                        // Set the stop and name style and add them to the tracking layer
                        snapPoint.Style = GetStopStyle(new Size2D(8, 8), Color.FromArgb(236, 118, 0));
                        m_trackingLayer.Add(snapPoint, "StartStop");
                        stopText.TextStyle = GetStopTextStyle(6.0, Color.FromArgb(0, 0, 0));
                        m_trackingLayer.Add(stopText, "StartStopName");

                        // 设置为起始站点ID
                        // Set the strat stop ID
                        m_startStopID = recordset.GetInt64("STOPID");
                    }
                    else
                    {
                        // 绘制之前先清空跟踪层上的点和文字
                        // Clear all points and words on the tracking layer before drawing
                        Int32 indexEndStop = m_trackingLayer.IndexOf("EndStop");
                        if (indexEndStop != -1)
                        {
                            m_trackingLayer.Remove(indexEndStop);
                        }
                        Int32 indexEndText = m_trackingLayer.IndexOf("EndStopName");
                        if (indexEndText != -1)
                        {
                            m_trackingLayer.Remove(indexEndText);
                        }
                        // 分别设置站点及其名称文本的风格,并添加到跟踪层上
                        // Set the stop and name style and add them to the tracking layer
                        snapPoint.Style = GetStopStyle(new Size2D(8, 8), Color.FromArgb(22, 255, 0));
                        m_trackingLayer.Add(snapPoint, "EndStop");
                        stopText.TextStyle = GetStopTextStyle(6.0, Color.FromArgb(0, 0, 0));
                        m_trackingLayer.Add(stopText, "EndStopName");

                        // 设置为起始站点ID
                        // Set the strat stop ID
                        m_endStopID = recordset.GetInt64("STOPID");
                    }
                    recordset.Dispose();
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 2
0
        /// <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("抱歉!公交方案详细信息提取出错!");
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 根据线路查询站点
        /// Query stop by the path
        /// </summary>
        /// <param name="lineID"></param>
        public void FindStopsByLine(Int64 lineID)
        {
            try
            {
                if (m_isLoad)
                {
                    m_comboGuide.Items.Clear();
                    m_dataGridView.Rows.Clear();
                    if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
                    {
                        m_dataGridView.Columns[1].HeaderText = "Stop ID";
                        m_dataGridView.Columns[2].HeaderText = "Name";
                    }
                    else
                    {
                        m_dataGridView.Columns[1].HeaderText = "站点ID";
                        m_dataGridView.Columns[2].HeaderText = "名称";
                    }
                    m_dataGridView.Columns[3].HeaderText = "----";

                    // 清除跟踪层上的对象
                    // Clear object on the tracking layer
                    m_trackingLayer.Clear();
                    m_mapControl.Map.RefreshTrackingLayer();

                    // 查询经过指定站点的线路
                    // Query the path by stops
                    StopInfo[] stopInfos = m_transferAnalyst.FindStopsByLine(lineID);
                    if (stopInfos.Length > 0)
                    {
                        // 将该线路添加到跟踪层上显示
                        // Add the path to the tracking layer
                        LineInfo[] lineInfos = m_transferAnalyst.FindLinesByStop(stopInfos[0].StopID);
                        for (Int32 i = 0; i < lineInfos.Length; i++)
                        {
                            if (lineInfos[i].LineID == lineID)
                            {
                                GeoLine line = lineInfos[i].TotalLine;
                                m_mapControl.Map.CustomBounds          = line.Bounds;
                                m_mapControl.Map.IsCustomBoundsEnabled = true;
                                m_mapControl.Map.ViewEntire();

                                GeoStyle style = new GeoStyle();
                                style.LineColor = Color.DeepSkyBlue;
                                style.LineWidth = 1.0;
                                line.Style      = style;
                                m_trackingLayer.Add(line, "Line");
                                break;
                            }
                        }
                        // 添加站点信息
                        // Add the stops
                        for (Int32 j = 0; j < stopInfos.Length; j++)
                        {
                            // 将线路信息添加到DataGridView中
                            // Add the line information to DataGridView
                            Object[] values = new Object[4];
                            values[0] = j + 1;
                            values[1] = stopInfos[j].StopID;
                            values[2] = stopInfos[j].Name;
                            values[3] = "----";
                            m_dataGridView.Rows.Add(values);

                            // 在跟踪图层中绘制查询出的站点及其名称
                            // Draw stops and names on the tracking layer
                            Point2D  point2D = stopInfos[j].Position;
                            GeoPoint point   = new GeoPoint(point2D);
                            point.Style = GetStopStyle(new Size2D(5, 5), Color.Orange);
                            m_trackingLayer.Add(point, "Stops");

                            GeoText  geoText = new GeoText();
                            TextPart part    = new TextPart(stopInfos[j].Name, point2D);
                            geoText.AddPart(part);
                            geoText.TextStyle = GetStopTextStyle(5.0, Color.FromArgb(153, 0, 255));
                            m_trackingLayer.Add(geoText, "StopNames");
                        }
                        m_mapControl.Map.RefreshTrackingLayer();
                    }
                }
                else
                {
                    if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
                    {
                        MessageBox.Show("Sorry! There is no stop on this path!");
                    }
                    else
                    {
                        MessageBox.Show("抱歉!没有查找到该线路上的站点!");
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }