private MetarWind GetFirstMetarWindElement() { if (metarElements.Count > 0) { foreach (var item in metarElements) { if (item.ElementType == MetarElementType.SurfaceWind) { MetarWind mwItem = (MetarWind)item; return(mwItem); } } } return(null); }
private void ParseCurrentMetarElements() { metarElements.Clear(); int numElements = currentMetarElements.Count; bool bWindsToFollow = false; if (numElements > 6) { int index = 0; foreach (var entry in currentMetarElements) { if (index == 0) { MetarElement item = new MetarElement(MetarElementType.Station_ID, entry); metarElements.Add(item); index++; } else { if (entry.Contains("METAR") || entry.Contains("SPECI")) { MetarElement item = new MetarElement(MetarElementType.Report_Type, entry); metarElements.Add(item); index++; } else { if (entry.Contains("AUTO")) { MetarElement item = new MetarElement(MetarElementType.Auto, entry); metarElements.Add(item); index++; } else { if (entry.Contains("COR")) { MetarElement item = new MetarElement(MetarElementType.Corrected, entry); metarElements.Add(item); index++; } else { if (entry.Contains("NIL")) { MetarElement item = new MetarElement(MetarElementType.Nil, entry); metarElements.Add(item); index++; } else { // test for windspeed string units = ""; if (IsWindSpeedEntry(entry, out units)) { MetarElement item = new MetarWind(MetarElementType.SurfaceWind, entry, units); metarElements.Add(item); index++; } else { if ((entry.Length == 7) && (entry.Substring(3, 1) == "V")) { MetarElement item = new MetarElement(MetarElementType.MinMaxWindDir, entry); metarElements.Add(item); index++; } else { if (entry.Contains("CAVOK")) { MetarElement item = new MetarElement(MetarElementType.Cavok, entry); metarElements.Add(item); index++; } else { if ((entry.Length == 6) && (entry.Substring(0, 1) == "A") || ((entry.Length == 6) && (entry.Substring(0, 1) == "Q"))) { MetarElement item = new MetarElement(MetarElementType.Altimeter, entry); metarElements.Add(item); index++; } else { if (entry == "@@@") { MetarElement item = new MetarElement(MetarElementType.WindsToFollow, entry); metarElements.Add(item); bWindsToFollow = true; index++; } else { if (bWindsToFollow == false) { MetarElement item = new MetarElement(MetarElementType.Unknown, entry); metarElements.Add(item); index++; } else { MetarElement item = new MetarElement(MetarElementType.WindsAloft, entry); metarElements.Add(item); index++; } } } } } } } } } } } // System.Console.WriteLine("Index {0} ", index); } } }