コード例 #1
0
        // chs, 2011-17-11 changed for showing departures and arrivals from one airport to another
        //returns the list of arrivals or departures from one airport to another
        public static List <RouteTimeTableEntry> GetAirportFlights(Airport fAirport, Airport tAirport, Boolean arrivals)
        {
            List <RouteTimeTableEntry> entries = new List <RouteTimeTableEntry>();

            foreach (Route route in AirportHelpers.GetAirportRoutes(fAirport))
            {
                if (route.HasAirliner && (route.Destination1 == tAirport || route.Destination2 == tAirport))
                {
                    RouteTimeTableEntry entry = route.getCurrentAirliner() == null || route.getCurrentAirliner().CurrentFlight == null || route.getCurrentAirliner().CurrentFlight.Entry == null?route.TimeTable.getNextEntry(GameObject.GetInstance().GameTime) : route.getCurrentAirliner().CurrentFlight.Entry;

                    for (int i = 0; i < route.TimeTable.Entries.Count; i++)
                    {
                        if (!arrivals && entry.Destination.Airport == tAirport)
                        {
                            entries.Add(entry);
                        }

                        if (arrivals && entry.Destination.Airport == fAirport)
                        {
                            entries.Add(entry);
                        }

                        entry = route.TimeTable.getNextEntry(entry);
                    }
                }
            }
            entries.Sort(delegate(RouteTimeTableEntry e1, RouteTimeTableEntry e2) { return(MathHelpers.ConvertEntryToDate(e1).CompareTo(MathHelpers.ConvertEntryToDate(e2))); });
            return(entries);
        }
コード例 #2
0
        //returns the list of destinations for the airport
        private Dictionary <Airport, int> getDestinations()
        {
            Dictionary <Airport, int> destinations = new Dictionary <Airport, int>();

            foreach (Route route in AirportHelpers.GetAirportRoutes(this.Airport).FindAll(r => r.getAirliners().Count > 0))
            {
                if (route.Destination1 != this.Airport)
                {
                    if (!destinations.ContainsKey(route.Destination1))
                    {
                        destinations.Add(route.Destination1, 0);
                    }
                    destinations[route.Destination1] += route.TimeTable.getEntries(route.Destination1).Count;
                }
                if (route.Destination2 != this.Airport)
                {
                    if (!destinations.ContainsKey(route.Destination2))
                    {
                        destinations.Add(route.Destination2, 0);
                    }
                    destinations[route.Destination2] += route.TimeTable.getEntries(route.Destination2).Count;
                }
            }
            return(destinations);
        }
コード例 #3
0
        public static List <RouteTimeTableEntry> GetAirportDepartures(Airport airport, int count)
        {
            List <RouteTimeTableEntry> entries = new List <RouteTimeTableEntry>();

            foreach (Route route in AirportHelpers.GetAirportRoutes(airport))
            {
                if (route.HasAirliner && route.getCurrentAirliner() != null)
                {
                    RouteTimeTableEntry entry = route.getCurrentAirliner().CurrentFlight == null?route.TimeTable.getNextEntry(GameObject.GetInstance().GameTime, airport) : route.getCurrentAirliner().CurrentFlight.Entry;

                    if (!entry.Destination.Airport.Profile.Coordinates.Equals(airport.Profile.Coordinates))
                    {
                        entries.Add(entry);
                    }

                    while (entries.Count < 4)
                    {
                        entry = route.TimeTable.getNextEntry(entry);
                        if (entry.Destination.Airport != airport)
                        {
                            entries.Add(entry);
                        }
                    }
                }
            }
            entries.Sort(delegate(RouteTimeTableEntry e1, RouteTimeTableEntry e2) { return(MathHelpers.ConvertEntryToDate(e1).CompareTo(MathHelpers.ConvertEntryToDate(e2))); });
            return(entries.GetRange(0, Math.Min(entries.Count, count)));
        }
