public PilotProfile(string firstname, string lastname, DateTime birthdate, Town town) { this.Firstname = firstname; this.Lastname = lastname; this.Town = town; this.Birthdate = birthdate; }
public WeatherAverage(int month, double temperatureMin, double temperatureMax,int precipitation, Weather.eWindSpeed windspeedMin, Weather.eWindSpeed windspeedMax, Country country, Town town,Airport airport) { this.Month = month; this.Airport = airport; this.Country = country; this.Town = town; this.TemperatureMin = temperatureMin; this.TemperatureMax = temperatureMax; this.WindSpeedMax = windspeedMax; this.WindSpeedMin = windspeedMin; this.Precipitation = precipitation; }
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) { this.PaxValues = new List<PaxValue>(); this.Name = name; this.Period = period; this.IATACode = code; this.ICAOCode = icaocode; this.Type = type; this.Town = town; this.Coordinates = coordinates; this.CargoVolume = cargovolume; this.MajorDestionations = new Dictionary<string, int>(); this.Cargo = cargo; this.Logo = ""; this.OffsetDST = offsetDST; this.OffsetGMT = offsetGMT; this.Season = season; this.ID = string.Format("{0:00}-{1:00}-{2:00}-{3:00}-{4:00}-{5:00}", char.ConvertToUtf32(this.IATACode, 0), char.ConvertToUtf32(this.IATACode, 1), char.ConvertToUtf32(this.IATACode, 2), name.Length, char.ConvertToUtf32(this.Name, this.Name.Length / 2), (int)this.Cargo); }
private static void LoadAirports(string filename) { string id = ""; try { XmlDocument doc = new XmlDocument(); doc.Load(filename); XmlElement root = doc.DocumentElement; XmlNodeList airportsList = root.SelectNodes("//airport"); 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; AirportProfile.AirportType type = (AirportProfile.AirportType)Enum.Parse(typeof(AirportProfile.AirportType), airportElement.Attributes["type"].Value); Weather.Season season = (Weather.Season)Enum.Parse(typeof(Weather.Season), airportElement.Attributes["season"].Value); XmlElement 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)); XmlElement 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); XmlElement latitudeElement = (XmlElement)airportElement.SelectSingleNode("coordinates/latitude"); XmlElement longitudeElement = (XmlElement)airportElement.SelectSingleNode("coordinates/longitude"); string[] latitude = latitudeElement.Attributes["value"].Value.Split(new Char[] { '°', '\'' }, StringSplitOptions.RemoveEmptyEntries); string[] longitude = longitude = longitudeElement.Attributes["value"].Value.Split(new Char[] { '°', '\'' }, StringSplitOptions.RemoveEmptyEntries); int[] 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 latitude = null; longitude = null; //GeoCoordinate pos = new GeoCoordinate(MathHelpers.DMStoDeg(coords[0], coords[1], coords[2]),MathHelpers.DMStoDeg(coords[3],coords[4],coords[5])); Coordinates 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); XmlElement sizeElement = (XmlElement)airportElement.SelectSingleNode("size"); List<PaxValue> paxValues = new List<PaxValue>(); if (!sizeElement.HasChildNodes) { GeneralHelpers.Size 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); GeneralHelpers.Size size = (GeneralHelpers.Size)Enum.Parse(typeof(GeneralHelpers.Size), yearElement.Attributes["value"].Value); int pax = Convert.ToInt32(yearElement.Attributes["pax"].Value); PaxValue 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 = GeneralHelpers.Size.Very_small; 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 GeneralHelpers.Size[] cargoSizes = (GeneralHelpers.Size[])Enum.GetValues(typeof(GeneralHelpers.Size)); int i=0; Dictionary<GeneralHelpers.Size,int> 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 = null; if (town.Contains(",")) { State state = States.GetState(Countries.GetCountry(country), town.Split(',')[1].Trim()); if (state == null) eTown = new Town(town.Split(',')[0], Countries.GetCountry(country)); else eTown = new Town(town.Split(',')[0], Countries.GetCountry(country), state); } else eTown = new Town(town, Countries.GetCountry(country)); AirportProfile profile = new AirportProfile(name, iata, icao, type, airportPeriod, eTown, gmt, dst, pos, cargoSize, cargovolume, season); profile.PaxValues = paxValues; Airport airport = new Airport(profile); XmlElement destinationsElement = (XmlElement)airportElement.SelectSingleNode("destinations"); if (destinationsElement != null) { XmlNodeList majorDestinationsList = destinationsElement.SelectNodes("destination"); Dictionary<string, int> 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); airport.Terminals.addTerminal(new Terminal(airport, null, terminalName, terminalGates, new DateTime(1950, 1, 1))); } 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); Runway.SurfaceType surface = (Runway.SurfaceType)Enum.Parse(typeof(Runway.SurfaceType), runwayNode.Attributes["surface"].Value); airport.Runways.Add(new Runway(runwayName, runwayLength, surface, new DateTime(1900, 1, 1), true)); } 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(); * */ string i = id; string s = e.ToString(); } }
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) { }