Example #1
0
        private static string Get(VisibilityForMetar visibilityForMetar)
        {
            StringBuilder ret = new StringBuilder();

            ret.Append(Get(visibilityForMetar as Visibility));

            if (visibilityForMetar.IsClear == false)
            {
                if (visibilityForMetar.DirectionSpecification != null)
                {
                    ret.Append(R.VisibilityFrom + R.Space + Get(visibilityForMetar.DirectionSpecification.Value) + R.Space);
                }

                if (visibilityForMetar.OtherDistance.HasValue)
                {
                    ret.Append(R.OpeningBracket + Get(visibilityForMetar.OtherDistance.Value) + R.Space + R.VisibilityFrom + R.Space + Get(visibilityForMetar.OtherDirectionSpecification.Value) + R.ClosingBracket + R.Space);
                }

                if (visibilityForMetar.Runways.Count > 0)
                {
                    string pom = Get(visibilityForMetar.Runways);
                    ret.Append(R.Dot);
                    ret.Append(pom);
                }
            }

            ret.Append(R.Dot);

            return(ret.ToString());
        }
Example #2
0
        /// <summary>
        /// The descendant's implementation of the decoding function.
        /// </summary>
        /// <param name="source">Source string to decode.</param>
        /// <returns></returns>
        protected override Metar _Decode(string source)
        {
            Metar  ret = new Metar();
            string p   = source;

            ret.Type = new MetarPrefixDecoder().Decode(ref p);

            ret.IsCorrected = new CORDecoder()
            {
                Required = false
            }.Decode(ref p);

            ret.ICAO = new ICAOWithNumbersDecoder().Decode(ref p);

            ret.Date = new DayHourMinuteDecoder().Decode(ref p);

            ret.IsMissing = new NILDecoder()
            {
                Required = false
            }.Decode(ref p);

            ret.IsAUTO = new AUTODecoder()
            {
                Required = false
            }.Decode(ref p);

            var wind = new WindWithVariabilityDecoder()
            {
                Required = false
            }.Decode(ref p);

            if (wind == null)
            {
                wind = new WindWithVariability();
            }
            ret.Wind = wind;

            var visib = new VisibilityForMetarDecoder()
            {
                Required = false
            }.Decode(ref p);

            if (visib == null)
            {
                visib = new VisibilityForMetar();
            }
            ret.Visibility         = visib;
            ret.Visibility.Runways =
                new RunwayVisibilityListDecoder()
            {
                Required = false
            }.Decode(ref p);

            var phenomens = new PhenomInfoDecoder()
            {
                Required = false
            }.Decode(ref p);

            if (phenomens == null)
            {
                phenomens = new Types.PhenomInfo();
            }
            ret.Phenomens = phenomens;

            ret.Clouds = new CloudInfoWithNCDDecoder()
            {
                Required = false
            }.Decode(ref p);

            ret.Temperature = new TemperatureDecoder()
            {
                Required = false
            }.Decode(ref p);

            ret.DewPoint = new DewPointDecoder()
            {
                Required = false
            }.Decode(ref p);

            PressureInfo pi = new PressureInfoDecoder()
            {
                Required = false
            }.Decode(ref p);

            if (pi == null)
            {
                pi = new PressureInfo()
                {
                    QNH = 1013
                }
            }
            ;
            ret.Pressure = pi;

            ret.RePhenomens = new RePhenomInfoDecoder()
            {
                Required = false
            }.Decode(ref p);

            ret.WindShears = new WindShearInfoDecoder()
            {
                Required = false
            }.Decode(ref p);

            ret.SeaSurfaceTemperature = new SeaSurfaceTemperatureDecoder()
            {
                Required = false
            }.Decode(ref p);

            ret.SeaState = new SeaStateDecoder()
            {
                Required = false
            }.Decode(ref p);

            ret.RunwayConditions = new RunwayConditionInfoDecoder()
            {
                Required = false
            }.Decode(ref p);

            ret.Trend = new TrendInfoForMetarDecoder()
            {
                Required = false
            }.Decode(ref p);

            ret.Remark = new RemarkDecoder()
            {
                Required = false
            }.Decode(ref p);

            return(ret);
        }
    }