コード例 #4
0
 public void addAirlineContract(AirportContract contract)
 {
     this.Airport.addAirlineContract(contract);
     this.IsHuman           = GameObject.GetInstance().HumanAirline.Airports.Contains(this.Airport);
     this.NumberOfFreeGates = this.Airport.Terminals.NumberOfFreeGates;
     this.NumberOfAirlines  = this.Airport.AirlineContracts.Select(c => c.Airline).Distinct().Count();
     this.NumberOfRoutes    = AirportHelpers.GetAirportRoutes(this.Airport).Count;
 }
コード例 #5
0
ファイル: AirportsMVVM.cs プロジェクト: petfol/tap-desktop
 public AirportMVVM(Airport airport)
 {
     this.Airport           = airport;
     this.IsHuman           = GameObject.GetInstance().HumanAirline.Airports.Contains(this.Airport);
     this.NumberOfFreeGates = this.Airport.Terminals.NumberOfFreeGates;
     this.NumberOfAirlines  = this.Airport.AirlineContracts.Select(c => c.Airline).Distinct().Count();
     this.NumberOfRoutes    = AirportHelpers.GetAirportRoutes(this.Airport).Count;
     this.LongestRunway     = this.Airport.Runways.Count == 0 ? 0 : this.Airport.Runways.Max(r => r.Length);
 }
コード例 #6
0
 /// <summary>
 /// Returns the distance between two airports
 /// </summary>
 /// <param name="o">Start airport</param>
 /// <param name="d">Destination airport</param>
 /// <returns></returns>
 private double getDistanceBetween(Airport o, Airport d)
 {
     if (AirportHelpers.GetAirportRoutes(o).Find(r => r.Destination1 == d || r.Destination2 == d) != null)
     {
         return(1);
     }
     else
     {
         return(0);
     }
 }
コード例 #7
0
        /// <summary>
        /// Returns all airports with a route from the an airport
        /// </summary>
        /// <param name="n">Airport</param>
        /// <returns></returns>
        private List <Airport> getNeighbors(Airport n)
        {
            List <Airport> neighbors = new List <Airport>();

            foreach (Route route in AirportHelpers.GetAirportRoutes(n))
            {
                Airport destination = route.Destination1 == n ? route.Destination2 : route.Destination1;
                if (this.Basis.Contains(n))
                {
                    neighbors.Add(destination);
                }
            }

            return(neighbors);
        }
コード例 #8
0
        //returns the list of arrivals for an airport
        public static List <RouteTimeTableEntry> GetAirportArrivals(Airport airport, DayOfWeek day)
        {
            List <RouteTimeTableEntry> entries = new List <RouteTimeTableEntry>();

            foreach (Route route in AirportHelpers.GetAirportRoutes(airport))
            {
                if (route.HasAirliner)
                {
                    var rEntries = route.TimeTable.Entries.Where(e => e.Day == day && e.Destination.Airport == airport);

                    entries.AddRange(rEntries);
                }
            }
            entries.Sort(delegate(RouteTimeTableEntry e1, RouteTimeTableEntry e2) { return(MathHelpers.ConvertEntryToDate(e1).CompareTo(MathHelpers.ConvertEntryToDate(e2))); });
            return(entries);
        }
コード例 #9
0
        //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);
                }
            }
        }
コード例 #10
0
        public static List <RouteTimeTableEntry> GetAirportArrivals(Airport airport, int count)
        {
            List <RouteTimeTableEntry> entries = new List <RouteTimeTableEntry>();

            foreach (Route route in AirportHelpers.GetAirportRoutes(airport))
            {
                if (route.HasAirliner && route.getCurrentAirliner() != null)
                {
                    RouteTimeTableEntry entry = route.getCurrentAirliner().CurrentFlight == null?route.TimeTable.getNextEntry(GameObject.GetInstance().GameTime, (airport == route.Destination1 ? route.Destination2 : route.Destination1)) : route.getCurrentAirliner().CurrentFlight.Entry;

                    for (int i = 0; i < route.TimeTable.Entries.Count; i++)
                    {
                        if (entry.Destination.Airport == airport)
                        {
                            entries.Add(entry);
                        }
                        entry = route.TimeTable.getNextEntry(entry);
                    }
                }
            }
            entries.Sort(delegate(RouteTimeTableEntry e1, RouteTimeTableEntry e2) { return(MathHelpers.ConvertEntryToDate(e1).CompareTo(MathHelpers.ConvertEntryToDate(e2))); });
            return(entries.GetRange(0, Math.Min(entries.Count, count)));
        }
