suggestion
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
and lots of wee code cleaning
+15.12.1999 Christian Mayer changed the air pressure calculation to a much
+ more realistic formula. But as I need for that
+ the temperature I moved the code to
+ FGPhysicalProperties
*****************************************************************************/
/****************************************************************************/
# 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>
-#include "sg.h"
+#include <plib/sg.h>
#include "FGWeatherDefs.h"
#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 */
map<Altitude,FGCloudItem> Clouds; //amount of covering and type
- WeatherPrecision SnowRainIntensity; //this also stands for hail, snow,...
+ WeatherPrecision SnowRainIntensity; //this also stands for hail, snow,...
SnowRainType snowRainType;
- WeatherPrecision LightningProbability;
+ WeatherPrecision LightningProbability; //in lightnings per second
FGPhysicalProperties(); //consructor to fill it with FG standart weather
void WindAt (sgVec3 ret, const WeatherPrecision a) const;
void TurbulenceAt (sgVec3 ret, const WeatherPrecision a) const;
WeatherPrecision TemperatureAt (const WeatherPrecision a) const;
- WeatherPrecision AirPressureAt (const WeatherPrecision a) const;
+ WeatherPrecision AirPressureAt (const WeatherPrecision x) const; //x is used here instead of a on purpose
WeatherPrecision VaporPressureAt(const WeatherPrecision a) const;
//for easier access to the cloud stuff:
typedef FGPhysicalProperties2DVector::iterator FGPhysicalProperties2DVectorIt;
typedef FGPhysicalProperties2DVector::const_iterator FGPhysicalProperties2DVectorConstIt;
-inline ostream& operator<< ( ostream& out, const FGPhysicalProperties2D& 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;
-
- out << "Position: (" << p.p[0] << ", " << p.p[1] << ", " << p.p[2] << ")\n";
-
- out << "Stored Wind: ";
- for (wind_iterator WindIt = p.Wind.begin();
- WindIt != p.Wind.end();
- WindIt++)
- out << "(" << WindIt->first << ") at (" << WindIt->second.x() << ", " << WindIt->second.y() << ", " << WindIt->second.z() << ") m; ";
- out << "\n";
-
- out << "Stored Turbulence: ";
- for (turbulence_iterator TurbulenceIt = p.Turbulence.begin();
- TurbulenceIt != p.Turbulence.end();
- TurbulenceIt++)
- out << "(" << TurbulenceIt->first << ") at (" << TurbulenceIt->second.x() << ", " << TurbulenceIt->second.y() << ", " << TurbulenceIt->second.z() << ") m; ";
- out << "\n";
-
- out << "Stored Temperature: ";
- for (scalar_iterator TemperatureIt = p.Temperature.begin();
- TemperatureIt != p.Temperature.end();
- TemperatureIt++)
- out << TemperatureIt->first << " at " << TemperatureIt->second << "m; ";
- out << "\n";
-
- out << "Stored AirPressure: ";
- out << p.AirPressure.getValue(0) << " at " << 0.0 << "m; ";
- out << "\n";
-
- out << "Stored VaporPressure: ";
- for (scalar_iterator VaporPressureIt = p.VaporPressure.begin();
- VaporPressureIt != p.VaporPressure.end();
- VaporPressureIt++)
- out << VaporPressureIt->first << " at " << VaporPressureIt->second << "m; ";
- out << "\n";
-
- return out << "\n";
-}
inline FGPhysicalProperties& FGPhysicalProperties::operator = ( const FGPhysicalProperties& p )
if (!Temperature.insert(*TemperatureIt).second)
Temperature[TemperatureIt->first] += TemperatureIt->second;
- AirPressure += p.AirPressure.getValue(0.0);
+ AirPressure += p.AirPressure.getValue();
for (scalar_iterator VaporPressureIt = p.VaporPressure.begin();
VaporPressureIt != p.VaporPressure.end();
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;
if (!Temperature.insert( make_pair(TemperatureIt->first, -TemperatureIt->second) ).second)
Temperature[TemperatureIt->first] -= TemperatureIt->second;
- AirPressure -= p.AirPressure.getValue(0.0);
+ AirPressure -= p.AirPressure.getValue();
for (scalar_iterator VaporPressureIt = p.VaporPressure.begin();
VaporPressureIt != p.VaporPressure.end();
return *this;
}
-
+#endif
inline void FGPhysicalProperties::WindAt(sgVec3 ret, const WeatherPrecision a) const
{
return ( (it2->second - it->second)/(it2->first - it->first) ) * (a - it2->first) + it2->second;
}
-inline WeatherPrecision FGPhysicalProperties::AirPressureAt(const WeatherPrecision a) const
-{
- return AirPressure.getValue(a);
-}
+//inline WeatherPrecision FGPhysicalProperties::AirPressureAt(const WeatherPrecision x) const
+//moved to FGPhysicalProperties.cpp as it got too complex to inline
inline WeatherPrecision FGPhysicalProperties::VaporPressureAt(const WeatherPrecision a) const
{