Ejemplo n.º 1
0
        public void BulidWay(WaySetter ws)
        {
            IRoadNet inet = RoadNet.GetInstance();

            Way            = inet.BuildWay(this.Shape.Start, this.Shape.End);
            Way.Name       = ws.TBWayName.Text + Way.ID.ToString();
            Way.TrueLength = (double)ws.TBLength.Value;
            ///先创建一个车道做测试
            int iLaneCount = System.Convert.ToInt32(ws.TBLaneCount.Value);

            Way.AddLane(LaneType.All);
            Way.Shape = EntityShape.CreateShape(this.shape);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// create xnode way road and lane.
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="et"></param>
        /// <returns></returns>
        public StaticOBJ Build(OxyzPointF start, OxyzPointF end, EntityType et)
        {
            var net = RoadNet.GetInstance();

            switch (et)
            {
            case EntityType.Road:
                var road = new Road();

                road.Way       = this.Build(start, end, EntityType.Way) as Way;
                road.CtrWay    = this.Build(end, start, EntityType.Way) as Way;
                road.Container = net;

                //register
                net.roads.Add(road.GetHashCode(), road);                       //register
                return(road);

            ///avoid to create a xnode
            case EntityType.XNode:
                var node = new XNode(start);

                node.Container = net;
                net.xnodes.Add(node.GetHashCode(), node);                       //register
                return(node);

            case EntityType.Way:
                var way = new Way(start, end);
                //way.AddLane(LaneType.Straight);
                //way.Container = net;
                net.ways.Add(way.GetHashCode(), way);                       //register

                return(way);

            //break;
            case EntityType.Lane:

                throw new Exception("lane should be builded by way");
                break;

            default:
                break;
            }
            throw new  ArgumentException("无法创建参数指定的构造型");
        }
Ejemplo n.º 3
0
        private static void LoadMobiles()
        {
            IRoadNet inet = RoadNet.GetInstance();
            Way      way  = null;//= new Way(;

            foreach (var item in inet.Ways)
            {
                way = item;
            }
            Lane startLane = way.Lanes[0];
            int  i         = SimController.iMobileCount;

            while (i-- > 0)
            {
                //新建一条路由
                EdgeRoute route = new EdgeRoute();
                //设置每段路走哪条路
                route.Add(way);
                var car = MobileFactory.BuildSmallCar();
                car.Route = route;
                startLane.EnterInn(car);
            }
        }
Ejemplo n.º 4
0
        private void ShowDebugMessage()
        {
            DebugShower ds   = new DebugShower();
            IRoadNet    inet = RoadNet.GetInstance();

            List <string> list = new List <string>();

            foreach (var item in inet.Ways)
            {
                list.Add(item.Name);
            }
            ds.LB_LaneNuber.DataSource = list;

            List <string> listLane = new List <string>();

            foreach (var item in inet.Lanes)
            {
                listLane.Add(item.Name + item.Shape.Count.ToString());
            }

            ds.LB_LaneShape.DataSource = listLane;//.lane.Lanes;// as Dictionary<int, lane>;
            SplitMain.Panel2.Controls.Add(ds);
            ds.Show();
        }