public RoadDistance(Road road, double distance, bool endofmap)
     : this()
 {
     Distance = distance;
     EndOfMap = endofmap;
     Road = road;
 }
Example #2
0
        public RoadLane(Road road, LaneDirection lanedirection, LaneType lanetype, int laneindex, double width,
                        double translation)
        {
            int colorindex;

            if (lanedirection == LaneDirection.Backward)
                colorindex = laneindex;
            else
                colorindex = -laneindex - 1;

            curvecolor = Colors.GetSaturatedColor(colorindex);
            ILaneContainer = road;
            LaneDirection = lanedirection;
            LaneIndex = laneindex;
            LaneType = lanetype;
            linecolor = road.LineColor;
            this.road = road;
            roadcolor = road.RoadColor;
            this.translation = translation;
            vehiclelist = new List<Vehicle>();
            Width = width;

            setbeziers();
            setgaplengths();

            Length = beziers.Sum(bezier => bezier.Length);
            spawndistance = 2*road.GetMaximumSpeed("Vehicle")/beziers[0].Length;
        }
        public void AddTrafficLight(Road road, TrafficLight trafficlight)
        {
            if (!roadlist.Contains(road))
            {
                roadlist.Add(road);
                trafficlightdictionary.Add(road, new List<TrafficLight>());
            }

            trafficlightdictionary[road].Add(trafficlight);
        }
 public RoadConnection(Road road, Dictionary<int, HashSet<RoadLaneIndex>> connectiondictionary)
     : this()
 {
     ConnectionDictionary = connectiondictionary;
     Road = road;
 }
Example #5
0
        private Road GetRoadTo(Road source, Point point)
        {
            var roaddistancelist = new List<RoadDistance>();

            foreach (Road road in roadlist.Where(road => road != source))
            {
                double distance = road.GetOffwardCoordinate(location).DistanceTo(point);

                if (distance < road.Width)
                    return road;

                bool endofmap = (road.IsToward(location) && road.Previous == null) ||
                                (!road.IsToward(location) && road.Next == null);
                roaddistancelist.Add(new RoadDistance(road, distance, endofmap));
            }

            roaddistancelist = roaddistancelist.Where(roaddistance => !roaddistance.EndOfMap).ToList();
            double min = roaddistancelist.Min(roaddistance => roaddistance.Distance);
            roaddistancelist =
                roaddistancelist.Where(roaddistance => roaddistance.Distance < 1.2*min).ToList();

            if (roaddistancelist.Count > 1)
                roaddistancelist.Sort(
                    (r1, r2) => r1.Road.VehicleCount.CompareTo(r2.Road.VehicleCount));

            return roaddistancelist[0].Road;
        }
Example #6
0
 public int GetLaneIndexTo(Road source, Point point)
 {
     Road exit = GetRoadTo(source, point);
     List<CrossingLane> sublanelist =
         lanelist.Where(
             crossinglane =>
             crossinglane.PreviousLane.Road == source && crossinglane.NextLane.Road == exit).ToList();
     return (sublanelist[0].PreviousLane.LaneIndex);
 }