Exemplo n.º 1
0
 /// <summary>
 /// 拷贝构造函数。
 /// </summary>
 /// <param name="pathGuideItem"></param>
 public PathGuideItem(PathGuideItem pathGuideItem)
 {
     if (pathGuideItem == null) throw new ArgumentException();
     if (pathGuideItem.Bounds != null)
     {
         this.Bounds = new Rectangle2D(pathGuideItem.Bounds);
     }
     this.Description = pathGuideItem.Description;
     this.DirectionType = pathGuideItem.DirectionType;
     this.Distance = pathGuideItem.Distance;
     if (pathGuideItem.Geometry != null)
     {
         this.Geometry = pathGuideItem.Geometry;
     }
     this.Id = pathGuideItem.Id;
     this.Index = pathGuideItem.Index;
     this.IsEdge = pathGuideItem.IsEdge;
     this.IsStop = pathGuideItem.IsStop;
     this.Length = pathGuideItem.Length;
     this.Name = pathGuideItem.Name;
     this.SideType = pathGuideItem.SideType;
     this.TurnAngle = pathGuideItem.TurnAngle;
     this.TurnType = pathGuideItem.TurnType;
     this.Weight = pathGuideItem.Weight;
 }
Exemplo n.º 2
0
        /// <summary>
        /// 显示结果。
        /// Show result
        /// </summary>
        /// <param name="pathNum"></param>
        public void FillResultTable(Int32 pathNum)
        {
            try
            {
                // 清除原数据,添加初始点信息
                // Clear original data and add start point information
                m_dataGridView.Rows.Clear();
                Object[] objs = new Object[4];
                objs[0] = m_dataGridView.RowCount;
                if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
                {
                    objs[1] = "Start";
                }
                else
                {
                    objs[1] = "从起始点出发";
                }
                objs[2] = "--";
                objs[3] = "--";
                m_dataGridView.Rows.Add(objs);

                // 得到行驶导引对象,根据导引子项类型的不同进行不同的填充
                // Get the PathGuide object, and make different fill according to different items
                PathGuide[] pathGuides = m_analystResult.PathGuides;
                PathGuide   pathGuide  = pathGuides[pathNum];

                for (int j = 1; j < pathGuide.Count; j++)
                {
                    PathGuideItem item = pathGuide[j];
                    objs[0] = m_dataGridView.RowCount;
                    // 导引子项为站点的添加方式
                    // If the item is a stop
                    if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
                    {
                        if (item.IsStop)
                        {
                            String side = "None";
                            if (item.SideType == SideType.Left)
                            {
                                side = "Left";
                            }
                            if (item.SideType == SideType.Right)
                            {
                                side = "Right";
                            }
                            if (item.SideType == SideType.Middle)
                            {
                                side = "On the road";
                            }
                            String dis = item.Distance.ToString();

                            if (j != pathGuide.Count - 1)
                            {
                                objs[1] = "Arrive at [" + item.Index + " route], on the " + side
                                          + dis;
                            }
                            else
                            {
                                objs[1] = "Arrive at destination " + side + dis;
                            }
                            objs[2] = "";
                            objs[3] = "";
                            m_dataGridView.Rows.Add(objs);
                        }
                    }
                    else
                    {
                        if (item.IsStop)
                        {
                            String side = "无";
                            if (item.SideType == SideType.Left)
                            {
                                side = "左侧";
                            }
                            if (item.SideType == SideType.Right)
                            {
                                side = "右侧";
                            }
                            if (item.SideType == SideType.Middle)
                            {
                                side = "上";
                            }
                            String dis = item.Distance.ToString();

                            if (j != pathGuide.Count - 1)
                            {
                                objs[1] = "到达[" + item.Index + "号路由点],在道路" + side
                                          + dis;
                            }
                            else
                            {
                                objs[1] = "到达终点,在道路" + side + dis;
                            }
                            objs[2] = "";
                            objs[3] = "";
                            m_dataGridView.Rows.Add(objs);
                        }
                    }

                    // 导引子项为弧段的添加方式
                    // If the item is a edge
                    if (SuperMap.Data.Environment.CurrentCulture != "zh-CN")
                    {
                        if (item.IsEdge)
                        {
                            String direct = "Go ahead";
                            if (item.DirectionType == DirectionType.East)
                            {
                                direct = "East";
                            }
                            if (item.DirectionType == DirectionType.West)
                            {
                                direct = "West";
                            }
                            if (item.DirectionType == DirectionType.South)
                            {
                                direct = "South";
                            }
                            if (item.DirectionType == DirectionType.North)
                            {
                                direct = "North";
                            }

                            String weight = item.Weight.ToString();

                            String roadName   = item.Name;
                            String roadString = roadName.Equals("") ? "Anonymous road" : roadName;
                            objs[1] = "Go along with [" + roadString + "], " + direct + " direction"
                                      + weight;
                            objs[2] = weight;
                            objs[3] = item.Length;
                            m_dataGridView.Rows.Add(objs);
                        }
                    }
                    else
                    {
                        if (item.IsEdge)
                        {
                            String direct = "直行";
                            if (item.DirectionType == DirectionType.East)
                            {
                                direct = "东";
                            }
                            if (item.DirectionType == DirectionType.West)
                            {
                                direct = "西";
                            }
                            if (item.DirectionType == DirectionType.South)
                            {
                                direct = "南";
                            }
                            if (item.DirectionType == DirectionType.North)
                            {
                                direct = "北";
                            }

                            String weight = item.Weight.ToString();

                            String roadName   = item.Name;
                            String roadString = roadName.Equals("") ? "匿名路段" : roadName;
                            objs[1] = "沿着[" + roadString + "],朝" + direct + "行走"
                                      + weight;
                            objs[2] = weight;
                            objs[3] = item.Length;
                            m_dataGridView.Rows.Add(objs);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message);
            }
        }