Esempio n. 1
0
        /// <summary>
        /// Decode a part into mData and return the rest
        /// </summary>
        /// <param name="raw">The raw METAR input string</param>
        /// <param name="minMax">The TempMinMax List to fill in</param>
        /// <returns>The reminder of  the input string, (raw minus the processed part)</returns>
        public static string Decode(string raw, List <T_TempMinMax> minMax)
        {
            try {
                Match match = RE_regular.Match(raw);
                if (match.Success)
                {
                    var tmm = new T_TempMinMax();
                    tmm.Chunks     += match.Groups["chunk"].Value;
                    tmm.Temperature = UnitC.FromTemp(match.Groups["temp"].Value);
                    int day   = int.Parse(match.Groups["day"].Value);
                    int zHour = int.Parse(match.Groups["hour"].Value);
                    tmm.At    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, day, zHour, 0, 0, DateTimeKind.Utc);
                    tmm.IsMax = match.Groups["flag"].Value == "TX";
                    tmm.IsMin = match.Groups["flag"].Value == "TN";
                    tmm.Valid = true;
                    minMax.Add(tmm);
                    return(match.Groups["rest"].Value.TrimStart( ));
                }
            }
            catch {
                ; // DEBUG STOP
            }

            return(raw);
        }
Esempio n. 2
0
        /// <summary>
        /// Decode a part into mData and return the rest
        /// </summary>
        /// <param name="raw">The raw METAR input string</param>
        /// <param name="visibility">The Visibility record to fill in</param>
        /// <returns>The reminder of  the input string, (raw minus the processed part)</returns>
        public static string Decode(string raw, M_Visibility visibility)
        {
            try {
                Match match = RE_regular.Match(raw);
                if (match.Success)
                {
                    visibility.Chunks      += match.Groups["chunk"].Value;
                    visibility.Distance_SM  = UnitC.DistAsSM(int.Parse(match.Groups["dist"].Value), match.Groups["unit"].Value);
                    visibility.LessThanFlag = match.Groups["mp"].Success && match.Groups["mp"].Value == "M";
                    visibility.MoreThanFlag = (match.Groups["mp"].Success && match.Groups["mp"].Value == "P") || (match.Groups["dist"].Value == "9999");
                    visibility.Direction    = match.Groups["dir"].Success ? match.Groups["dir"].Value : "";
                    visibility.Valid        = true;
                    return(match.Groups["rest"].Value.TrimStart( ));
                }

                match = RE_parts.Match(raw);
                if (match.Success)
                {
                    visibility.Chunks += match.Groups["chunk"].Value;
                    float val = UnitC.FromDistU(match.Groups["distu"].Value);
                    visibility.Distance_SM  = UnitC.DistAsSM(val, match.Groups["unit"].Value);
                    visibility.LessThanFlag = match.Groups["mp"].Success && match.Groups["mp"].Value == "M";
                    visibility.MoreThanFlag = match.Groups["mp"].Success && match.Groups["mp"].Value == "P";
                    visibility.Direction    = match.Groups["dir"].Success ? match.Groups["dir"].Value : "";
                    visibility.Valid        = true;
                    return(match.Groups["rest"].Value.TrimStart( ));
                }

                match = RE_cavok.Match(raw);
                if (match.Success)
                {
                    visibility.Chunks += match.Groups["chunk"].Value;
                    visibility.CAVOK   = true;
                    visibility.Valid   = true;
                    return(match.Groups["rest"].Value.TrimStart( ));
                }
            }
            catch {
                ; // DEBUG STOP
            }

            return(raw);
        }
Esempio n. 3
0
        /// <summary>
        /// Decode a part into mData and return the rest
        /// </summary>
        /// <param name="raw">The raw METAR input string</param>
        /// <param name="runwayVRs">The RunwayVR List to fill in</param>
        /// <returns>The reminder of  the input string, (raw minus the processed part)</returns>
        public static string Decode(string raw, List <M_RunwayVR> runwayVRs)
        {
            try {
                if (IsMatch(raw))
                {
                    Match match = RE_regular.Match(raw);
                    var   rw    = new M_RunwayVR();
                    rw.Chunks  += match.Groups["chunk"].Value;
                    rw.RunwayID = match.Groups["rwy"].Value;
                    if (match.Groups["lo"].Success)
                    {
                        rw.LoDistance_ft  = UnitC.DistAsFT(int.Parse(match.Groups["lo"].Value), match.Groups["unit"].Value);
                        rw.LoLessThanFlag = match.Groups["mpl"].Success && match.Groups["mpl"].Value == "M";
                        rw.LoMoreThanFlag = match.Groups["mpl"].Success && match.Groups["mpl"].Value == "P";
                    }

                    if (match.Groups["hi"].Success)
                    {
                        rw.HiDistance_ft  = UnitC.DistAsFT(int.Parse(match.Groups["hi"].Value), match.Groups["unit"].Value);
                        rw.HiLessThanFlag = match.Groups["mpl"].Success && match.Groups["mpl"].Value == "M";
                        rw.HiMoreThanFlag = match.Groups["mpl"].Success && match.Groups["mpl"].Value == "P";
                    }

                    if (match.Groups["trend"].Success)
                    {
                        rw.Trend = match.Groups["trend"].Value;
                    }

                    rw.Valid = true;
                    runwayVRs.Add(rw);
                    return(match.Groups["rest"].Value.TrimStart( ));
                }
            }
            catch {
                ; // DEBUG STOP
            }

            return(raw);
        }
