]> git.mxchange.org Git - simgear.git/blob - simgear/metar/MetarReport.cpp
Fixes for MSVC++.
[simgear.git] / simgear / metar / MetarReport.cpp
1 // Metar report implementation class code
2
3 #include "MetarReport.h"
4 #include "Metar.h"
5
6 CMetarReport::CMetarReport(
7    char *s ) :
8                 m_DecodedReport( 0 )
9 {
10         m_DecodedReport = new Decoded_METAR;
11         DcdMETAR( s, (Decoded_METAR *)m_DecodedReport );
12 }
13
14
15 CMetarReport::~CMetarReport()
16 {
17 }
18
19 static int DecodeDirChars( char* c )
20 {
21         int r = 0;
22
23         if ( c[0] )
24         {
25                 if ( c[0] == 'E' ) r = 90;
26                 else if ( c[0] == 'S' ) r = 180;
27                 else if ( c[0] == 'W' ) r = 270;
28
29                 if ( r == 0 )
30                 {
31                         if ( c[1] == 'E' ) r = 45;
32                         else if ( c[1] == 'W' ) r = 315;
33                 }
34                 else if ( r = 180 )
35                 {
36                         if ( c[1] == 'E' ) r = 135;
37                         else if ( c[1] == 'W' ) r = 225;
38                 }
39         }
40         return r;
41 }
42
43 char *CMetarReport::StationID()
44 {
45         return ((Decoded_METAR *)m_DecodedReport)->stnid;
46 }
47
48 int CMetarReport::WindDirection()
49 {
50         return ((Decoded_METAR *)m_DecodedReport)->winData.windDir;
51 }
52
53 int CMetarReport::WindSpeed()
54 {
55         return ((Decoded_METAR *)m_DecodedReport)->winData.windSpeed;
56 }
57
58 int CMetarReport::WindGustSpeed()
59 {
60         return ((Decoded_METAR *)m_DecodedReport)->winData.windGust;
61 }
62
63 int CMetarReport::LightningDirection()
64 {
65         return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->LTG_DIR );
66 }
67
68 char CMetarReport::CloudLow()
69 {
70         return ((Decoded_METAR *)m_DecodedReport)->CloudLow;
71 }
72
73 char CMetarReport::CloudMedium()
74 {
75         return ((Decoded_METAR *)m_DecodedReport)->CloudMedium;
76 }
77
78 char CMetarReport::CloudHigh()
79 {
80         return ((Decoded_METAR *)m_DecodedReport)->CloudHigh;
81 }
82
83 int CMetarReport::VirgaDirection()
84 {
85         return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->VIRGA_DIR );
86 }
87
88 int CMetarReport::TornadicDirection()
89 {
90         return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->TornadicDIR );
91 }
92
93 int CMetarReport::TornadicMovementDirection()
94 {
95         return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->TornadicMovDir );
96 }
97
98 int CMetarReport::ThunderStormDirection()
99 {
100         return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->TS_LOC );
101 }
102
103 int CMetarReport::ThunderStormMovementDirection()
104 {
105         return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->TS_MOVMNT );
106 }
107
108 bool CMetarReport::Virga()
109 {
110         return ((Decoded_METAR *)m_DecodedReport)->VIRGA;
111 }
112
113 bool CMetarReport::VolcanicAsh()
114 {
115         return ((Decoded_METAR *)m_DecodedReport)->VOLCASH;
116 }
117
118 bool CMetarReport::Hail()
119 {
120         return ((Decoded_METAR *)m_DecodedReport)->GR;
121 }
122
123 bool CMetarReport::OccationalLightning()
124 {
125         return ((Decoded_METAR *)m_DecodedReport)->OCNL_LTG;
126 }
127
128 bool CMetarReport::FrequentLightning()
129 {
130         return ((Decoded_METAR *)m_DecodedReport)->FRQ_LTG;
131 }
132
133 bool CMetarReport::ContinuousLightning()
134 {
135         return ((Decoded_METAR *)m_DecodedReport)->CNS_LTG;
136 }
137
138 bool CMetarReport::CloudToGroundLightning()
139 {
140         return ((Decoded_METAR *)m_DecodedReport)->CG_LTG;
141 }
142
143 bool CMetarReport::InterCloudLightning()
144 {
145         return ((Decoded_METAR *)m_DecodedReport)->IC_LTG;
146 }
147
148 bool CMetarReport::CloudToCloudLightning()
149 {
150         return ((Decoded_METAR *)m_DecodedReport)->CC_LTG;
151 }
152
153 bool CMetarReport::CloudToAirLightning()
154 {
155         return ((Decoded_METAR *)m_DecodedReport)->CA_LTG;
156 }
157
158 bool CMetarReport::DistantLightning()
159 {
160         return ((Decoded_METAR *)m_DecodedReport)->DSNT_LTG;
161 }
162
163 bool CMetarReport::AirportLightning()
164 {
165         return ((Decoded_METAR *)m_DecodedReport)->AP_LTG;
166 }
167
168 bool CMetarReport::VicinityLightning()
169 {
170         return ((Decoded_METAR *)m_DecodedReport)->VcyStn_LTG;
171 }
172
173 bool CMetarReport::OverheadLightning()
174 {
175         return ((Decoded_METAR *)m_DecodedReport)->OVHD_LTG;
176 }
177
178 int CMetarReport::Temperature()
179 {
180         return ((Decoded_METAR *)m_DecodedReport)->temp;
181 }
182
183 int CMetarReport::DewpointTemperature()
184 {
185         return ((Decoded_METAR *)m_DecodedReport)->dew_pt_temp;
186 }
187
188 int CMetarReport::VerticalVisibility() // Meters
189 {
190         return ((Decoded_METAR *)m_DecodedReport)->VertVsby;
191 }
192
193 int CMetarReport::Ceiling()
194 {
195         return FEET_TO_METER * ((Decoded_METAR *)m_DecodedReport)->Ceiling;
196 }
197
198 int CMetarReport::EstimatedCeiling()
199 {
200         return FEET_TO_METER * ((Decoded_METAR *)m_DecodedReport)->Estimated_Ceiling;
201 }
202
203 int CMetarReport::VariableSkyLayerHeight()
204 {
205         return FEET_TO_METER * ((Decoded_METAR *)m_DecodedReport)->VrbSkyLayerHgt;
206 }
207
208 int CMetarReport::SnowDepthInches()
209 {
210         return ((Decoded_METAR *)m_DecodedReport)->snow_depth;
211 }
212
213
214 std::ostream&
215 operator << ( ostream& out, CMetarReport& p )
216 {
217     return out 
218         << "StationID " << p.StationID()
219         << " WindDirection " << p.WindDirection()
220         << " WindSpeed " << p.WindSpeed()
221         << " WindGustSpeed " << p.WindGustSpeed() << std::endl
222         << "CloudLow " << p.CloudLow()
223         << " CloudMedium " << p.CloudMedium()
224         << " CloudHigh " << p.CloudHigh() << std::endl
225         << "TornadicDirection " << p.TornadicDirection()
226         << " TornadicMovementDirection " << p.TornadicMovementDirection() << std::endl
227         << "ThunderStormDirection " << p.ThunderStormDirection()
228         << " ThunderStormMovementDirection " << p.ThunderStormMovementDirection() << std::endl
229         << "Virga " << p.Virga()
230         << " VirgaDirection " << p.VirgaDirection() << std::endl
231         << "VolcanicAsh " << p.VolcanicAsh() << std::endl
232         << "Hail " << p.Hail() << std::endl
233         << "LightningDirection " << p.LightningDirection()
234         << " OccationalLightning " << p.OccationalLightning()
235         << " FrequentLightning " << p.FrequentLightning()
236         << " ContinuousLightning " << p.ContinuousLightning() << std::endl
237         << "CloudToGroundLightning " << p.CloudToGroundLightning()
238         << " InterCloudLightning " << p.InterCloudLightning()
239         << " CloudToCloudLightning " << p.CloudToCloudLightning()
240         << " CloudToAirLightning " << p.CloudToAirLightning() << std::endl
241         << "DistantLightning " << p.DistantLightning()
242         << " AirportLightning " << p.AirportLightning()
243         << " VicinityLightning " << p.VicinityLightning()
244         << " OverheadLightning " << p.OverheadLightning() << std::endl
245         << "VerticalVisibility " << p.VerticalVisibility() << std::endl // Meters
246         << "Temperature " << p.Temperature() 
247         << " DewpointTemperature " << p.DewpointTemperature() << std::endl
248         << "Ceiling " << p.Ceiling()
249         << " EstimatedCeiling " << p.EstimatedCeiling()
250         << " VariableSkyLayerHeight " << p.VariableSkyLayerHeight() << std::endl
251         << "SnowDepthInches " << p.SnowDepthInches() << std::endl
252         ;
253 }
254
255
256 void CMetarReport::dump()
257 {
258         prtDMETR( (Decoded_METAR *)m_DecodedReport );
259 }