示例#1
0
        private WaypointList GenTwoWayAirway()
        {
            var wpts = new WaypointList();

            //index = 0
            wpts.AddWaypoint(new Waypoint(WptIdGenerator(1)));

            for (int i = 1; i <= 10; i++)
            {
                wpts.AddWaypoint(new Waypoint(WptIdGenerator(i)));
            }

            for (int i = 1; i <= 10; i++)
            {
                var n = new Neighbor("A001", 10);
                wpts.AddNeighbor(i, i - 1, n);
            }

            for (int i = 0; i <= 9; i++)
            {
                var n = new Neighbor("A001", 10);
                wpts.AddNeighbor(i, i + 1, n);
            }

            return(wpts);
        }
示例#2
0
        private static WaypointList BasicWptList()
        {
            var wptList = new WaypointList();

            int index1 = wptList.AddWaypoint(new Waypoint("25N050E", 25.0, 50.0));
            int index2 = wptList.AddWaypoint(new Waypoint("27N050E", 27.0, 50.0));

            wptList.AddNeighbor(index1, "AIRWAY1", index2);
            wptList.AddNeighbor(index2, "AIRWAY1", index1);

            return(wptList);
        }
示例#3
0
        private AnalyzerWithCommands GetAnalyzer1(params string[] route)
        {
            InitObjects1();

            var wptList = new WaypointList();

            var wptP1 = new Waypoint("P1", 24.0, 120.0);
            var wptQ1 = new Waypoint("Q1", 23.0, 114.0);
            int p1    = wptList.AddWaypoint(wptP1);
            int q1    = wptList.AddWaypoint(wptQ1);

            var neighbor = new Neighbor("A1", wptP1.Distance(wptQ1));

            wptList.AddNeighbor(p1, q1, neighbor);

            return(new AnalyzerWithCommands(
                       route.ToRouteString(),
                       "ABCD",
                       "05L",
                       "EFGH",
                       "07L",
                       airportList,
                       wptList,
                       wptList.GetEditor(),
                       sids,
                       stars));
        }
        private static void AddAirways(WaypointList wptList)
        {
            foreach (var i in airwayEntries)
            {
                int x        = TryAddWpt(wptList, i.StartWpt);
                int y        = TryAddWpt(wptList, i.EndWpt);
                var neighbor = new Neighbor(i.Airway, wptList.Distance(x, y));

                wptList.AddNeighbor(x, y, neighbor);
            }
        }
示例#5
0
        private WaypointList Case4WptList()
        {
            var wptList = new WaypointList();
            int index   = wptList.AddWaypoint(
                new Waypoint("26N050E", 26.0, 50.0));

            int indexNeighbor = wptList.AddWaypoint(
                new Waypoint("27N050E", 27.0, 50.0));

            wptList.AddNeighbor(index, "AIRWAY1", indexNeighbor);

            return(wptList);
        }
示例#6
0
        public void ConnectionRoutesAddedCorrectly()
        {
            // Arrange
            var p1 = new Waypoint("P1", 0.0, 0.0);
            var p2 = new Waypoint("P2", 5.0, 5.0);

            var q1 = new Waypoint("Q1", 3.0, 3.0);
            var q2 = new Waypoint("Q2", 2.0, 3.0);
            var q3 = new Waypoint("Q3", 1.0, 3.0);

            var wptList = new WaypointList();
            int p1Index = wptList.AddWaypoint(p1);

            wptList.AddWaypoint(p2);

            int q1Index  = wptList.AddWaypoint(q1);
            int q2Index  = wptList.AddWaypoint(q2);
            int q3Index  = wptList.AddWaypoint(q3);
            var neighbor = new Neighbor("A1", q1.Distance(q2));

            wptList.AddNeighbor(q1Index, q2Index, neighbor);

            var reader = new TrackReader <PacificTrack>(
                wptList, new AirportManager());

            string[] routeFrom = { "Q1", "A1", "Q2", "UPR", "Q3", "P1" };

            // Act
            var nodes = reader.Read(
                new PacificTrack(
                    PacotDirection.Westbound,
                    "A",
                    "",
                    "",
                    "",
                    RouteString.From("P1", "P2"),
                    new[] { routeFrom.ToRouteString() },
                    new[] { RouteString.Empty },
                    new LatLon(0.0, 0.0),
                    new LatLon(0.0, 0.0)));

            // Assert
            var pairs = nodes.ConnectionRoutes.ToList();

            Assert.AreEqual(1, pairs.Count);

            var pair = pairs.First();

            Assert.AreEqual(q3Index, pair.IndexFrom);
            Assert.AreEqual(p1Index, pair.IndexTo);
        }
        public void WhenPreferredLatLonAreBadShouldStillFindsResult()
        {
            // setup
            var wpts = new[]
            {
                new Waypoint("P01", 0.0, 15.0),
                new Waypoint("P02", 0.0, 16.0),
                new Waypoint("P03", 0.0, 17.0),
                new Waypoint("P01", 50.0, -30.0)
            };

            var wptList = new WaypointList();
            var indices = wpts.Select(w => wptList.AddWaypoint(w)).ToList();

            wptList.AddNeighbor(indices[0], "A01", indices[1]);
            wptList.AddNeighbor(indices[1], "A02", indices[2]);

            // Added so that there are 2 airways to choose from at P03.
            wptList.AddNeighbor(indices[1], "A03", indices[3]);

            var analyzer = new AutoSelectAnalyzer(
                GetRouteString("P01", "A01", "P02", "A02", "P03"),
                new LatLon(50.0, -30.0),
                new LatLon(50.0, -30.0),
                wptList);

            // invoke
            var route = analyzer.Analyze();

            // assert
            var expected = GetRoute(
                wpts[0], "A01", -1.0,
                wpts[1], "A02", -1.0,
                wpts[2]);

            Assert.IsTrue(route.Equals(expected));
        }
