//shows the passengers private void showDemand() { lbPassengers.Items.Clear(); List<Airport> airports; if (domesticDemand) airports = Airports.GetAirports(a => a != this.Airport && a.Profile.Country == this.Airport.Profile.Country).OrderByDescending(a => this.Airport.getDestinationPassengersRate(a, AirlinerClass.ClassType.Economy_Class)).ToList(); else airports = Airports.GetAirports(a => a != this.Airport && a.Profile.Country != this.Airport.Profile.Country).OrderByDescending(a => this.Airport.getDestinationPassengersRate(a, AirlinerClass.ClassType.Economy_Class)).ToList(); foreach (Airport airport in airports) { int passengers = this.Airport.getDestinationPassengersRate(airport,AirlinerClass.ClassType.Economy_Class); int cargo = this.Airport.getDestinationCargoRate(airport); if (passengers > 0 || cargo > 0) { DestinationDemand passengerDemand = new DestinationDemand(airport.Profile.IATACode, (ushort)passengers); DestinationDemand cargoDemand = new DestinationDemand(airport.Profile.IATACode, (ushort)cargo); int demand = passengers; int covered = 0; List<Route> routes = AirportHelpers.GetAirportRoutes(airport, this.Airport).Where(r => r.Type == Route.RouteType.Mixed || r.Type == Route.RouteType.Passenger).ToList(); foreach (Route route in routes) { RouteAirlinerClass raClass = ((PassengerRoute)route).getRouteAirlinerClass(AirlinerClass.ClassType.Economy_Class); double avgPassengers = route.Statistics.getStatisticsValue(raClass, StatisticsTypes.GetStatisticsType("Passengers%")); double flights = route.TimeTable.Entries.Count; double routeCovered = avgPassengers / (7.0 / flights); covered += (int)routeCovered; } KeyValuePair<DestinationDemand, int> paxDemand = new KeyValuePair<DestinationDemand, int>(passengerDemand, Math.Max(0, demand - covered)); KeyValuePair<DestinationDemand, int> cDemand = new KeyValuePair<DestinationDemand, int>(cargoDemand, 0); KeyValuePair<KeyValuePair<DestinationDemand, int>, KeyValuePair<DestinationDemand, int>> totalDemand = new KeyValuePair<KeyValuePair<DestinationDemand, int>, KeyValuePair<DestinationDemand, int>>(paxDemand, cDemand); lbPassengers.Items.Add(totalDemand); } } }
//adds a passenger rate for a destination public void addDestinationPassengersRate(DestinationDemand passengers) { this.Statics.addPassengerDemand(passengers); }
//adds passenger demand to the airport public void addPassengerDemand(DestinationDemand demand) { lock (this.PassengerDemand) this.PassengerDemand.Add(demand); }
//adds a cargo rate for a destination public void addDestinationCargoRate(DestinationDemand cargo) { this.Statics.addCargoDemand(cargo); }
//adds cargo demand to the airport public void addCargoDemand(DestinationDemand demand) { lock (this.CargoDemand) this.CargoDemand.Add(demand); }