Exemplo n.º 1
0
        public override Dictionary <string, object> Parse(string remainingMetar, bool withCavok = false)
        {
            var consumed          = Consume(remainingMetar);
            var found             = consumed.Value;
            var newRemainingMetar = consumed.Key;
            var result            = new Dictionary <string, object>();

            var presentWeather = new List <WeatherPhenomenon>();

            for (var i = 1; i <= 13; i += 6)
            {
                if (!string.IsNullOrEmpty(found[i].Value) && found[i + 3].Value != "//")
                {
                    var weather = new WeatherPhenomenon()
                    {
                        IntensityProximity = found[i + 1].Value,
                        Characteristics    = found[i + 2].Value
                    };
                    for (var k = 3; k <= 5; ++k)
                    {
                        if (!string.IsNullOrEmpty(found[i + k].Value))
                        {
                            weather.AddType(found[i + k].Value);
                        }
                    }
                    presentWeather.Add(weather);
                }
            }

            result.Add(PresentWeatherParameterName, presentWeather);

            return(GetResults(newRemainingMetar, result));
        }
        public override Dictionary <string, object> Parse(string remainingMetar, bool withCavok = false)
        {
            var consumed          = Consume(remainingMetar);
            var found             = consumed.Value;
            var newRemainingMetar = consumed.Key;
            var result            = new Dictionary <string, object>();

            if (found.Count > 1)
            {
                // retrieve found params
                var weather = new WeatherPhenomenon();
                weather.Characteristics = found[1].Value;
                for (var k = 2; k <= 4; ++k)
                {
                    if (!string.IsNullOrEmpty(found[k].Value))
                    {
                        weather.AddType(found[k].Value);
                    }
                }
                result.Add(RecentWeatherParameterName, weather);
            }

            return(GetResults(newRemainingMetar, result));
        }