示例#8
0
        public void WhenRouteUseAirwaysAnalyzeCorrectness()
        {
            // setup
            var wpts = new[]
            {
                new Waypoint("P01", 0.0, 15.0),
                new Waypoint("P02", 0.0, 16.0),
                new Waypoint("P03", 0.0, 17.0),
                new Waypoint("P04", 0.0, 18.0)
            };

            var wptList = new WaypointList();
            var indices = wpts.Select(w => wptList.AddWaypoint(w)).ToList();

            wptList.AddNeighbor(indices[0], "A01", indices[1]);
            wptList.AddNeighbor(indices[1], "A02", indices[2]);

            // Added so that there are 2 airways to choose from at P03.
            wptList.AddNeighbor(indices[1], "A03", indices[3]);

            var analyzer = new BasicRouteAnalyzer(
                GetRouteString("P01", "A01", "P02", "A02", "P03"),
                wptList,
                wptList.FindById("P01"));

            // invoke
            var route = analyzer.Analyze();

            // assert
            var expected = GetRoute(
                wpts[0], "A01", -1.0,
                wpts[1], "A02", -1.0,
                wpts[2]);

            Assert.IsTrue(route.Equals(expected));
        }
示例#9
0
 public static void AddNeighbor(this WaypointList wptList, int index1,
                                string airway, int index2)
 {
     wptList.AddNeighbor(index1, index2,
                         new Neighbor(airway, wptList.Distance(index1, index2)));
 }
示例#10
0
        // Reads the ATS.txt into the given WaypointList.
        // If the waypoints on a line is not found in wptList, it's added.
        // This method continues to read if an parsing error is encountered on a line.
        //
        public static IReadOnlyList <ReadFileError> Read(WaypointList wptList,
                                                         IEnumerable <string> allLines)
        {
            var    errors        = new List <ReadFileError>();
            string currentAirway = "";

            allLines.ForEach((line, index) =>
            {
                var lineNum = index + 1;
                var words   = line.Split(',').Select(s => s.Trim()).ToList();

                if (words.Count == 0)
                {
                    return;
                }

                try
                {
                    if (words[0] == "A")
                    {
                        // This line is an airway identifier
                        currentAirway = words[1];
                    }
                    else if (words[0] == "S")
                    {
                        // This line is waypoint
                        var firstWpt = new Waypoint(
                            words[1], double.Parse(words[2]), double.Parse(words[3]));

                        var secondWpt = new Waypoint(
                            words[4], double.Parse(words[5]), double.Parse(words[6]));

                        int index1 = wptList.FindByWaypoint(firstWpt);
                        int index2 = wptList.FindByWaypoint(secondWpt);

                        // words[7] and words[8] are headings between two waypoints.
                        // Will be skipped.

                        double dis = double.Parse(words[9]);

                        // Add second waypoint as required
                        if (index2 <= 0)
                        {
                            index2 = wptList.AddWaypoint(secondWpt);
                        }

                        // Add first waypoint as required
                        if (index1 < 0)
                        {
                            index1 = wptList.AddWaypoint(firstWpt);
                        }

                        // Add the connection.
                        var neighbor = new Neighbor(currentAirway, dis);

                        wptList.AddNeighbor(index1, index2, neighbor);
                    }
                }
                catch
                {
                    errors.Add(new ReadFileError(lineNum, line));
                }
            });

            return(errors);
        }