コード例 #11
0
 public CompareAirportMVVM(Airport airport)
 {
     this.Airport         = airport;
     this.Routes          = AirportHelpers.GetAirportRoutes(this.Airport).Count;
     this.ServingAirlines = this.Airport.AirlineContracts.Select(c => c.Airline).Distinct().Count();
 }
コード例 #12
0
        public AirportMVVM(Airport airport)
        {
            this.Airport = airport;

            this.TerminalGatePrice = this.Airport.getTerminalGatePrice();
            this.TerminalPrice     = this.Airport.getTerminalPrice();

            this.Terminals = new ObservableCollection <AirportTerminalMVVM>();

            foreach (Terminal terminal in this.Airport.Terminals.getTerminals())
            {
                Boolean isSellable = terminal.Airline != null && terminal.Airline == GameObject.GetInstance().HumanAirline;

                this.Terminals.Add(new AirportTerminalMVVM(terminal, terminal.IsBuyable, isSellable));
            }
            this.Contracts = new ObservableCollection <ContractMVVM>();

            foreach (AirportContract contract in this.Airport.AirlineContracts)
            {
                this.Contracts.Add(new ContractMVVM(contract));
            }

            AirportHelpers.CreateAirportWeather(this.Airport);

            this.Weather = this.Airport.Weather.ToList();

            if (!GameObject.GetInstance().DayRoundEnabled)
            {
                this.CurrentWeather = this.Weather[0].Temperatures[GameObject.GetInstance().GameTime.Hour];
            }

            this.FreeGates = this.Airport.Terminals.NumberOfFreeGates;

            this.Demands = new List <DemandMVVM>();

            foreach (Airport destination in this.Airport.getDestinationDemands().Where(a => a != null && GeneralHelpers.IsAirportActive(a)))
            {
                this.Demands.Add(new DemandMVVM(destination, (int)this.Airport.getDestinationPassengersRate(destination, AirlinerClass.ClassType.Economy_Class), (int)this.Airport.getDestinationCargoRate(destination), new CountryCurrentCountryConverter().Convert(destination.Profile.Country) == new CountryCurrentCountryConverter().Convert(this.Airport.Profile.Country) ? DemandMVVM.DestinationType.Domestic : DemandMVVM.DestinationType.International));
            }

            this.AirportFacilities = this.Airport.getAirportFacilities().FindAll(f => f.Airline == null).Select(f => f.Facility).ToList();

            this.AirlineFacilities = new ObservableCollection <AirlineAirportFacilityMVVM>();

            foreach (var facility in this.Airport.getAirportFacilities().FindAll(f => f.Airline != null))
            {
                if (facility.Facility.TypeLevel != 0)
                {
                    Alliance alliance = facility.Airline.Alliances.Count == 0 ? null : facility.Airline.Alliances[0];

                    this.AirlineFacilities.Add(new AirlineAirportFacilityMVVM(facility, alliance));
                }
            }

            this.AirlineStatistics = new List <AirportStatisticsMVMM>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                StatisticsType passengersType    = StatisticsTypes.GetStatisticsType("Passengers");
                StatisticsType passengersAvgType = StatisticsTypes.GetStatisticsType("Passengers%");
                StatisticsType arrivalsType      = StatisticsTypes.GetStatisticsType("Arrivals");

                double passengers    = this.Airport.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, airline, passengersType);
                double passengersAvg = this.Airport.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, airline, passengersAvgType);
                double arrivals      = this.Airport.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, airline, arrivalsType);

                this.AirlineStatistics.Add(new AirportStatisticsMVMM(airline, passengers, passengersAvg, arrivals));
            }

            this.Traffic = new List <AirportTrafficMVVM>();

            var passengerDestinations = from a in Airports.GetAllActiveAirports() orderby this.Airport.getDestinationPassengerStatistics(a) descending select a;

            var cargoDestinations = from a in Airports.GetAllActiveAirports() orderby this.Airport.getDestinationCargoStatistics(a) descending select a;

            foreach (Airport a in passengerDestinations.Take(20))
            {
                this.Traffic.Add(new AirportTrafficMVVM(a, this.Airport.getDestinationPassengerStatistics(a), AirportTrafficMVVM.TrafficType.Passengers));
            }

            foreach (Airport a in cargoDestinations.Take(20))
            {
                this.Traffic.Add(new AirportTrafficMVVM(a, Convert.ToInt64(this.Airport.getDestinationCargoStatistics(a)), AirportTrafficMVVM.TrafficType.Cargo));
            }

            this.Flights = new List <DestinationFlightsMVVM>();

            Dictionary <Airport, int> destinations = new Dictionary <Airport, int>();

            foreach (Route route in AirportHelpers.GetAirportRoutes(this.Airport).FindAll(r => r.getAirliners().Count > 0))
            {
                if (route.Destination1 != this.Airport)
                {
                    if (!destinations.ContainsKey(route.Destination1))
                    {
                        destinations.Add(route.Destination1, 0);
                    }
                    destinations[route.Destination1] += route.TimeTable.getEntries(route.Destination1).Count;
                }
                if (route.Destination2 != this.Airport)
                {
                    if (!destinations.ContainsKey(route.Destination2))
                    {
                        destinations.Add(route.Destination2, 0);
                    }
                    destinations[route.Destination2] += route.TimeTable.getEntries(route.Destination2).Count;
                }
            }

            foreach (Airport a in destinations.Keys)
            {
                this.Flights.Add(new DestinationFlightsMVVM(a, destinations[a]));
            }

            this.Hubs = new ObservableCollection <Hub>();

            foreach (Hub hub in this.Airport.getHubs())
            {
                this.Hubs.Add(hub);
            }

            this.CanBuildHub = canBuildHub();

            this.LocalTime = MathHelpers.ConvertDateTimeToLoalTime(GameObject.GetInstance().GameTime, this.Airport.Profile.TimeZone);

            this.ShowLocalTime = !GameObject.GetInstance().DayRoundEnabled;
        }
