private static void AssertTrackC(WaypointList wptList) { var edge = wptList.GetEdge(GetEdgeIndex("NATC", "ETARI", wptList)); // Distance var expectedDis = new ICoordinate[] { wptList[wptList.FindById("ETARI")], new LatLon(55.5, -20), new LatLon(55.5, -30), new LatLon(55.5, -40), new LatLon(54.5, -50), wptList[wptList.FindById("MELDI")] }.TotalDistance(); Assert.AreEqual(expectedDis, edge.Value.Distance, 0.01); // Start, end waypoints are correct Assert.IsTrue(wptList[edge.FromNodeIndex].ID == "ETARI"); Assert.IsTrue(wptList[edge.ToNodeIndex].ID == "MELDI"); // Start, end waypoints are connected Assert.IsTrue(wptList.EdgesFromCount(edge.FromNodeIndex) > 0); Assert.IsTrue(wptList.EdgesToCount(edge.ToNodeIndex) > 0); // Airway is correct Assert.IsTrue(edge.Value.Airway == "NATC"); }
private static void AssertTrackZ(WaypointList wptList) { var edge = wptList.GetEdge(GetEdgeIndex("NATZ", "SOORY", wptList)); var expectedDis = new ICoordinate[] { wptList[wptList.FindById("SOORY")], new LatLon(42.0, -50.0), new LatLon(44.0, -40.0), new LatLon(44.0, -30.0), new LatLon(46.0, -20.0), new LatLon(46.0, -15.0), wptList[wptList.FindById("SEPAL")], wptList[wptList.FindById("LAPEX")] }.TotalDistance(); // Distance Assert.AreEqual(expectedDis, edge.Value.Distance, 0.01); // Start, end waypoints are correct Assert.IsTrue(wptList[edge.FromNodeIndex].ID == "SOORY"); Assert.IsTrue(wptList[edge.ToNodeIndex].ID == "LAPEX"); // Start, end waypoints are connected Assert.IsTrue(wptList.EdgesFromCount(edge.FromNodeIndex) > 0); Assert.IsTrue(wptList.EdgesToCount(edge.ToNodeIndex) > 0); // Airway is correct Assert.IsTrue(edge.Value.Airway == "NATZ"); }
private static void AssertTrackJ(WaypointList wptList) { var edge = wptList.GetEdge(GetEdgeIndex("PACOTJ", "ALCOA", wptList)); // Distance var expectedDis = new ICoordinate[] { wptList[wptList.FindById("ALCOA")], wptList[wptList.FindById("CEPAS")], wptList[wptList.FindById("COBAD")], new LatLon(41, -140), new LatLon(42, -150), new LatLon(40, -160), new LatLon(37, -170), new LatLon(33, 180), new LatLon(29, 170), new LatLon(27, 160), new LatLon(26, 150), new LatLon(27, 140), wptList[wptList.FindById("BIXAK")] }.TotalDistance(); Assert.AreEqual(expectedDis, edge.Value.Distance, 0.01); // Start, end waypoints are correct Assert.IsTrue(wptList[edge.FromNodeIndex].ID == "ALCOA"); Assert.IsTrue(wptList[edge.ToNodeIndex].ID == "BIXAK"); // Start, end waypoints are connected Assert.IsTrue(wptList.EdgesFromCount(edge.FromNodeIndex) > 0); Assert.IsTrue(wptList.EdgesToCount(edge.ToNodeIndex) > 0); // Airway is correct Assert.IsTrue(edge.Value.Airway == "PACOTJ"); }
// Finds a list of waypoints which is near the given // Lat/Lon, and are connected to at least one other waypoint. private static List <IndexDistancePair> Find( double Lat, double Lon, bool IsSid, WaypointList wptList, WptSearchOption option) { double searchRange = 0.0; var result = new List <IndexDistancePair>(); while (searchRange <= option.MaxSearchRange && result.Count < option.TargetCount) { result.Clear(); searchRange += option.SearchRangeIncr; var searchResult = wptList.Find(Lat, Lon, searchRange); foreach (var item in searchResult) { int i = item.Index; if ((IsSid && wptList.EdgesFromCount(i) > 0) || (IsSid == false && wptList.EdgesToCount(i) > 0)) { double dctDis = wptList[i].Distance(Lat, Lon); result.Add(new IndexDistancePair(i, dctDis)); } } } return(result); }
private static void AssertTrack11(WaypointList wptList) { var edge = wptList.GetEdge(GetEdgeIndex("PACOT11", "SEALS", wptList)); // Distance var expectedDis = new ICoordinate[] { wptList[wptList.FindById("SEALS")], new LatLon(36, 150), new LatLon(37, 160), new LatLon(36, 170), new LatLon(33, 180), new LatLon(29, -170), wptList[wptList.FindById("DANNO")] }.TotalDistance(); Assert.AreEqual(expectedDis, edge.Value.Distance, 0.01); // Start, end waypoints are correct Assert.IsTrue(wptList[edge.FromNodeIndex].ID == "SEALS"); Assert.IsTrue(wptList[edge.ToNodeIndex].ID == "DANNO"); // Start, end waypoints are connected Assert.IsTrue(wptList.EdgesFromCount(edge.FromNodeIndex) > 0); Assert.IsTrue(wptList.EdgesToCount(edge.ToNodeIndex) > 0); // Airway is correct Assert.IsTrue(edge.Value.Airway == "PACOT11"); }
/// <exception cref="WaypointNotFoundException"></exception> private void AddToWptList(int rwyIndex, string rwy, string star) { var starWpts = stars.StarWaypoints(star, rwy, wptList[rwyIndex]); var firstWpt = starWpts[0]; int firstWptIndex = wptList.FindByWaypoint(firstWpt); if (firstWptIndex < 0) { // Case 4 firstWptIndex = editor.AddWaypoint(firstWpt); } if (wptList.EdgesToCount(firstWptIndex) == 0) { // Case 2 foreach (var k in AirwayConnections(firstWpt)) { var n = new Neighbor("DCT", k.Distance); editor.AddNeighbor(k.Index, firstWptIndex, n); } } // For case 2, 3 and 4 var neighbor = new Neighbor( star, starWpts.TotalDistance(), starWpts.WithoutFirstAndLast(), InnerWaypointsType.Terminal); editor.AddNeighbor(firstWptIndex, rwyIndex, neighbor); }
private static void AssertTrackBP14(WaypointList wptList) { var edge = wptList.GetEdge(GetEdgeIndex("AUSOTBP14", "TAXEG", wptList)); var expectedDistance = new[] { "TAXEG", "PASTA", "TAROR", "WR", "ENTRE", "MALLY", "NSM" }.Select(id => wptList[wptList.FindById(id)]).TotalDistance(); // Distance Assert.AreEqual(expectedDistance, edge.Value.Distance, 0.01); // Start, end waypoints are correct Assert.IsTrue(wptList[edge.FromNodeIndex].ID == "TAXEG"); Assert.IsTrue(wptList[edge.ToNodeIndex].ID == "NSM"); // Start, end waypoints are connected Assert.IsTrue(wptList.EdgesFromCount(edge.FromNodeIndex) > 0); Assert.IsTrue(wptList.EdgesToCount(edge.ToNodeIndex) > 0); // Airway is correct Assert.IsTrue(edge.Value.Airway == "AUSOTBP14"); }
private static void AssertTrackMY14(WaypointList wptList) { var edge = wptList.GetEdge(GetEdgeIndex("AUSOTMY14", "JAMOR", wptList)); // Distance var expectedDistance = new[] { "JAMOR", "IBABI", "LEC", "OOD", "ARNTU", "KEXIM", "CIN", "ATMAP" }.Select(id => wptList[wptList.FindById(id)]).TotalDistance(); Assert.AreEqual(expectedDistance, edge.Value.Distance, 0.01); // Start, end waypoints are correct Assert.IsTrue(wptList[edge.FromNodeIndex].ID == "JAMOR"); Assert.IsTrue(wptList[edge.ToNodeIndex].ID == "ATMAP"); // Start, end waypoints are connected Assert.IsTrue(wptList.EdgesFromCount(edge.FromNodeIndex) > 0); Assert.IsTrue(wptList.EdgesToCount(edge.ToNodeIndex) > 0); // Airway is correct Assert.IsTrue(edge.Value.Airway == "AUSOTMY14"); }
// Returns the index of added wpt in wptList. private int AddFirstWpt(Waypoint wpt) { int x = wptList.FindByWaypoint(wpt); if (x < 0) { throw new TrackWaypointNotFoundException($"Waypoint {wpt.ID} is not found."); } if (wptList.EdgesToCount(x) == 0) { // No other wpt have this wpt as a neighbor, // need to find nearby wpt to connect. var k = WaypointAirwayConnector.ToAirway(wpt.Lat, wpt.Lon, wptList); foreach (var m in k) { int index = m.Index; double dis = wptList.Distance(x, index); editor.AddNeighbor(index, x, new Neighbor("DCT", dis)); } } return(x); }
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); } }