-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDecodedMetar.cs
180 lines (153 loc) · 4.87 KB
/
DecodedMetar.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Metar.Decoder.Entity
{
public sealed class DecodedMetar
{
/// <summary>
/// Report type (METAR, METAR COR or SPECI)
/// </summary>
public enum MetarType
{
NULL,
METAR,
METAR_COR,
SPECI,
SPECI_COR,
}
/// <summary>
/// Metar Status
/// </summary>
public enum MetarStatus
{
NULL,
AUTO,
NIL,
}
private string _rawMetar;
/// <summary>
/// Raw METAR
/// </summary>
public string RawMetar
{
get
{
return _rawMetar.Trim();
}
set
{
_rawMetar = value;
}
}
/// <summary>
/// Decoding exceptions, if any
/// </summary>
private List<MetarChunkDecoderException> _decodingExceptions = new();
/// <summary>
/// If the decoded metar is invalid, get all the exceptions that occurred during decoding
/// Note that in strict mode, only the first encountered exception will be reported as parsing stops on error
/// Else return null;.
/// </summary>
public ReadOnlyCollection<MetarChunkDecoderException> DecodingExceptions
{
get
{
return new ReadOnlyCollection<MetarChunkDecoderException>(_decodingExceptions);
}
}
/// <summary>
/// Report type (METAR, METAR COR or SPECI)
/// </summary>
public MetarType Type { get; set; } = MetarType.NULL;
/// <summary>
/// ICAO code of the airport where the observation has been made
/// </summary>
public string ICAO { get; set; } = string.Empty;
/// <summary>
/// Day of this observation
/// </summary>
public int? Day { get; set; }
/// <summary>
/// Time of the observation, as a string
/// </summary>
public string Time { get; set; } = string.Empty;
/// <summary>
/// Report status (AUTO or NIL)
/// </summary>
public string Status { get; set; } = string.Empty;
/// <summary>
/// Surface wind information
/// </summary>
public SurfaceWind SurfaceWind { get; set; }
/// <summary>
/// Visibility information
/// </summary>
public Visibility Visibility { get; set; }
public bool Cavok { get; set; } = false;
/// <summary>
/// Runway visual range information
/// </summary>
public List<RunwayVisualRange> RunwaysVisualRange { get; set; } = new List<RunwayVisualRange>();
/// <summary>
/// Present weather
/// </summary>
public List<WeatherPhenomenon> PresentWeather { get; set; } = new List<WeatherPhenomenon>();
/// <summary>
/// Cloud layers information
/// </summary>
public List<CloudLayer> Clouds { get; set; } = new List<CloudLayer>();
/// <summary>
/// Temperature information
/// </summary>
public Value AirTemperature { get; set; }
/// <summary>
/// Temperature information
/// </summary>
public Value DewPointTemperature { get; set; }
/// <summary>
/// Pressure information
/// </summary>
public Value Pressure { get; set; }
/// <summary>
/// Recent weather
/// </summary>
public WeatherPhenomenon RecentWeather { get; set; }
/// <summary>
/// Windshear runway information (which runways, or "all")
/// </summary>
public bool? WindshearAllRunways { get; set; }
/// <summary>
/// Windshear runway information (which runways, or "all")
/// </summary>
public List<string> WindshearRunways { get; set; }
internal DecodedMetar(string rawMetar = "")
{
RawMetar = rawMetar;
}
/// <summary>
/// Reset the whole list of Decoding Exceptions
/// </summary>
public void ResetDecodingExceptions()
{
_decodingExceptions = new List<MetarChunkDecoderException>();
}
/// <summary>
/// Check if the decoded metar is valid, i.e. if there was no error during decoding.
/// </summary>
public bool IsValid
{
get
{
return DecodingExceptions.Count == 0;
}
}
/// <summary>
/// Add an exception that occured during metar decoding.
/// </summary>
/// <param name="ex"></param>
public void AddDecodingException(MetarChunkDecoderException ex)
{
_decodingExceptions.Add(ex);
}
}
}