]> git.mxchange.org Git - simgear.git/blobdiff - simgear/metar/MetarReport.cpp
MacOS X fixes
[simgear.git] / simgear / metar / MetarReport.cpp
index c8a9b5a06b3b355a769e4fd5d41e2666473c4d24..57107b5e70aa5459a7047da6ec10ff808d0ec905 100644 (file)
@@ -1,8 +1,15 @@
 // 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 )
@@ -31,7 +38,7 @@ static int DecodeDirChars( char* c )
                        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;
@@ -207,17 +214,22 @@ int CMetarReport::VerticalVisibility() // Meters
 
 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()
@@ -226,51 +238,51 @@ 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() 
+double CMetarReport::AirPressure()
 {
-  return ((Decoded_METAR *)m_DecodedReport)->inches_altstng;
+    return ((Decoded_METAR *)m_DecodedReport)->inches_altstng;
 }
 
 void CMetarReport::dump()
@@ -278,12 +290,13 @@ void CMetarReport::dump()
        prtDMETR( (Decoded_METAR *)m_DecodedReport );
 }
 
-double CMetarReport::PrevailVisibility() {
+double CMetarReport::PrevailVisibility()
+{
   //Values from each visibility field converted to meters.
   double smiles;
   double km;
   double meters;
-  smiles = ((Decoded_METAR*) m_DecodedReport)->prevail_vsbySM  * 621 ;
+  smiles = ((Decoded_METAR*) m_DecodedReport)->prevail_vsbySM * 1609.34;
   km =  ((Decoded_METAR*) m_DecodedReport)->prevail_vsbyKM * 1000;
   meters =  ((Decoded_METAR*) m_DecodedReport)->prevail_vsbyM;