private SubRoute ComputeTerminalRoute(RouteString item, bool isOrig, bool isDest) { Route origRoute = null; Route destRoute = null; if (isOrig) { var sidExtract = new SidExtractor(item, origRwy, origRwyWpt, wptList, sids) .Extract(); origRoute = sidExtract.OrigRoute; item = sidExtract.RemainingRoute; } if (isDest) { var starExtract = new StarExtractor(item, destRwy, destRwyWpt, wptList, stars) .Extract(); destRoute = starExtract.DestRoute; item = starExtract.RemainingRoute; } var remainRoute = origRoute == null ? GetAutoSelectRoute(item) : GetBasicRoute(item, wptList.FindByWaypoint(origRoute.LastWaypoint)); return(new[] { origRoute, remainRoute, destRoute } .Where(r => r != null) .Connect() .ToSubRoute()); }
private List <WptPair> GetExtraPairs(RouteString rteFrom, ICoordinate previous) { var result = new List <WptPair>(); int lastIndex = -1; foreach (var from in rteFrom) { if (lastIndex >= 0) { if (IsAirway(lastIndex, from)) { lastIndex = -1; } else { int wpt = SelectWpt(from, previous); result.Add(new WptPair(lastIndex, wpt)); lastIndex = wpt; } } else { lastIndex = SelectWpt(from, previous); } } return(result); }
public void GroupNoSegmentShouldBeEmpty() { var input = new RouteString("AUTO A B".Split(' ')); var result = EntryGrouping.Group(input); Assert.AreEqual(2, result.Count); Assert.IsTrue(result[0].IsAuto); AssertSegment(result[1], new[] { "A", "B" }); }
public AutoSelectAnalyzer( RouteString route, ICoordinate orig, ICoordinate dest, WaypointList wptList) { this.route = route; this.orig = orig; this.dest = dest; this.wptList = wptList; }
public void GroupTest() { var input = new RouteString("A B AUTO C D RAND E".Split(' ')); var result = EntryGrouping.Group(input); Assert.AreEqual(5, result.Count); AssertSegment(result[0], new[] { "A", "B" }); Assert.IsTrue(result[1].IsAuto); AssertSegment(result[2], new[] { "C", "D" }); Assert.IsTrue(result[3].IsRand); AssertSegment(result[4], new[] { "E" }); }
/// <param name="firstWaypointIndex">Use a negative value if the /// first waypoint is a lat/lon.</param> /// <exception cref="ArgumentException"></exception> public BasicRouteAnalyzer(RouteString routeInput, WaypointList wptList, int firstWaypointIndex) { if (routeInput.Count == 0) { throw new ArgumentException("Route input should have at least 1 elements."); } this.wptList = wptList; rte = new Route(); this.routeInput = routeInput; ValidateFirstWpt(firstWaypointIndex); }
public StarExtractor( RouteString route, string rwy, Waypoint rwyWpt, WaypointList wptList, StarCollection stars) { this.route = new LinkedList <string>(route); this.rwy = rwy; this.rwyWpt = rwyWpt; this.wptList = wptList; this.stars = stars; }
private RouteString RemoveIcaos(RouteString route) { bool firstIsIcao = route[0] == origIcao; bool lastIsIcao = route.Last() == destIcao; int skipHead = firstIsIcao ? 1 : 0; int skipTail = lastIsIcao ? 1 : 0; return(route .Skip(skipHead) .Take(route.Count - skipHead - skipTail) .ToRouteString()); }
public SidExtractor( RouteString route, string rwy, Waypoint rwyWpt, WaypointList wptList, SidCollection sids) { this.route = new LinkedList <string>(route); this.rwy = rwy; this.rwyWpt = rwyWpt; this.wptList = wptList; this.sids = sids; }
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 AusTrack( string Ident, string TimeStart, string TimeEnd, string Remarks, RouteString MainRoute, IReadOnlyList <RouteString> RouteFrom, IReadOnlyList <RouteString> RouteTo, ICoordinate PreferredFirstLatLon, ICoordinate PreferredLastLatLon) : base(Ident, TimeStart, TimeEnd, Remarks, MainRoute, RouteFrom, RouteTo, PreferredFirstLatLon, PreferredFirstLatLon) { }
private static void EnsureNoConsectiveCommands(RouteString route) { string[] commands = { "AUTO", "RAND" }; for (int i = 0; i < route.Count - 1; i++) { var first = route[i]; var second = route[i + 1]; if (commands.Contains(first) && commands.Contains(second)) { throw new ArgumentException($"{first} cannot be followed by {second}"); } } }
public static IReadOnlyList <RouteSegment> Group(RouteString route) { var result = new List <RouteSegment>(); var queue = new Queue <string>(route); while (queue.Count > 0) { var seg = GetNextSegment(queue); if (seg.IsAuto || seg.IsRand || seg.RouteString.Count > 0) { result.Add(seg); } } return(result); }
public NorthAtlanticTrack( NatsDirection Direction, string Ident, string TimeStart, string TimeEnd, string Remarks, RouteString MainRoute) : base(Ident, TimeStart, TimeEnd, Remarks, MainRoute, EmpRouteStrings, EmpRouteStrings, Constants.CenterAtlantic, Constants.CenterAtlantic) { this.Direction = Direction; }
// May throw exception. public Route Analyze() { SetRwyWpts(); if (route.Count == 0) { return(DirectRoute()); } EnsureNoConsectiveCommands(route); route = RemoveIcaos(route); IdentifyLatLon(); var subRoutes = EntryGrouping.Group(new RouteString(route)); var analyzed = TransformSubRoutes(subRoutes); var final = ComputeCommands(analyzed); editor.Undo(); return(final.Connect()); }
public void AddsMainRouteCorrectly() { // Arrange var p1 = new Waypoint("P1", 0.0, 0.0); var p2 = new Waypoint("P2", 5.0, 5.0); var wptList = new WaypointList(); wptList.AddWaypoint(p1); wptList.AddWaypoint(p2); var reader = new TrackReader <PacificTrack>( wptList, new AirportManager()); // Act var nodes = reader.Read( new PacificTrack( PacotDirection.Westbound, "A", "", "", "", RouteString.From("P1", "P2"), new[] { RouteString.Empty }, new[] { RouteString.Empty }, new LatLon(0.0, 0.0), new LatLon(0.0, 0.0))); // Assert var route = nodes.MainRoute; Assert.AreEqual(2, route.Count); var n = route.First.Value; Assert.IsTrue(n.Waypoint.Equals(p1)); Assert.IsTrue(n.Neighbor.Airway == "DCT" && n.Neighbor.Distance == p1.Distance(p2)); Assert.IsTrue(route.LastWaypoint.Equals(p2)); }
public Track( string Ident, string TimeStart, string TimeEnd, string Remarks, RouteString MainRoute, IReadOnlyList <RouteString> RouteFrom, IReadOnlyList <RouteString> RouteTo, ICoordinate PreferredFirstLatLon, ICoordinate PreferredLastLatLon) { this.Ident = Ident; this.TimeStart = TimeStart; this.TimeEnd = TimeEnd; this.Remarks = Remarks; this.MainRoute = MainRoute; this.RouteFrom = RouteFrom; this.RouteTo = RouteTo; this.PreferredFirstLatLon = PreferredFirstLatLon; this.PreferredLastLatLon = PreferredLastLatLon; }
public AnalyzerWithCommands( RouteString route, string origIcao, string origRwy, string destIcao, string destRwy, AirportManager airportList, WaypointList wptList, WaypointListEditor editor, SidCollection sids, StarCollection stars) { this.route = route; this.origIcao = origIcao; this.origRwy = origRwy; this.destIcao = destIcao; this.destRwy = destRwy; this.airportList = airportList; this.wptList = wptList; this.editor = editor; this.sids = sids; this.stars = stars; }
public PacificTrack( PacotDirection Direction, string Ident, string TimeStart, string TimeEnd, string Remarks, RouteString MainRoute, IReadOnlyList <RouteString> RouteFrom, IReadOnlyList <RouteString> RouteTo, ICoordinate PreferredFirstLatLon, ICoordinate PreferredLastLatLon) : base( Ident, TimeStart, TimeEnd, Remarks, MainRoute, RouteFrom, RouteTo, PreferredFirstLatLon, PreferredLastLatLon) { this.Direction = Direction; }
public ExtractResult(RouteString RemainingRoute, Route OrigRoute) { this.RemainingRoute = RemainingRoute; this.OrigRoute = OrigRoute; }
private async void FindRoute() { if (FromAddressessSearch.SelectedLocation == null || ToAddressessSearch.SelectedLocation == null) { return; } FavVM.MainVM.Loading = true; RouteInstrucions = new StepModel[] { new StepModel() { Description = "WCZYTYWANIE..." } }; var rm = await Client.GetRoute(FromAddressessSearch.SelectedLocation.Address, ToAddressessSearch.SelectedLocation.Address); if (rm != null) { RouteString[] ri = new RouteString[rm.Steps.Length]; MainMap.PolylineLocations = new LocationCollection(); for (int i = 0; i < rm.Steps.Length; i++) { ri[i] = new RouteString(rm.Steps[i].Description); var polyLineLocations = new Decoder().Decode(rm.Steps[i].Polyline); foreach (var geoCoordinate in polyLineLocations) { MainMap.PolylineLocations.Add(new Location(geoCoordinate.Latitude, geoCoordinate.Longitude)); } } MainMap.Center = MainMap.PolylineLocations[MainMap.PolylineLocations.Count() / 2]; if (rm.Distance > 10000000) { MainMap.ZoomLevel = 1; } else if (rm.Distance > 8000000) { MainMap.ZoomLevel = 2; } else if (rm.Distance > 4000000) { MainMap.ZoomLevel = 3; } else if (rm.Distance > 2000000) { MainMap.ZoomLevel = 4; } else if (rm.Distance > 1000000) { MainMap.ZoomLevel = 5; } else if (rm.Distance > 500000) { MainMap.ZoomLevel = 6; } else if (rm.Distance > 200000) { MainMap.ZoomLevel = 7; } else if (rm.Distance > 80000) { MainMap.ZoomLevel = 8; } else if (rm.Distance > 50000) { MainMap.ZoomLevel = 9; } else if (rm.Distance > 25000) { MainMap.ZoomLevel = 10; } else if (rm.Distance > 10000) { MainMap.ZoomLevel = 11; } else if (rm.Distance > 7000) { MainMap.ZoomLevel = 12; } else if (rm.Distance > 4000) { MainMap.ZoomLevel = 13; } else if (rm.Distance > 2000) { MainMap.ZoomLevel = 14; } else if (rm.Distance > 1000) { MainMap.ZoomLevel = 15; } else if (rm.Distance > 500) { MainMap.ZoomLevel = 16; } else if (rm.Distance > 100) { MainMap.ZoomLevel = 17; } else if (rm.Distance > 50) { MainMap.ZoomLevel = 19; } else { MainMap.ZoomLevel = 20; } RouteInstrucions = rm.Steps; } else { RouteInstrucions = new StepModel[] { new StepModel() { Description = "Nie znaleziono trasy dla podanych adresów." } }; } FavVM.MainVM.Loading = false; }
private Route GetBasicRoute(RouteString r, int firstWptIndex) { var analyzer = new BasicRouteAnalyzer(r, wptList, firstWptIndex); return(analyzer.Analyze()); }
public RouteSegment(RouteString RouteString) : this(false, false, RouteString) { }
private Route GetAutoSelectRoute(RouteString r) { var analyzer = new AutoSelectAnalyzer(r, origRwyWpt, destRwyWpt, wptList); return(analyzer.Analyze()); }
private RouteSegment(bool IsAuto, bool IsRand, RouteString RouteString) { this.IsAuto = IsAuto; this.IsRand = IsRand; this.RouteString = RouteString; }
public ExtractResult(RouteString RemainingRoute, Route DestRoute) { this.RemainingRoute = RemainingRoute; this.DestRoute = DestRoute; }