コード例 #13
0
        public PageAirportFlights(Airport airport)
        {
            InitializeComponent();

            this.Airport = airport;

            StackPanel panelFlights = new StackPanel();

            panelFlights.Margin = new Thickness(0, 10, 50, 0);

            ContentControl ccHeader = new ContentControl();

            ccHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            ccHeader.ContentTemplate     = this.Resources["DestinationsHeader"] as DataTemplate;
            panelFlights.Children.Add(ccHeader);

            /*
             * TextBlock txtHeader = new TextBlock();
             * txtHeader.Uid = "1001";
             * txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
             * txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
             * txtHeader.FontWeight = FontWeights.Bold;
             * txtHeader.Text = Translator.GetInstance().GetString("PageAirportFlights", txtHeader.Uid);
             *
             * panelFlights.Children.Add(txtHeader);
             */

            lbStatistics = new ListBox();
            lbStatistics.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbStatistics.ItemTemplate = this.Resources["DestinationItem"] as DataTemplate;
            lbStatistics.MaxHeight    = (GraphicsHelpers.GetContentHeight() - 100) / 2;

            var items = new List <DestinationFlights>();

            foreach (Airport a in getDestinations().Keys)
            {
                items.Add(new DestinationFlights(a, getDestinations()[a]));
            }

            items.OrderBy(i => i.Airport.Profile.Name);

            lbStatistics.ItemsSource = items;

            panelFlights.Children.Add(lbStatistics);

            //panelFlights.Children.Add(createDestinationFlightsPanel());

            WrapPanel panelButtons = new WrapPanel();

            panelButtons.Margin = new Thickness(0, 5, 0, 0);

            Button btnSlotAllocation = new Button();

            btnSlotAllocation.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnSlotAllocation.Height  = Double.NaN;
            btnSlotAllocation.Width   = Double.NaN;
            btnSlotAllocation.Uid     = "200";
            btnSlotAllocation.Content = Translator.GetInstance().GetString("PageAirportFlights", btnSlotAllocation.Uid);
            btnSlotAllocation.Click  += new RoutedEventHandler(btnSlotAllocation_Click);
            btnSlotAllocation.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            btnSlotAllocation.Visibility = AirportHelpers.GetAirportRoutes(this.Airport).Count > 0 ? Visibility.Visible : Visibility.Collapsed;

            panelButtons.Children.Add(btnSlotAllocation);

            Button btnFlightMap = new Button();

            btnFlightMap.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnFlightMap.Height  = Double.NaN;
            btnFlightMap.Width   = Double.NaN;
            btnFlightMap.Uid     = "201";
            btnFlightMap.Content = Translator.GetInstance().GetString("PageAirportFlights", btnFlightMap.Uid);
            btnFlightMap.Click  += btnFlightMap_Click;
            btnFlightMap.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            btnFlightMap.Margin     = new Thickness(5, 0, 0, 0);
            btnFlightMap.Visibility = AirportHelpers.GetAirportRoutes(this.Airport).Count > 0 ? Visibility.Visible : System.Windows.Visibility.Collapsed;

            panelButtons.Children.Add(btnFlightMap);

            panelFlights.Children.Add(panelButtons);
            panelFlights.Children.Add(createFlightsPanel());

            this.Content = panelFlights;
        }
