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::Day()
50 return ((Decoded_METAR*)m_DecodedReport)->ob_date;
53 int CMetarReport::Hour()
55 return ((Decoded_METAR*)m_DecodedReport)->ob_hour;
58 int CMetarReport::Minutes()
60 return ((Decoded_METAR*)m_DecodedReport)->ob_minute;
63 int CMetarReport::WindDirection()
65 return ((Decoded_METAR *)m_DecodedReport)->winData.windDir;
68 int CMetarReport::WindSpeed()
70 return ((Decoded_METAR *)m_DecodedReport)->winData.windSpeed;
73 int CMetarReport::WindGustSpeed()
75 return ((Decoded_METAR *)m_DecodedReport)->winData.windGust;
78 int CMetarReport::LightningDirection()
80 return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->LTG_DIR );
83 char CMetarReport::CloudLow()
85 return ((Decoded_METAR *)m_DecodedReport)->CloudLow;
88 char CMetarReport::CloudMedium()
90 return ((Decoded_METAR *)m_DecodedReport)->CloudMedium;
93 char CMetarReport::CloudHigh()
95 return ((Decoded_METAR *)m_DecodedReport)->CloudHigh;
98 int CMetarReport::VirgaDirection()
100 return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->VIRGA_DIR );
103 int CMetarReport::TornadicDirection()
105 return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->TornadicDIR );
108 int CMetarReport::TornadicMovementDirection()
110 return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->TornadicMovDir );
113 int CMetarReport::ThunderStormDirection()
115 return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->TS_LOC );
118 int CMetarReport::ThunderStormMovementDirection()
120 return DecodeDirChars( ((Decoded_METAR *)m_DecodedReport)->TS_MOVMNT );
123 bool CMetarReport::Virga()
125 return ((Decoded_METAR *)m_DecodedReport)->VIRGA;
128 bool CMetarReport::VolcanicAsh()
130 return ((Decoded_METAR *)m_DecodedReport)->VOLCASH;
133 bool CMetarReport::Hail()
135 return ((Decoded_METAR *)m_DecodedReport)->GR;
138 bool CMetarReport::OccationalLightning()
140 return ((Decoded_METAR *)m_DecodedReport)->OCNL_LTG;
143 bool CMetarReport::FrequentLightning()
145 return ((Decoded_METAR *)m_DecodedReport)->FRQ_LTG;
148 bool CMetarReport::ContinuousLightning()
150 return ((Decoded_METAR *)m_DecodedReport)->CNS_LTG;
153 bool CMetarReport::CloudToGroundLightning()
155 return ((Decoded_METAR *)m_DecodedReport)->CG_LTG;
158 bool CMetarReport::InterCloudLightning()
160 return ((Decoded_METAR *)m_DecodedReport)->IC_LTG;
163 bool CMetarReport::CloudToCloudLightning()
165 return ((Decoded_METAR *)m_DecodedReport)->CC_LTG;
168 bool CMetarReport::CloudToAirLightning()
170 return ((Decoded_METAR *)m_DecodedReport)->CA_LTG;
173 bool CMetarReport::DistantLightning()
175 return ((Decoded_METAR *)m_DecodedReport)->DSNT_LTG;
178 bool CMetarReport::AirportLightning()
180 return ((Decoded_METAR *)m_DecodedReport)->AP_LTG;
183 bool CMetarReport::VicinityLightning()
185 return ((Decoded_METAR *)m_DecodedReport)->VcyStn_LTG;
188 bool CMetarReport::OverheadLightning()
190 return ((Decoded_METAR *)m_DecodedReport)->OVHD_LTG;
193 int CMetarReport::Temperature()
195 return ((Decoded_METAR *)m_DecodedReport)->temp;
198 int CMetarReport::DewpointTemperature()
200 return ((Decoded_METAR *)m_DecodedReport)->dew_pt_temp;
203 int CMetarReport::VerticalVisibility() // Meters
205 return ((Decoded_METAR *)m_DecodedReport)->VertVsby;
208 int CMetarReport::Ceiling()
210 return FEET_TO_METER * ((Decoded_METAR *)m_DecodedReport)->Ceiling;
213 int CMetarReport::EstimatedCeiling()
215 return FEET_TO_METER * ((Decoded_METAR *)m_DecodedReport)->Estimated_Ceiling;
218 int CMetarReport::VariableSkyLayerHeight()
220 return FEET_TO_METER * ((Decoded_METAR *)m_DecodedReport)->VrbSkyLayerHgt;
223 int CMetarReport::SnowDepthInches()
225 return ((Decoded_METAR *)m_DecodedReport)->snow_depth;
230 operator << ( ostream& out, CMetarReport& p )
233 << "StationID " << p.StationID()
234 << " WindDirection " << p.WindDirection()
235 << " WindSpeed " << p.WindSpeed()
236 << " WindGustSpeed " << p.WindGustSpeed() << std::endl
237 << "CloudLow " << p.CloudLow()
238 << " CloudMedium " << p.CloudMedium()
239 << " CloudHigh " << p.CloudHigh() << std::endl
240 << "TornadicDirection " << p.TornadicDirection()
241 << " TornadicMovementDirection " << p.TornadicMovementDirection() << std::endl
242 << "ThunderStormDirection " << p.ThunderStormDirection()
243 << " ThunderStormMovementDirection " << p.ThunderStormMovementDirection() << std::endl
244 << "Virga " << p.Virga()
245 << " VirgaDirection " << p.VirgaDirection() << std::endl
246 << "VolcanicAsh " << p.VolcanicAsh() << std::endl
247 << "Hail " << p.Hail() << std::endl
248 << "LightningDirection " << p.LightningDirection()
249 << " OccationalLightning " << p.OccationalLightning()
250 << " FrequentLightning " << p.FrequentLightning()
251 << " ContinuousLightning " << p.ContinuousLightning() << std::endl
252 << "CloudToGroundLightning " << p.CloudToGroundLightning()
253 << " InterCloudLightning " << p.InterCloudLightning()
254 << " CloudToCloudLightning " << p.CloudToCloudLightning()
255 << " CloudToAirLightning " << p.CloudToAirLightning() << std::endl
256 << "DistantLightning " << p.DistantLightning()
257 << " AirportLightning " << p.AirportLightning()
258 << " VicinityLightning " << p.VicinityLightning()
259 << " OverheadLightning " << p.OverheadLightning() << std::endl
260 << "VerticalVisibility " << p.VerticalVisibility() << std::endl // Meters
261 << "Temperature " << p.Temperature()
262 << " DewpointTemperature " << p.DewpointTemperature() << std::endl
263 << "Ceiling " << p.Ceiling()
264 << " EstimatedCeiling " << p.EstimatedCeiling()
265 << " VariableSkyLayerHeight " << p.VariableSkyLayerHeight() << std::endl
266 << "SnowDepthInches " << p.SnowDepthInches() << std::endl
271 double CMetarReport::AirPressure()
273 return ((Decoded_METAR *)m_DecodedReport)->inches_altstng;
276 void CMetarReport::dump()
278 prtDMETR( (Decoded_METAR *)m_DecodedReport );
281 double CMetarReport::PrevailVisibility() {
282 //Values from each visibility field converted to meters.
286 smiles = ((Decoded_METAR*) m_DecodedReport)->prevail_vsbySM * 621 ;
287 km = ((Decoded_METAR*) m_DecodedReport)->prevail_vsbyKM * 1000;
288 meters = ((Decoded_METAR*) m_DecodedReport)->prevail_vsbyM;
290 /* Return the smallest one. If the field is specified it should have been
292 if(smiles < km && smiles < meters)
295 return km < meters ? km : meters;