Exemplo n.º 1
0
        public void Case3Test()
        {
            // Setup
            var route = new[] { "SIERA", "P1", "STAR1" };

            var wptList = new WaypointList();
            var wpt     = new Waypoint("SIERA", 18.0, 115.0);

            wptList.AddWaypoint(wpt);

            var rwy = new Waypoint("VHHH07L", 18.0, 118.0);
            var p1  = new Waypoint("P1", 18.5, 117.0);

            var star = new StarEntry(
                "07L",
                "STAR1",
                new[] { p1 },
                EntryType.RwySpecific);

            var stars = new StarCollection(new[] { star });

            var extractor = new StarExtractor(
                route.ToRouteString(),
                "07L",
                rwy,
                wptList,
                stars);

            var result = extractor.Extract();

            Assert.IsTrue(result.RemainingRoute.SequenceEqual(new[] { "SIERA" }));

            var destRoute = result.DestRoute;

            Assert.AreEqual(3, destRoute.Count);

            var node1     = destRoute.First();
            var neighbor1 = node1.AirwayToNext;

            Assert.IsTrue(node1.Waypoint.Equals(wpt));
            Assert.IsTrue("DCT" == neighbor1.Airway);
            Assert.AreEqual(wpt.Distance(p1), neighbor1.Distance, 1E-8);
            Assert.AreEqual(0, neighbor1.InnerWaypoints.Count);
            Assert.AreEqual(InnerWaypointsType.None, neighbor1.Type);

            var node2     = destRoute.First.Next.Value;
            var neighbor2 = node2.AirwayToNext;

            Assert.IsTrue(node2.Waypoint.Equals(p1));
            Assert.IsTrue("STAR1" == neighbor2.Airway);
            Assert.AreEqual(p1.Distance(rwy), neighbor2.Distance, 1E-8);
            Assert.AreEqual(0, neighbor2.InnerWaypoints.Count);
            Assert.AreEqual(InnerWaypointsType.Terminal, neighbor2.Type);

            Assert.IsTrue(destRoute.Last().Waypoint.Equals(rwy));
        }
Exemplo n.º 2
0
        private void AddToWptListCase2And4(WaypointList wptList)
        {
            var entry = new StarEntry(
                "18",
                "STAR1",
                List(wpt101, wpt102, wpt103, wpt104),
                EntryType.RwySpecific);

            var adder = new StarAdder(
                "AXYZ",
                new StarCollection(List(entry)),
                wptList,
                wptList.GetEditor(),
                GetAirportManager());

            int rwyIndex = adder.AddStarsToWptList("18", List("STAR1"));

            // Check the STAR1 has been added with correct total distance.
            var edges = wptList.EdgesTo(rwyIndex).ToList();

            Assert.IsTrue(edges.Count > 0);

            Assert.IsTrue(edges
                          .Select(e => wptList.GetEdge(e))
                          .All(e =>
                               e.Value.InnerWaypoints.SequenceEqual(List(wpt102, wpt103, wpt104)) &&
                               e.Value.Type == InnerWaypointsType.Terminal));

            double dis = List(wpt101, wpt102, wpt103, wpt104, rwy)
                         .TotalDistance();

            Assert.IsTrue(StarIsAdded(
                              wptList.FindByWaypoint(wpt101),
                              "STAR1",
                              dis,
                              wptList));

            // Check the edges of first wpt
            int index = wptList.FindByWaypoint(wpt101);

            Assert.IsTrue(index >= 0);
            Assert.AreEqual(2, wptList.EdgesToCount(index));

            foreach (var i in wptList.EdgesTo(index))
            {
                var edge = wptList.GetEdge(i);
                Assert.AreEqual("DCT", edge.Value.Airway);
                Assert.AreEqual(0, edge.Value.InnerWaypoints.Count);

                double expectedDis = wpt101.Distance(wptList[edge.FromNodeIndex]);
                Assert.AreEqual(expectedDis, edge.Value.Distance, DistanceEpsilon);
            }
        }
Exemplo n.º 3
0
        public void Case2Test()
        {
            // Setup
            var route = new[] { "ELATO", "SIERA", "STAR1" };

            var wptList = new WaypointList();
            var wpt     = new Waypoint("SIERA", 18.0, 115.0);

            wptList.AddWaypoint(wpt);

            var rwy = new Waypoint("VHHH07L", 18.0, 118.0);
            var p1  = new Waypoint("P1", 18.5, 117.0);

            var star = new StarEntry(
                "07L",
                "STAR1",
                new[] { wpt, p1 },
                EntryType.RwySpecific);

            var stars = new StarCollection(new[] { star });

            var extractor = new StarExtractor(
                route.ToRouteString(),
                "07L",
                rwy,
                wptList,
                stars);

            var result = extractor.Extract();

            Assert.IsTrue(result.RemainingRoute.SequenceEqual(new[] { "ELATO", "SIERA" }));

            var destRoute = result.DestRoute;

            Assert.AreEqual(2, destRoute.Count);

            var node1    = destRoute.First();
            var neighbor = node1.AirwayToNext;

            Assert.IsTrue(node1.Waypoint.Equals(wpt));
            Assert.IsTrue("STAR1" == neighbor.Airway);

            double distance = new[] { wpt, p1, rwy }.TotalDistance();

            Assert.AreEqual(distance, neighbor.Distance, 1E-8);
            Assert.IsTrue(neighbor.InnerWaypoints.SequenceEqual(new[] { p1 }));
            Assert.AreEqual(InnerWaypointsType.Terminal, neighbor.Type);

            Assert.IsTrue(destRoute.Last().Waypoint.Equals(rwy));
        }
Exemplo n.º 4
0
        public void AddToWptListCase3()
        {
            var wptList   = BasicWptList();
            var wptCorrds = new Waypoint("26N050E", 26.0, 50.0);
            var wpt01     = new Waypoint("WPT01", 25.0, 50.0);

            var entry = new StarEntry(
                "18",
                "STAR1",
                List(wptCorrds, wpt01),
                EntryType.RwySpecific);

            var adder = new StarAdder(
                "AXYZ",
                new StarCollection(List(entry)),
                wptList,
                wptList.GetEditor(),
                GetAirportManager());

            int rwyIndex = adder.AddStarsToWptList("18", List("STAR1"));

            // Check the STAR1 has been added with correct total distance.
            var edges = wptList.EdgesTo(rwyIndex).ToList();

            Assert.AreEqual(1, edges.Count);
            var edge = wptList.GetEdge(edges[0]);

            Assert.IsTrue(edge.Value.InnerWaypoints.SequenceEqual(List(wpt01)));
            Assert.AreEqual(InnerWaypointsType.Terminal, edge.Value.Type);

            double dis = List(wptCorrds, wpt01, rwy).TotalDistance();

            Assert.IsTrue(StarIsAdded(
                              wptList.FindByWaypoint(wptCorrds),
                              "STAR1",
                              dis,
                              wptList));
        }