Beispiel #1
0
        public GeoPosition(string latitude, string longitude, AltitudeMetric altitude = null)
        {
            latitude  = !String.IsNullOrEmpty(latitude) ? latitude : "0";
            longitude = !String.IsNullOrEmpty(longitude) ? longitude : "0";

            this.Latitude  = double.Parse(latitude);
            this.Longitude = double.Parse(longitude);
            this.Altitude  = altitude;
        }
        public AirplanesRadar(IServiceAPI serviceAPI, bool isCacheEnabled = false)
        {
            source = serviceAPI;
            this.IsCacheEnabled = isCacheEnabled;

            LoggingHelper.LogBehavior("> INIT basic data...");
            var fooAirplane = new Airplane("0", "0", AltitudeMetric.FromMeter(0), 0, 0, SpeedMetric.FromKnot(0), 0, 0, "", "", "A319", "0", false);

            LoggingHelper.LogBehavior("> DONE basic data.");
        }
        public Airplane(string hexCode, string flightName, AltitudeMetric altitude, double latitude, double longitude, SpeedMetric speed, double verticalSpeed, double direction, string from, string to, string model, string registration, bool isOnGround)
        {
            var airplaneDatabaseData = AircraftDatabase.GetByICAO(hexCode);

            this.ID    = hexCode;
            this.Model = airplaneDatabaseData != null?AircraftModel.GetByICAO(airplaneDatabaseData.AircraftModelName) : null;

            this.Direction      = direction;
            this.From           = Airport.GetAirportByIata(from);
            this.Name           = flightName.Trim();
            this.Airline        = Airline.GetAirlineByFlight(flightName);
            this.Position       = new GeoPosition(latitude, longitude, altitude);
            this.Registration   = new AircraftRegistration(registration);
            this.Speed          = speed;
            this.To             = Airport.GetAirportByIata(to);
            this.VerticalSpeed  = verticalSpeed;
            this.DateCreation   = DateTime.Now;
            this.IsOnGround     = isOnGround;
            this.DateExpiration = DateTime.Now.AddHours(1);
        }
        /// <summary>
        /// Get Airport object from IATA
        /// </summary>
        /// <param name="iata">IATA</param>
        /// <returns></returns>
        public static Airport GetAirportByIata(string iata)
        {
            if (ListAirports == null)
            {
                string jsonstring = ResourceHelper.LoadExternalResource(resourceFileName);

                ListAirports = JsonConvert.DeserializeObject <IDictionary <string, IDictionary <string, object> > >(jsonstring);

                LoggingHelper.LogBehavior($">>> Done converting {resourceFileName} file ''.");
            }


            IDictionary <string, object> selectedAirport = null;

            if (ListAirports.ContainsKey(iata))
            {
                selectedAirport = ListAirports[iata];
            }
            // procurar por ICAO
            else if (!String.IsNullOrEmpty(iata))
            {
                var airportByICAO = ListAirports.Where(s => s.Value.ContainsKey("ICAO") && s.Value["ICAO"].ToString() == iata);

                if (airportByICAO.Any())
                {
                    iata = airportByICAO.FirstOrDefault().Key;
                }
            }

            if (ListAirports.ContainsKey(iata))
            {
                selectedAirport = ListAirports[iata];

                var airport = new Airport()
                {
                    City        = selectedAirport["City"].ToString(),
                    Country     = selectedAirport["Country"].ToString(),
                    Name        = selectedAirport["Name"].ToString(),
                    IATA        = iata,
                    Position    = new GeoPosition(selectedAirport["Lat"].ToString(), selectedAirport["Long"].ToString(), AltitudeMetric.FromFoot(double.Parse(selectedAirport["Alt"].ToString()))),
                    IsValid     = true,
                    ICAO        = selectedAirport["ICAO"].ToString(),
                    ListRunways = new List <Runway>()
                };



                return(airport);
            }
            else
            {
                return(new Airport()
                {
                    Name = iata + " (no found)",
                    IATA = iata,
                    City = String.Empty,
                    Country = String.Empty,
                    IsValid = false,
                });
            }
        }
Beispiel #5
0
 public GeoPosition(double latitude, double longitude, AltitudeMetric altitude = null)
 {
     this.Latitude  = latitude;
     this.Longitude = longitude;
     this.Altitude  = altitude;
 }