Esempio n. 1
0
        public void GetWindTestVRB()
        {
            var w = ParaExtractor.GetWind("RCTP ... VRB05KT").Value;

            Assert.AreEqual(0.0, (w.Direction - 360.0).Mod(360.0), 1E-6);
            Assert.AreEqual(0.0, w.Speed, 1E-6);
        }
Esempio n. 2
0
        public void PrecipitationExistsTest()
        {
            var noRain = ParaExtractor.PrecipitationExists("EDDM CAVOK");

            Assert.IsFalse(noRain);

            var lightRain = ParaExtractor.PrecipitationExists("EDDM -RA");

            Assert.IsTrue(lightRain);

            var rain = ParaExtractor.PrecipitationExists("EDDM RA");

            Assert.IsTrue(rain);

            var heavyRain = ParaExtractor.PrecipitationExists("EDDM +RA");

            Assert.IsTrue(heavyRain);

            var lightSnow = ParaExtractor.PrecipitationExists("EDDM -SN");

            Assert.IsTrue(lightSnow);

            var lightShowerRain = ParaExtractor.PrecipitationExists("EDDM -SHRA");

            Assert.IsTrue(lightShowerRain);

            var showerRainInVicinity = ParaExtractor.PrecipitationExists("EDDM VCSHRA");

            Assert.IsTrue(showerRainInVicinity);
        }
Esempio n. 3
0
        public void GetPressTest()
        {
            var(found1, unit1, p1) = ParaExtractor.GetPressure("RCTP ... Q1015 ");
            Assert.IsTrue(found1);
            Assert.AreEqual(PressureUnit.Mb, unit1);
            Assert.AreEqual(1015.0, p1, 1E-6);

            var(found2, unit2, p2) = ParaExtractor.GetPressure("KLAX ... A3001");
            Assert.IsTrue(found2);
            Assert.AreEqual(PressureUnit.inHg, unit2);
            Assert.AreEqual(30.01, p2, 1E-6);
        }
Esempio n. 4
0
        /// <summary>
        /// Returns whether the operation was successful.
        /// </summary>
        public static bool Fill(
            string metar,
            TextBox windDirection,
            TextBox windSpeed,
            TextBox oat,
            ComboBox tempUnit,
            TextBox altimeter,
            ComboBox pressUnit,
            ComboBox surfCond)
        {
            var wind = ParaExtractor.GetWind(metar);
            int?temp = ParaExtractor.GetTemp(metar);

            var(pressFound, pUnit, press) = ParaExtractor.GetPressure(metar);
            bool precip = ParaExtractor.PrecipitationExists(metar);

            if (wind == null || temp == null || !pressFound)
            {
                return(false);
            }

            var w = wind.Value;

            windSpeed.Text = Numbers.RoundToInt(w.Speed).ToString();

            windDirection.Text =
                ((Numbers.RoundToInt(w.Direction) - 1)
                 .Mod(360) + 1)
                .ToString()
                .PadLeft(3, '0');

            tempUnit.SelectedIndex = 0;
            oat.Text = temp.Value.ToString();
            pressUnit.SelectedIndex = (int)pUnit;
            altimeter.Text          =
                pUnit == PressureUnit.inHg ?
                Math.Round(press, 2).ToString("0.00") :
                Numbers.RoundToInt(press).ToString();

            SetSurfCond(surfCond, precip);

            return(true);
        }
Esempio n. 5
0
        public void GetWindTestNormalFormat()
        {
            var w = ParaExtractor.GetWind("RCTP ... 31005KT").Value;

            Assert.AreEqual(0.0, (w.Direction - 310.0).Mod(360.0), 1E-6);
            Assert.AreEqual(5.0, w.Speed, 1E-6);

            var v = ParaExtractor.GetWind("ZSSS ... 31008MPS").Value;

            Assert.AreEqual(0.0, (v.Direction - 310.0).Mod(360.0), 1E-6);
            Assert.AreEqual(8.0 / 0.514444444, v.Speed, 1E-6);

            var x = ParaExtractor.GetWind("RCTP ... 310/05KT").Value;

            Assert.AreEqual(0.0, (x.Direction - 310.0).Mod(360.0), 1E-6);
            Assert.AreEqual(5.0, x.Speed, 1E-6);

            var y = ParaExtractor.GetWind("RCTP ... 31005G15KT").Value;

            Assert.AreEqual(0.0, (y.Direction - 310.0).Mod(360.0), 1E-6);
            Assert.AreEqual(5.0, y.Speed, 1E-6);
        }
Esempio n. 6
0
        /// <summary>
        /// Downloads the weather and selects the runway with max headwind component.
        /// If downloading timed out or downloaded data cannot be parsed, returns
        /// false for 'success'. Timeout is 1000 ms.
        /// </summary>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="InvalidOperationException">rwys is empty</exception>
        public static async Task <(bool success, string rwy)> SelectRwyBasedOnWind(
            IEnumerable <IRwyData> rwys, string icao)
        {
            var(timedout, metarDownloadResult) =
                await LibraryExtension.Tasks.Util.RunAsyncWithTimeout(
                    () => MetarDownloader.DownloadMetar(icao), 1000);

            if (timedout)
            {
                return(false, null);
            }
            var(downloaded, metar) = metarDownloadResult;
            if (!downloaded)
            {
                return(false, null);
            }
            var wind = ParaExtractor.GetWind(metar);

            if (!wind.HasValue)
            {
                return(false, null);
            }
            return(true, rwys.MaxHeadwind(wind.Value.Direction));
        }
Esempio n. 7
0
 public void GetPressTestNotFound()
 {
     var(found, _, _) = ParaExtractor.GetPressure("RCTP ... ...");
     Assert.False(found);
 }
Esempio n. 8
0
 public void GetTempTestNotFound()
 {
     Assert.AreEqual(null, ParaExtractor.GetTemp("RCTP ... ..."));
 }
Esempio n. 9
0
        public void GetTempTest2()
        {
            Assert.AreEqual(37, ParaExtractor.GetTemp(
                                @"2016/05/15 06:30
VVTS 150630Z 16004KT 090V170 9999 BKN017 FEW020TCU 37/22 Q1006 NOSIG "));
        }
Esempio n. 10
0
 public void GetTempTest1()
 {
     Assert.AreEqual(15, ParaExtractor.GetTemp("RCTP ... 15/12"));
     Assert.AreEqual(-5, ParaExtractor.GetTemp("EDDF ... M05/M06"));
     Assert.AreEqual(1, ParaExtractor.GetTemp("RJAA ... 01/M01"));
 }
Esempio n. 11
0
 public void GetWindTestNotFound()
 {
     Assert.IsNull(ParaExtractor.GetWind("RCTP ... ..."));
 }