示例#1
0
        private static List <int> GetLineIndices(Node parent) // returns all lines passing through this node
        {
            Line line = Lines[parent.LineIndex];

            Line.Branch      branch = line.Branches[parent.BranchIndex];
            Line.Branch.Stop stop   = branch.StopSequence[parent.StationIndex];
            return(stop.LineIds);
            //return Lines[parent.LineIndex].Branches[parent.BranchIndex].StopSequence[parent.StationIndex].LineIds;
        }
示例#2
0
        private static void FixCircleLine(StationDictionary stationDiction, LineDictionary lineDiction) // fix to error in circle line, where paddington and edgware road are not end of branch
        {
            int circleId      = lineDiction.GetKey("circle");
            int paddingtonId  = stationDiction.GetKey("paddington");
            int edgwareRoadId = stationDiction.GetKey("edgware road");

            Line.Branch.Stop edgwareRoad = null;
            Line.Branch.Stop paddington  = null;

            Line circleLine = Lines[circleId]; // alias

            Line.Branch branch;
            int         branchLength;

            for (int i = 0; i < circleLine.Branches.Count(); i++)
            {
                branch       = circleLine.Branches[i];
                branchLength = branch.StopSequence.Count();

                if (branch.StopSequence[0].StationId == edgwareRoadId)
                {
                    edgwareRoad = branch.StopSequence[0];
                    if (branch.StopSequence[1].StationId == paddingtonId)
                    {
                        paddington = branch.StopSequence[1];
                        branch.StopSequence.RemoveAt(0);
                    }
                }

                else if (branch.StopSequence[branchLength - 1].StationId == edgwareRoadId)
                {
                    edgwareRoad = branch.StopSequence[branchLength - 1];
                    if (branch.StopSequence[branchLength - 2].StationId == paddingtonId)
                    {
                        paddington = branch.StopSequence[branchLength - 2];
                        branch.StopSequence.RemoveAt(branchLength - 1);
                    }
                }
            }

            List <Line.Branch.Stop> stops = new List <Line.Branch.Stop> {
                paddington, edgwareRoad
            };

            circleLine.Branches.Add(new Line.Branch(stops));
        }
示例#3
0
 private static void RightInsertBreak(Node n)
 {
     Line.Branch.Stop cut = new Line.Branch.Stop(-1);                                         // -1 is break value
     Lines[n.LineIndex].Branches[n.BranchIndex].StopSequence.Insert(n.StationIndex + 1, cut); // right insert
 }