1 // Metar report implementation class code
3 #include "MetarReport.h"
6 CMetarReport::CMetarReport(
10 m_DecodedReport = new Decoded_METAR;
11 DcdMETAR( s, (Decoded_METAR *)m_DecodedReport );
15 CMetarReport::~CMetarReport()
19 static int DecodeDirChars( char* c )
25 if ( c[0] == 'E' ) r = 90;
26 else if ( c[0] == 'S' ) r = 180;
27 else if ( c[0] == 'W' ) r = 270;
31 if ( c[1] == 'E' ) r = 45;
32 else if ( c[1] == 'W' ) r = 315;
36 if ( c[1] == 'E' ) r = 135;
37 else if ( c[1] == 'W' ) r = 225;
43 char *CMetarReport::StationID()
45 return ((Decoded_METAR *)m_DecodedReport)->stnid;
48 int CMetarReport::WindDirection()
50 return ((Decoded_METAR *)m_DecodedReport)->winData.windDir;
53 int CMetarReport::WindSpeed()
55 return ((Decoded_METAR *)m_DecodedReport)->winData.windSpeed;
58 int CMetarReport::WindGustSpeed()
60 return ((Decoded_METAR *)m_DecodedReport)->winData.windGust;
63 int CMetarReport::LightningDirection()
65 return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->LTG_DIR );
68 char CMetarReport::CloudLow()
70 return ((Decoded_METAR *)m_DecodedReport)->CloudLow;
73 char CMetarReport::CloudMedium()
75 return ((Decoded_METAR *)m_DecodedReport)->CloudMedium;
78 char CMetarReport::CloudHigh()
80 return ((Decoded_METAR *)m_DecodedReport)->CloudHigh;
83 int CMetarReport::VirgaDirection()
85 return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->VIRGA_DIR );
88 int CMetarReport::TornadicDirection()
90 return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->TornadicDIR );
93 int CMetarReport::TornadicMovementDirection()
95 return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->TornadicMovDir );
98 int CMetarReport::ThunderStormDirection()
100 return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->TS_LOC );
103 int CMetarReport::ThunderStormMovementDirection()
105 return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->TS_MOVMNT );
108 bool CMetarReport::Virga()
110 return ((Decoded_METAR *)m_DecodedReport)->VIRGA;
113 bool CMetarReport::VolcanicAsh()
115 return ((Decoded_METAR *)m_DecodedReport)->VOLCASH;
118 bool CMetarReport::Hail()
120 return ((Decoded_METAR *)m_DecodedReport)->GR;
123 bool CMetarReport::OccationalLightning()
125 return ((Decoded_METAR *)m_DecodedReport)->OCNL_LTG;
128 bool CMetarReport::FrequentLightning()
130 return ((Decoded_METAR *)m_DecodedReport)->FRQ_LTG;
133 bool CMetarReport::ContinuousLightning()
135 return ((Decoded_METAR *)m_DecodedReport)->CNS_LTG;
138 bool CMetarReport::CloudToGroundLightning()
140 return ((Decoded_METAR *)m_DecodedReport)->CG_LTG;
143 bool CMetarReport::InterCloudLightning()
145 return ((Decoded_METAR *)m_DecodedReport)->IC_LTG;
148 bool CMetarReport::CloudToCloudLightning()
150 return ((Decoded_METAR *)m_DecodedReport)->CC_LTG;
153 bool CMetarReport::CloudToAirLightning()
155 return ((Decoded_METAR *)m_DecodedReport)->CA_LTG;
158 bool CMetarReport::DistantLightning()
160 return ((Decoded_METAR *)m_DecodedReport)->DSNT_LTG;
163 bool CMetarReport::AirportLightning()
165 return ((Decoded_METAR *)m_DecodedReport)->AP_LTG;
168 bool CMetarReport::VicinityLightning()
170 return ((Decoded_METAR *)m_DecodedReport)->VcyStn_LTG;
173 bool CMetarReport::OverheadLightning()
175 return ((Decoded_METAR *)m_DecodedReport)->OVHD_LTG;
178 int CMetarReport::Temperature()
180 return ((Decoded_METAR *)m_DecodedReport)->temp;
183 int CMetarReport::DewpointTemperature()
185 return ((Decoded_METAR *)m_DecodedReport)->dew_pt_temp;
188 int CMetarReport::VerticalVisibility() // Meters
190 return ((Decoded_METAR *)m_DecodedReport)->VertVsby;
193 int CMetarReport::Ceiling()
195 return FEET_TO_METER * ((Decoded_METAR *)m_DecodedReport)->Ceiling;
198 int CMetarReport::EstimatedCeiling()
200 return FEET_TO_METER * ((Decoded_METAR *)m_DecodedReport)->Estimated_Ceiling;
203 int CMetarReport::VariableSkyLayerHeight()
205 return FEET_TO_METER * ((Decoded_METAR *)m_DecodedReport)->VrbSkyLayerHgt;
208 int CMetarReport::SnowDepthInches()
210 return ((Decoded_METAR *)m_DecodedReport)->snow_depth;
215 operator << ( ostream& out, CMetarReport& p )
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
256 void CMetarReport::dump()
258 prtDMETR( (Decoded_METAR *)m_DecodedReport );