// Metar report implementation class code
+#include <simgear/compiler.h>
+
+#include STL_IOSTREAM
+
#include "MetarReport.h"
#include "Metar.h"
+SG_USING_STD(endl);
+SG_USING_STD(ostream);
+
CMetarReport::CMetarReport(
char *s ) :
m_DecodedReport( 0 )
if ( c[1] == 'E' ) r = 45;
else if ( c[1] == 'W' ) r = 315;
}
- else if ( r = 180 )
+ else if ( r == 180 )
{
if ( c[1] == 'E' ) r = 135;
else if ( c[1] == 'W' ) r = 225;
return ((Decoded_METAR *)m_DecodedReport)->stnid;
}
+int CMetarReport::Day()
+{
+ return ((Decoded_METAR*)m_DecodedReport)->ob_date;
+}
+
+int CMetarReport::Hour()
+{
+ return ((Decoded_METAR*)m_DecodedReport)->ob_hour;
+}
+
+int CMetarReport::Minutes()
+{
+ return ((Decoded_METAR*)m_DecodedReport)->ob_minute;
+}
+
int CMetarReport::WindDirection()
{
return ((Decoded_METAR *)m_DecodedReport)->winData.windDir;
int CMetarReport::Ceiling()
{
- return FEET_TO_METER * ((Decoded_METAR *)m_DecodedReport)->Ceiling;
+ return
+ (int)(SG_FEET_TO_METER*((Decoded_METAR *)m_DecodedReport)->Ceiling);
}
int CMetarReport::EstimatedCeiling()
{
- return FEET_TO_METER * ((Decoded_METAR *)m_DecodedReport)->Estimated_Ceiling;
+ return
+ (int)(SG_FEET_TO_METER
+ * ((Decoded_METAR *)m_DecodedReport)->Estimated_Ceiling);
}
int CMetarReport::VariableSkyLayerHeight()
{
- return FEET_TO_METER * ((Decoded_METAR *)m_DecodedReport)->VrbSkyLayerHgt;
+ return
+ (int)(SG_FEET_TO_METER
+ * ((Decoded_METAR *)m_DecodedReport)->VrbSkyLayerHgt);
}
int CMetarReport::SnowDepthInches()
}
-std::ostream&
+ostream&
operator << ( ostream& out, CMetarReport& p )
{
return out
<< "StationID " << p.StationID()
<< " WindDirection " << p.WindDirection()
<< " WindSpeed " << p.WindSpeed()
- << " WindGustSpeed " << p.WindGustSpeed() << std::endl
+ << " WindGustSpeed " << p.WindGustSpeed() << endl
<< "CloudLow " << p.CloudLow()
<< " CloudMedium " << p.CloudMedium()
- << " CloudHigh " << p.CloudHigh() << std::endl
+ << " CloudHigh " << p.CloudHigh() << endl
<< "TornadicDirection " << p.TornadicDirection()
- << " TornadicMovementDirection " << p.TornadicMovementDirection() << std::endl
+ << " TornadicMovementDirection " << p.TornadicMovementDirection() << endl
<< "ThunderStormDirection " << p.ThunderStormDirection()
- << " ThunderStormMovementDirection " << p.ThunderStormMovementDirection() << std::endl
+ << " ThunderStormMovementDirection " << p.ThunderStormMovementDirection() << endl
<< "Virga " << p.Virga()
- << " VirgaDirection " << p.VirgaDirection() << std::endl
- << "VolcanicAsh " << p.VolcanicAsh() << std::endl
- << "Hail " << p.Hail() << std::endl
+ << " VirgaDirection " << p.VirgaDirection() << endl
+ << "VolcanicAsh " << p.VolcanicAsh() << endl
+ << "Hail " << p.Hail() << endl
<< "LightningDirection " << p.LightningDirection()
<< " OccationalLightning " << p.OccationalLightning()
<< " FrequentLightning " << p.FrequentLightning()
- << " ContinuousLightning " << p.ContinuousLightning() << std::endl
+ << " ContinuousLightning " << p.ContinuousLightning() << endl
<< "CloudToGroundLightning " << p.CloudToGroundLightning()
<< " InterCloudLightning " << p.InterCloudLightning()
<< " CloudToCloudLightning " << p.CloudToCloudLightning()
- << " CloudToAirLightning " << p.CloudToAirLightning() << std::endl
+ << " CloudToAirLightning " << p.CloudToAirLightning() << endl
<< "DistantLightning " << p.DistantLightning()
<< " AirportLightning " << p.AirportLightning()
<< " VicinityLightning " << p.VicinityLightning()
- << " OverheadLightning " << p.OverheadLightning() << std::endl
- << "VerticalVisibility " << p.VerticalVisibility() << std::endl // Meters
+ << " OverheadLightning " << p.OverheadLightning() << endl
+ << "VerticalVisibility " << p.VerticalVisibility() << endl // Meters
<< "Temperature " << p.Temperature()
- << " DewpointTemperature " << p.DewpointTemperature() << std::endl
+ << " DewpointTemperature " << p.DewpointTemperature() << endl
<< "Ceiling " << p.Ceiling()
<< " EstimatedCeiling " << p.EstimatedCeiling()
- << " VariableSkyLayerHeight " << p.VariableSkyLayerHeight() << std::endl
- << "SnowDepthInches " << p.SnowDepthInches() << std::endl
+ << " VariableSkyLayerHeight " << p.VariableSkyLayerHeight() << endl
+ << "SnowDepthInches " << p.SnowDepthInches() << endl
;
}
+double CMetarReport::AirPressure()
+{
+ return ((Decoded_METAR *)m_DecodedReport)->inches_altstng;
+}
+
void CMetarReport::dump()
{
prtDMETR( (Decoded_METAR *)m_DecodedReport );
}
+
+double CMetarReport::PrevailVisibility()
+{
+ //Values from each visibility field converted to meters.
+ double smiles;
+ double km;
+ double meters;
+ smiles = ((Decoded_METAR*) m_DecodedReport)->prevail_vsbySM * 1609.34;
+ km = ((Decoded_METAR*) m_DecodedReport)->prevail_vsbyKM * 1000;
+ meters = ((Decoded_METAR*) m_DecodedReport)->prevail_vsbyM;
+
+ /* Return the smallest one. If the field is specified it should have been
+ set to MAX_INT */
+ if(smiles < km && smiles < meters)
+ return smiles;
+ else
+ return km < meters ? km : meters;
+}