Exemple #1
0
        /// <summary>
        /// Retrieve most current data for a Location
        /// Try a number of ranges to retrieve data to not overlaod the server
        /// </summary>
        private async Task GetData(double lat, double lon)
        {
            // Sanity checks
            if (double.IsNaN(lat))
            {
                return;
            }
            if (double.IsNaN(lon))
            {
                return;
            }

            var response = new MetarTafDataList();

            foreach (var range in c_MaxRangeSM)
            {
                switch (MetarProvider)
                {
                case Providers.AviationWeatherDotGov:
                    response = await Provider.AviationWeatherDotGov.MetarRequest.GetMetar(lat, lon, range);

                    break;

                default: break;
                }
                if (response.Count > 0 && response.Valid)
                {
                    break; // We have found an entry.. Return
                }
            }
            // signal response
            OnMetarDataEvent(response);
        }
Exemple #2
0
        /// <summary>
        /// Retrieve most current data for a Station
        /// If provided use the lat lon location if the station cannot return an answer
        /// Not provided means either of lat, lon is a NaN
        /// </summary>
        private async Task GetData(string station, double lat, double lon)
        {
            var response = new MetarTafDataList();

            switch (MetarProvider)
            {
            case Providers.AviationWeatherDotGov:
                response = await Provider.AviationWeatherDotGov.MetarRequest.GetMetar(station);

                break;

            default: break;
            }
            if (response.Count > 0 && response.Valid)
            {
                // signal response and end
                OnMetarDataEvent(response);
                return;
            }
            else
            {
#pragma warning disable CS4014     // Because this call is not awaited, execution of the current method continues before the call is completed
                GetData(lat, lon); // try the location
#pragma warning restore CS4014     // Because this call is not awaited, execution of the current method continues before the call is completed
            }
        }
Exemple #3
0
        /// <summary>
        /// Retrieve most current data for a Station
        /// </summary>
        private async Task GetData(string station)
        {
            var response = new MetarTafDataList();

            switch (MetarProvider)
            {
            case Providers.AviationWeatherDotGov:
                response = await Provider.AviationWeatherDotGov.MetarRequest.GetMetar(station);

                break;

            default: break;
            }
            // signal response
            OnMetarDataEvent(response);
        }
Exemple #4
0
        /// <summary>
        /// Retrieve most current data for a Location and Destination
        /// Try a number of ranges to retrieve data to not overlaod the server
        /// </summary>
        private async Task GetData(double lat, double lon, float bearing)
        {
            // Sanity checks
            if (double.IsNaN(lat))
            {
                return;
            }
            if (double.IsNaN(lon))
            {
                return;
            }
            if (float.IsNaN(bearing))
            {
                return;
            }

            var response = new MetarTafDataList();

            foreach (var range in c_MaxRangeSM)
            {
                var pos  = new LatLon(lat, lon);
                var dest = pos.DestinationPoint(range * 2, bearing, ConvConsts.EarthRadiusSM); // pt at end of range*2

                switch (MetarProvider)
                {
                case Providers.AviationWeatherDotGov:
                    response = await Provider.AviationWeatherDotGov.MetarRequest.GetMetar(lat, lon, dest.Lat, dest.Lon, range);

                    break;

                default: break;
                }
                if (response.Count > 0 && response.Valid)
                {
                    break; // We have found an entry.. Return
                }
            }
            // signal response
            OnMetarDataEvent(response);
        }
Exemple #5
0
 // Signal the user that and what data has arrived
 private void OnMetarDataEvent(MetarTafDataList data)
 {
     MetarDataEvent?.Invoke(this, new MetarTafDataEventArgs(data));
 }
Exemple #6
0
 /// <summary>
 /// cTor:
 /// </summary>
 public MetarTafDataEventArgs(MetarTafDataList data)
 {
     MetarTafData = data;
 }