]> git.mxchange.org Git - flightgear.git/blobdiff - src/WeatherCM/FGPhysicalProperties.h
Moved JSBSim.hxx to src/FDM/JSBSim/
[flightgear.git] / src / WeatherCM / FGPhysicalProperties.h
index 35b2fa5f28f590e9ee7f796a07d7d8c34392ba47..1e20e35ce85dbd33ab6c319a993e80f0b29ddad7 100644 (file)
@@ -57,13 +57,13 @@ HISTORY
 #  include <config.h>
 #endif
 
-#include <Include/compiler.h>
+#include <simgear/compiler.h>
 
 #ifdef HAVE_WINDOWS_H
 #  include <windows.h>
 #endif
 
-#include <iostream>
+#include STL_IOSTREAM
 #include <vector>
 #include <map>
 
@@ -78,9 +78,9 @@ HISTORY
 #include "FGCloudItem.h"
 #include "FGSnowRain.h"
 
-FG_USING_STD(vector);
-FG_USING_STD(map);
-FG_USING_NAMESPACE(std);
+SG_USING_STD(vector);
+SG_USING_STD(map);
+SG_USING_NAMESPACE(std);
 
 /****************************************************************************/
 /* FOREWARD DEFINITIONS                                                            */
@@ -229,6 +229,49 @@ inline FGPhysicalProperties& FGPhysicalProperties::operator += (const FGPhysical
     return *this;
 }
 
+// slightly modified version that also makes the Mac happy
+inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysicalProperties& p)
+{
+    typedef map<FGPhysicalProperties::Altitude, FGWindItem>::const_iterator wind_iterator;
+    typedef map<FGPhysicalProperties::Altitude, FGTurbulenceItem>::const_iterator turbulence_iterator;
+    typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::const_iterator scalar_iterator;
+    
+    // types to replace make_pair
+    typedef map<FGPhysicalProperties::Altitude, FGWindItem>::value_type wind_type;
+    typedef map<FGPhysicalProperties::Altitude,        FGTurbulenceItem>::value_type turb_type;
+    typedef map<FGPhysicalProperties::Altitude,        WeatherPrecision>::value_type weather_type;
+    
+    for (wind_iterator WindIt = p.Wind.begin();
+        WindIt != p.Wind.end();
+        WindIt++)
+       if (!Wind.insert( wind_type(WindIt->first, -WindIt->second) ).second)
+           // when it's not inserted => it's already existing
+           Wind[WindIt->first] -= WindIt->second; //=> substract the value
+
+    for (turbulence_iterator TurbulenceIt = p.Turbulence.begin();
+        TurbulenceIt != p.Turbulence.end();
+        TurbulenceIt++)
+       if (!Turbulence.insert( turb_type(TurbulenceIt->first, -TurbulenceIt->second) ).second)
+           Turbulence[TurbulenceIt->first] -= TurbulenceIt->second;
+    
+    for (scalar_iterator TemperatureIt = p.Temperature.begin();
+        TemperatureIt != p.Temperature.end();
+        TemperatureIt++)
+       if (!Temperature.insert( weather_type(TemperatureIt->first, -TemperatureIt->second) ).second)
+           Temperature[TemperatureIt->first] -= TemperatureIt->second;
+    
+    AirPressure -= p.AirPressure.getValue();
+    
+    for (scalar_iterator VaporPressureIt = p.VaporPressure.begin();
+        VaporPressureIt != p.VaporPressure.end();
+        VaporPressureIt++)
+       if (!VaporPressure.insert( weather_type(VaporPressureIt->first, -VaporPressureIt->second) ).second)
+           VaporPressure[VaporPressureIt->first] -= VaporPressureIt->second;
+
+    return *this;
+}
+
+#if 0 // old version
 inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysicalProperties& p)
 {
     typedef map<FGPhysicalProperties::Altitude, FGWindItem      >::const_iterator wind_iterator;
@@ -264,6 +307,7 @@ inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysical
 
     return *this;
 }
+#endif
 
 inline void FGPhysicalProperties::WindAt(sgVec3 ret, const WeatherPrecision a) const
 {