Esempio n. 4
0
        /// <summary>
        /// Decode a part into mData and return the rest
        /// </summary>
        /// <param name="raw">The raw message input string</param>
        /// <param name="pressure">The Altimeter record to fill in</param>
        /// <returns>The reminder of  the input string, (raw minus the processed part)</returns>
        public static string Decode(string raw, M_Pressure pressure)
        {
            try {
                Match match = RE_regular.Match(raw);
                if (match.Success)
                {
                    pressure.Chunks          += match.Groups["chunk"].Value;
                    pressure.AltPressure_inHg = UnitC.PressureAsInHg(int.Parse(match.Groups["press"].Value),
                                                                     match.Groups["unit"].Value,
                                                                     (match.Groups["unit"].Success)? match.Groups["unit"].Value:"");
                    pressure.AltPressure_hPa = UnitC.PressureAsHPa(int.Parse(match.Groups["press"].Value),
                                                                   match.Groups["unit"].Value,
                                                                   (match.Groups["unit"].Success) ? match.Groups["unit"].Value : "");
                    pressure.Valid = true;
                    return(match.Groups["rest"].Value.TrimStart( ));
                }
            }
            catch {
                ; // DEBUG STOP
            }

            return(raw);
        }
Esempio n. 5
0
        /// <summary>
        /// Decode a part into mData and return the rest
        /// </summary>
        /// <param name="raw">The raw METAR input string</param>
        /// <param name="temp">The Temperature record to fill in</param>
        /// <returns>The reminder of  the input string, (raw minus the processed part)</returns>
        public static string Decode(string raw, M_Temp temp)
        {
            try {
                Match match = RE_regular.Match(raw);
                if (match.Success)
                {
                    temp.Chunks     += match.Groups["chunk"].Value;
                    temp.Temperature = UnitC.FromTemp(match.Groups["temp"].Value);
                    if (match.Groups["dewpt"].Success)
                    {
                        temp.Dewpoint = UnitC.FromTemp(match.Groups["dewpt"].Value);
                    }

                    temp.Valid = true;
                    return(match.Groups["rest"].Value.TrimStart( ));
                }
            }
            catch {
                ; // DEBUG STOP
            }

            return(raw);
        }
Esempio n. 6
0
        private static Regex RE_variable = new Regex(@"^(?<chunk>(?<from>\d{3})(V)(?<to>\d{3}))(?<rest>\s{1}.*)", RegexOptions.Compiled);                                          // option variable 350V002


        /// <summary>
        /// Decode a part into mData and return the rest
        /// </summary>
        /// <param name="raw">The raw METAR input string</param>
        /// <param name="wind">The Wind record to fill in</param>
        /// <returns>The reminder of  the input string, (raw minus the processed part)</returns>
        public static string Decode(string raw, M_Wind wind)
        {
            try {
                Match match = RE_regular.Match(raw);
                if (match.Success)
                {
                    wind.Chunks               += match.Groups["chunk"].Value;
                    wind.DirectionVariable     = false;
                    wind.SpeedAbove            = false;
                    wind.WindDirectionMain_deg = int.Parse(match.Groups["dir"].Value);
                    wind.WindSpeed_kt          = UnitC.SpeedAsKT(int.Parse(match.Groups["speed"].Value), match.Groups["unit"].Value);
                    if (match.Groups["gust"].Success)
                    {
                        wind.WindGustSpeed_kt = UnitC.SpeedAsKT(int.Parse(match.Groups["gust"].Value), match.Groups["unit"].Value);
                    }
                    wind.Valid = true;
                    return(match.Groups["rest"].Value.TrimStart( ));
                }

                match = RE_above.Match(raw);
                if (match.Success)
                {
                    wind.Chunks               += match.Groups["chunk"].Value;
                    wind.DirectionVariable     = false;
                    wind.SpeedAbove            = true;
                    wind.WindDirectionMain_deg = 0; // undet direction
                    wind.WindSpeed_kt          = UnitC.SpeedAsKT(int.Parse(match.Groups["speed"].Value), match.Groups["unit"].Value);
                    wind.Valid = true;
                    return(match.Groups["rest"].Value.TrimStart( ));
                }

                match = RE_varLow.Match(raw);
                if (match.Success)
                {
                    wind.Chunks           += match.Groups["chunk"].Value;
                    wind.DirectionVariable = true;
                    wind.SpeedAbove        = false;
                    wind.WindSpeed_kt      = UnitC.SpeedAsKT(int.Parse(match.Groups["speed"].Value), match.Groups["unit"].Value);
                    if (match.Groups["gust"].Success)
                    {
                        wind.WindGustSpeed_kt = UnitC.SpeedAsKT(int.Parse(match.Groups["gust"].Value), match.Groups["unit"].Value);
                    }
                    wind.Valid = true;
                    return(match.Groups["rest"].Value.TrimStart( ));
                }

                match = RE_variable.Match(raw);
                // should have a valid Wind Record here..
                if (wind.Valid && match.Success)
                {
                    wind.Chunks += " " + match.Groups["chunk"].Value;
                    wind.WindVariationFrom_deg = int.Parse(match.Groups["from"].Value);
                    wind.WindVariationTo_deg   = int.Parse(match.Groups["to"].Value);
                    return(match.Groups["rest"].Value.TrimStart( ));
                }
            }
            catch {
                ; // DEBUG STOP
            }

            return(raw);
        }