public AirportProfile( string name, string code, string icaocode, AirportType type, Period<DateTime> period, Town town, TimeSpan offsetGMT, TimeSpan offsetDST, Coordinates coordinates, GeneralHelpers.Size cargo, double cargovolume, Weather.Season season) { PaxValues = new List<PaxValue>(); Expansions = new List<AirportExpansion>(); Name = name; Period = period; IATACode = code; ICAOCode = icaocode; Type = type; Town = town; Coordinates = coordinates; CargoVolume = cargovolume; MajorDestionations = new Dictionary<string, int>(); Cargo = cargo; Logo = ""; OffsetDST = offsetDST; OffsetGMT = offsetGMT; Season = season; ID = $"{char.ConvertToUtf32(IATACode, 0):00}-{char.ConvertToUtf32(IATACode, 1):00}-{char.ConvertToUtf32(IATACode, 2):00}-{name.Length:00}-{char.ConvertToUtf32(Name, Name.Length/2):00}-{(int) Cargo:00}"; }
public PilotProfile(string firstname, string lastname, DateTime birthdate, Town town) { Firstname = firstname; Lastname = lastname; Town = town; Birthdate = birthdate; }
public WeatherAverage( int month, double temperatureMin, double temperatureMax, int precipitation, Weather.eWindSpeed windspeedMin, Weather.eWindSpeed windspeedMax, Town town) : this(month, temperatureMin, temperatureMax, precipitation, windspeedMin, windspeedMax, town.Country, town, null) { }
public WeatherAverage( int month, double temperatureMin, double temperatureMax, int precipitation, Weather.eWindSpeed windspeedMin, Weather.eWindSpeed windspeedMax, Country country, Town town, Airport airport) { Month = month; Airport = airport; Country = country; Town = town; TemperatureMin = temperatureMin; TemperatureMax = temperatureMax; WindSpeedMax = windspeedMax; WindSpeedMin = windspeedMin; Precipitation = precipitation; }
/*!loads the airliner images */ private static void LoadAirports(string filename) { string id = ""; try { var doc = new XmlDocument(); doc.Load(filename); XmlElement root = doc.DocumentElement; XmlNodeList airportsList = root?.SelectNodes("//airport"); if (airportsList != null) foreach (XmlElement airportElement in airportsList) { string name = airportElement.Attributes["name"].Value; string icao = airportElement.Attributes["icao"].Value; string iata = airportElement.Attributes["iata"].Value; id = name + " iata: " + iata; var type = (AirportProfile.AirportType) Enum.Parse(typeof (AirportProfile.AirportType), airportElement.Attributes["type"].Value); var season = (Weather.Season) Enum.Parse(typeof (Weather.Season), airportElement.Attributes["season"].Value); var periodElement = (XmlElement) airportElement.SelectSingleNode("period"); Period<DateTime> airportPeriod; if (periodElement != null) { DateTime airportFrom = Convert.ToDateTime( periodElement.Attributes["from"].Value, new CultureInfo("en-US", false)); DateTime airportTo = Convert.ToDateTime( periodElement.Attributes["to"].Value, new CultureInfo("en-US", false)); airportPeriod = new Period<DateTime>(airportFrom, airportTo); } else { airportPeriod = new Period<DateTime>(new DateTime(1959, 12, 31), new DateTime(2199, 12, 31)); } var townElement = (XmlElement) airportElement.SelectSingleNode("town"); string town = townElement.Attributes["town"].Value; string country = townElement.Attributes["country"].Value; TimeSpan gmt = TimeSpan.Parse(townElement.Attributes["GMT"].Value); TimeSpan dst = TimeSpan.Parse(townElement.Attributes["DST"].Value); var latitudeElement = (XmlElement) airportElement.SelectSingleNode("coordinates/latitude"); var longitudeElement = (XmlElement) airportElement.SelectSingleNode("coordinates/longitude"); string[] latitude = latitudeElement.Attributes["value"].Value.Split( new[] {'°', '\''}, StringSplitOptions.RemoveEmptyEntries); string[] longitude = longitudeElement.Attributes["value"].Value.Split( new[] {'°', '\''}, StringSplitOptions.RemoveEmptyEntries); var coords = new int[6]; //latitude coords[0] = int.Parse(latitude[0]); coords[1] = int.Parse(latitude[1]); coords[2] = int.Parse(latitude[2]); if (latitude[3] == "S") { coords[0] = -coords[0]; } //longitude coords[3] = int.Parse(longitude[0]); coords[4] = int.Parse(longitude[1]); coords[5] = int.Parse(longitude[2]); if (longitude[3] == "W") { coords[3] = -coords[3]; } /* foreach(string l in latitude ) { //int.TryParse(l, out coords[c]); coords[c] = int.Parse(l); c++; } c = 3; foreach (string l in longitude) { //int.TryParse(l, out coords[c]); coords[c] = int.Parse(l); c++; }*/ //cleaning up //GeoCoordinate pos = new GeoCoordinate(MathHelpers.DMStoDeg(coords[0], coords[1], coords[2]),MathHelpers.DMStoDeg(coords[3],coords[4],coords[5])); var pos = new Coordinates( new Coordinate(coords[0], coords[1], coords[2]), new Coordinate(coords[3], coords[4], coords[5])); //double longitude = Coordinate.Parse(longitudeElement.Attributes["value"].Value); var sizeElement = (XmlElement) airportElement.SelectSingleNode("size"); var paxValues = new List<PaxValue>(); if (!sizeElement.HasChildNodes) { var size = (GeneralHelpers.Size) Enum.Parse(typeof (GeneralHelpers.Size), sizeElement.Attributes["value"].Value); int pax = sizeElement.HasAttribute("pax") ? Convert.ToInt32(sizeElement.Attributes["pax"].Value) : 0; paxValues.Add(new PaxValue(airportPeriod.From.Year, airportPeriod.To.Year, size, pax)); } else { XmlNodeList yearsList = sizeElement.SelectNodes("yearvalues/yearvalue"); foreach (XmlElement yearElement in yearsList) { int fromYear = Convert.ToInt16(yearElement.Attributes["from"].Value); int toYear = Convert.ToInt16(yearElement.Attributes["to"].Value); var size = (GeneralHelpers.Size) Enum.Parse(typeof (GeneralHelpers.Size), yearElement.Attributes["value"].Value); int pax = Convert.ToInt32(yearElement.Attributes["pax"].Value); var paxValue = new PaxValue(fromYear, toYear, size, pax); if (yearElement.HasAttribute("inflationafter")) { paxValue.InflationAfterYear = Convert.ToDouble( yearElement.Attributes["inflationafter"].Value, CultureInfo.GetCultureInfo("en-US").NumberFormat); } if (yearElement.HasAttribute("inflationbefore")) { paxValue.InflationBeforeYear = Convert.ToDouble( yearElement.Attributes["inflationbefore"].Value, CultureInfo.GetCultureInfo("en-US").NumberFormat); } paxValues.Add(paxValue); } } GeneralHelpers.Size cargoSize; double cargovolume = sizeElement.HasAttribute("cargovolume") ? Convert.ToDouble( sizeElement.Attributes["cargovolume"].Value, CultureInfo.GetCultureInfo("en-US").NumberFormat) : 0; if (sizeElement.HasAttribute("cargo")) { cargoSize = (GeneralHelpers.Size) Enum.Parse(typeof (GeneralHelpers.Size), sizeElement.Attributes["cargo"].Value); } else { //calculates the cargo size var cargoSizes = (GeneralHelpers.Size[]) Enum.GetValues(typeof (GeneralHelpers.Size)); int i = 0; var list = new Dictionary<GeneralHelpers.Size, int>(); while (i < cargoSizes.Length && cargoSizes[i] <= paxValues.First().Size) { list.Add(cargoSizes[i], 10 - i); i++; } cargoSize = AIHelpers.GetRandomItem(list); } Town eTown; if (town.Contains(",")) { State state = States.GetState(Countries.GetCountry(country), town.Split(',')[1].Trim()); eTown = state == null ? new Town(town.Split(',')[0], Countries.GetCountry(country)) : new Town(town.Split(',')[0], Countries.GetCountry(country), state); } else { eTown = new Town(town, Countries.GetCountry(country)); } var profile = new AirportProfile( name, iata, icao, type, airportPeriod, eTown, gmt, dst, pos, cargoSize, cargovolume, season) {PaxValues = paxValues}; var airport = new Airport(profile); var destinationsElement = (XmlElement) airportElement.SelectSingleNode("destinations"); if (destinationsElement != null) { XmlNodeList majorDestinationsList = destinationsElement.SelectNodes("destination"); var majorDestinations = new Dictionary<string, int>(); foreach (XmlElement majorDestinationNode in majorDestinationsList) { string majorDestination = majorDestinationNode.Attributes["airport"].Value; int majorDestinationPax = Convert.ToInt32(majorDestinationNode.Attributes["pax"].Value); majorDestinations.Add(majorDestination, majorDestinationPax); } airport.Profile.MajorDestionations = majorDestinations; } XmlNodeList terminalList = airportElement.SelectNodes("terminals/terminal"); foreach (XmlElement terminalNode in terminalList) { string terminalName = terminalNode.Attributes["name"].Value; int terminalGates = XmlConvert.ToInt32(terminalNode.Attributes["gates"].Value); Terminal.TerminalType terminalType; if (terminalNode.HasAttribute("type")) terminalType = (Terminal.TerminalType) Enum.Parse(typeof (Terminal.TerminalType), terminalNode.Attributes["type"].Value); else terminalType = Terminal.TerminalType.Passenger; airport.Terminals.AddTerminal( new Terminal(airport, null, terminalName, terminalGates, new DateTime(1950, 1, 1), terminalType)); } XmlNodeList runwaysList = airportElement.SelectNodes("runways/runway"); foreach (XmlElement runwayNode in runwaysList) { string runwayName = runwayNode.Attributes["name"].Value; long runwayLength = XmlConvert.ToInt32(runwayNode.Attributes["length"].Value); var surface = (Runway.SurfaceType) Enum.Parse(typeof (Runway.SurfaceType), runwayNode.Attributes["surface"].Value); var runwayType = Runway.RunwayType.Regular; if (runwayNode.HasAttribute("type")) { runwayType = (Runway.RunwayType) Enum.Parse(typeof (Runway.RunwayType), runwayNode.Attributes["type"].Value); } airport.Runways.Add( new Runway(runwayName, runwayLength, runwayType, surface, new DateTime(1900, 1, 1), true)); } XmlNodeList expansionsList = airportElement.SelectNodes("expansions/expansion"); foreach (XmlElement expansionNode in expansionsList) { var expansionType = (AirportExpansion.ExpansionType) Enum.Parse(typeof (AirportExpansion.ExpansionType), expansionNode.Attributes["type"].Value); DateTime expansionDate = Convert.ToDateTime( expansionNode.Attributes["date"].Value, new CultureInfo("en-US", false)); bool expansionNotify = Convert.ToBoolean(expansionNode.Attributes["notify"].Value); var expansion = new AirportExpansion(expansionType, expansionDate, expansionNotify); if (expansionType == AirportExpansion.ExpansionType.Name) { string expansionName = expansionNode.Attributes["name"].Value; expansion.Name = expansionName; } if (expansionType == AirportExpansion.ExpansionType.RunwayLength) { string expansionName = expansionNode.Attributes["name"].Value; long length = Convert.ToInt64(expansionNode.Attributes["length"].Value); expansion.Name = expansionName; expansion.Length = length; } if (expansionType == AirportExpansion.ExpansionType.NewRunway) { string expansionName = expansionNode.Attributes["name"].Value; long length = Convert.ToInt64(expansionNode.Attributes["length"].Value); var surface = (Runway.SurfaceType) Enum.Parse(typeof (Runway.SurfaceType), expansionNode.Attributes["surface"].Value); expansion.Name = expansionName; expansion.Length = length; expansion.Surface = surface; } if (expansionType == AirportExpansion.ExpansionType.NewTerminal) { string expansionName = expansionNode.Attributes["name"].Value; int gates = Convert.ToInt16(expansionNode.Attributes["gates"].Value); Terminal.TerminalType terminalType; if (expansionNode.HasAttribute("terminaltype")) terminalType = (Terminal.TerminalType) Enum.Parse(typeof (Terminal.TerminalType), expansionNode.Attributes["terminaltype"].Value); else terminalType = Terminal.TerminalType.Passenger; expansion.Name = expansionName; expansion.Gates = gates; expansion.TerminalType = terminalType; } if (expansionType == AirportExpansion.ExpansionType.ExtraGates) { string expansionName = expansionNode.Attributes["name"].Value; int gates = Convert.ToInt16(expansionNode.Attributes["gates"].Value); expansion.Name = expansionName; expansion.Gates = gates; } if (expansionType == AirportExpansion.ExpansionType.CloseTerminal) { string expansionName = expansionNode.Attributes["name"].Value; int gates = Convert.ToInt16(expansionNode.Attributes["gates"].Value); expansion.Name = expansionName; expansion.Gates = gates; } airport.Profile.AddExpansion(expansion); } //30.06.14: Added for loading of landing fees double landingFee = airportElement.HasAttribute("landingfee") ? Convert.ToDouble(airportElement.Attributes["landingfee"].Value, new CultureInfo("en-US", false)) : AirportHelpers.GetStandardLandingFee(airport); airport.LandingFee = landingFee; if (Airports.GetAirport(a => a.Profile.ID == airport.Profile.ID) == null) { Airports.AddAirport(airport); } } } catch (Exception e) { /* System.IO.StreamWriter file = new System.IO.StreamWriter(AppSettings.getCommonApplicationDataPath() + "\\theairlinestartup.log", true); file.WriteLine("Airport failing: " + id); file.WriteLine(e.ToString()); file.WriteLine(e.StackTrace); file.Close(); * */ Logger.Error("Airport {0} failing to load", id); Logger.Error(e); } }