コード例 #14
0
 private void btnFlightMap_Click(object sender, RoutedEventArgs e)
 {
     PopUpMap.ShowPopUp(AirportHelpers.GetAirportRoutes(this.Airport));
 }
コード例 #15
0
        public AirportMVVM(Airport airport)
        {
            this.Airport = airport;

            this.TerminalGatePrice = this.Airport.getTerminalGatePrice();
            this.TerminalPrice     = this.Airport.getTerminalPrice();

            this.Cooperations      = new ObservableCollection <Cooperation>();
            this.Terminals         = new ObservableCollection <AirportTerminalMVVM>();
            this.BuildingTerminals = new ObservableCollection <AirportTerminalMVVM>();

            foreach (Terminal terminal in this.Airport.Terminals.getTerminals())
            {
                Boolean isSellable = terminal.Airline != null && terminal.Airline == GameObject.GetInstance().HumanAirline;

                if (terminal.IsBuilt)
                {
                    this.Terminals.Add(new AirportTerminalMVVM(terminal, terminal.IsBuyable, isSellable));
                }
                else
                {
                    this.BuildingTerminals.Add(new AirportTerminalMVVM(terminal, terminal.IsBuyable, isSellable));
                }
            }
            this.Contracts = new ObservableCollection <ContractMVVM>();

            foreach (AirportContract contract in this.Airport.AirlineContracts)
            {
                this.Contracts.Add(new ContractMVVM(contract));
            }

            foreach (Cooperation cooperation in this.Airport.Cooperations)
            {
                this.Cooperations.Add(cooperation);
            }

            AirportHelpers.CreateAirportWeather(this.Airport);

            this.Weather = this.Airport.Weather.ToList();

            if (!GameObject.GetInstance().DayRoundEnabled)
            {
                this.CurrentWeather = this.Weather[0].Temperatures[GameObject.GetInstance().GameTime.Hour];
            }

            this.FreeGates = this.Airport.Terminals.NumberOfFreeGates;

            this.Demands = new List <DemandMVVM>();

            var demands = this.Airport.getDestinationDemands().Where(a => a != null && GeneralHelpers.IsAirportActive(a)).OrderByDescending(a => this.Airport.getDestinationPassengersRate(a, AirlinerClass.ClassType.Economy_Class));

            var internationalDemand = demands.Where(a => new CountryCurrentCountryConverter().Convert(a.Profile.Country) != new CountryCurrentCountryConverter().Convert(this.Airport.Profile.Country));
            var domesticDemand      = demands.Where(a => new CountryCurrentCountryConverter().Convert(a.Profile.Country) == new CountryCurrentCountryConverter().Convert(this.Airport.Profile.Country));

            foreach (Airport destination in internationalDemand)
            {
                this.Demands.Add(new DemandMVVM(destination, (int)this.Airport.getDestinationPassengersRate(destination, AirlinerClass.ClassType.Economy_Class), (int)this.Airport.Profile.Pax, (int)this.Airport.getDestinationCargoRate(destination), DemandMVVM.DestinationType.International));
            }

            foreach (Airport destination in domesticDemand)
            {
                this.Demands.Add(new DemandMVVM(destination, (int)this.Airport.getDestinationPassengersRate(destination, AirlinerClass.ClassType.Economy_Class), (int)this.Airport.Profile.Pax, (int)this.Airport.getDestinationCargoRate(destination), DemandMVVM.DestinationType.Domestic));
            }

            this.AirportFacilities = this.Airport.getAirportFacilities().FindAll(f => f.Airline == null && f.Facility.TypeLevel != 0).Select(f => f.Facility).Distinct().ToList();

            this.AirlineFacilities         = new ObservableCollection <AirlineAirportFacilityMVVM>();
            this.BuildingAirlineFacilities = new ObservableCollection <AirlineAirportFacilityMVVM>();

            foreach (var facility in this.Airport.getAirportFacilities().FindAll(f => f.Airline != null))
            {
                if (facility.Facility.TypeLevel != 0)
                {
                    Alliance alliance = facility.Airline.Alliances.Count == 0 ? null : facility.Airline.Alliances[0];

                    AirlineAirportFacilityMVVM airlineFacility = new AirlineAirportFacilityMVVM(facility, alliance);

                    if (airlineFacility.IsDelivered)
                    {
                        if (facility == Airport.getAirlineAirportFacility(facility.Airline, facility.Facility.Type))
                        {
                            this.AirlineFacilities.Add(airlineFacility);
                        }
                    }
                    else
                    {
                        this.BuildingAirlineFacilities.Add(airlineFacility);
                    }
                }
            }

            this.AirlineStatistics = new List <AirportStatisticsMVMM>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                StatisticsType passengersType    = StatisticsTypes.GetStatisticsType("Passengers");
                StatisticsType passengersAvgType = StatisticsTypes.GetStatisticsType("Passengers%");
                StatisticsType arrivalsType      = StatisticsTypes.GetStatisticsType("Arrivals");

                double passengers    = this.Airport.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, airline, passengersType);
                double passengersAvg = this.Airport.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, airline, passengersAvgType);
                double arrivals      = this.Airport.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, airline, arrivalsType);

                int routes = airline.Routes.Count(r => r.Destination1 == this.Airport || r.Destination2 == this.Airport);

                this.AirlineStatistics.Add(new AirportStatisticsMVMM(airline, passengers, passengersAvg, arrivals, routes));
            }

            this.Traffic = new List <AirportTrafficMVVM>();

            var passengerDestinations = from a in Airports.GetAllActiveAirports() orderby this.Airport.getDestinationPassengerStatistics(a) descending select a;

            var cargoDestinations = from a in Airports.GetAllActiveAirports() orderby this.Airport.getDestinationCargoStatistics(a) descending select a;

            foreach (Airport a in passengerDestinations.Take(20))
            {
                this.Traffic.Add(new AirportTrafficMVVM(a, this.Airport.getDestinationPassengerStatistics(a), AirportTrafficMVVM.TrafficType.Passengers));
            }

            foreach (Airport a in cargoDestinations.Take(20))
            {
                this.Traffic.Add(new AirportTrafficMVVM(a, Convert.ToInt64(this.Airport.getDestinationCargoStatistics(a)), AirportTrafficMVVM.TrafficType.Cargo));
            }

            this.Flights = new List <DestinationFlightsMVVM>();

            var airportRoutes = AirportHelpers.GetAirportRoutes(this.Airport).Where(r => r.getAirliners().Count > 0);

            foreach (Route airportRoute in airportRoutes)
            {
                double distance = MathHelpers.GetDistance(airportRoute.Destination1, airportRoute.Destination2);

                Airport destination = airportRoute.Destination1 == this.Airport ? airportRoute.Destination2 : airportRoute.Destination1;
                if (this.Flights.Exists(f => f.Airline == airportRoute.Airline && f.Airport == destination))
                {
                    DestinationFlightsMVVM flight = this.Flights.First(f => f.Airline == airportRoute.Airline && f.Airport == destination);

                    flight.Flights += airportRoute.TimeTable.getEntries(destination).Count;

                    foreach (AirlinerType aircraft in airportRoute.getAirliners().Select(a => a.Airliner.Type))
                    {
                        if (!flight.Aircrafts.Contains(aircraft))
                        {
                            flight.Aircrafts.Add(aircraft);
                        }
                    }
                }
                else
                {
                    this.Flights.Add(new DestinationFlightsMVVM(destination, airportRoute.Airline, distance, airportRoute.getAirliners().Select(a => a.Airliner.Type).ToList(), airportRoute.TimeTable.getEntries(destination).Count));
                }
            }

            /*
             * Dictionary<Airport, int> destinations = new Dictionary<Airport, int>();
             * foreach (Route route in AirportHelpers.GetAirportRoutes(this.Airport).FindAll(r => r.getAirliners().Count > 0))
             * {
             *  if (route.Destination1 != this.Airport)
             *  {
             *      if (!destinations.ContainsKey(route.Destination1))
             *          destinations.Add(route.Destination1, 0);
             *      destinations[route.Destination1] += route.TimeTable.getEntries(route.Destination1).Count;
             *
             *
             *  }
             *  if (route.Destination2 != this.Airport)
             *  {
             *      if (!destinations.ContainsKey(route.Destination2))
             *          destinations.Add(route.Destination2, 0);
             *      destinations[route.Destination2] += route.TimeTable.getEntries(route.Destination2).Count;
             *  }
             * }
             *
             * foreach (Airport a in destinations.Keys)
             *  this.Flights.Add(new DestinationFlightsMVVM(a, destinations[a]));
             */

            this.Hubs = new ObservableCollection <Hub>();

            foreach (Hub hub in this.Airport.getHubs())
            {
                this.Hubs.Add(hub);
            }

            this.CanBuildHub        = canBuildHub();
            this.CanMakeCooperation = GameObject.GetInstance().HumanAirline.Airports.Exists(a => a == this.Airport);

            this.LocalTime = MathHelpers.ConvertDateTimeToLoalTime(GameObject.GetInstance().GameTime, this.Airport.Profile.TimeZone);

            this.ShowLocalTime = !GameObject.GetInstance().DayRoundEnabled;

            this.AirlineReputations = new List <AirlineReputationMVVM>();

            IDictionary <Airline, double> airlineScores = new Dictionary <Airline, double>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                airlineScores.Add(airline, this.Airport.getAirlineReputation(airline));
            }

            foreach (KeyValuePair <Airline, double> score in StatisticsHelpers.GetRatingScale(airlineScores))
            {
                this.AirlineReputations.Add(new AirlineReputationMVVM(score.Key, (int)score.Value));
            }
        }