it the default.
/* Define to include Oliver's networking support */
#undef FG_NETWORK_OLK
-/* Define to include Oliver's networking support */
-#undef FG_NEW_WEATHER
+/* Define to avoid Christian's new weather code */
+#undef FG_OLD_WEATHER
/* Define if we are building FGFS (should always be defined) */
#undef FGFS
SERIAL_LIBS =
endif
-if ENABLE_NEW_WEATHER
+if ENABLE_OLD_WEATHER
+WEATHER_LIBS = $(top_builddir)/Simulator/Weather/libWeather.a
+else
WEATHER_LIBS = $(top_builddir)/Simulator/WeatherCM/libWeatherCM.a \
$(top_builddir)/Lib/Voronoi/libVoronoi.a
-else
-WEATHER_LIBS = $(top_builddir)/Simulator/Weather/libWeather.a
endif
#include <Time/sunpos.hxx>
#include <Time/moonpos.hxx>
-#ifdef FG_NEW_WEATHER
+#ifndef FG_OLD_WEATHER
# include <WeatherCM/FGLocalWeatherDatabase.h>
#else
# include <Weather/weather.hxx>
fgEVENT::FG_EVENT_READY, 30000 );
// Initialize the weather modeling subsystem
-#ifdef FG_NEW_WEATHER
+#ifndef FG_OLD_WEATHER
// Initialize the WeatherDatabase
FG_LOG(FG_GENERAL, FG_INFO, "Creating LocalWeatherDatabase");
FGLocalWeatherDatabase::theFGLocalWeatherDatabase =
#include <Time/fg_time.hxx>
#include <Time/light.hxx>
-#ifdef FG_NEW_WEATHER
+#ifndef FG_OLD_WEATHER
# include <WeatherCM/FGLocalWeatherDatabase.h>
#else
# include <Weather/weather.hxx>
v->force_update_fov_math();
return;
case 90: // Z key
-#ifdef FG_NEW_WEATHER
+#ifndef FG_OLD_WEATHER
tmp = WeatherDatabase->getWeatherVisibility();
tmp /= 1.10;
WeatherDatabase->setWeatherVisibility( tmp );
v->force_update_fov_math();
return;
case 122: // z key
-#ifdef FG_NEW_WEATHER
+#ifndef FG_OLD_WEATHER
tmp = WeatherDatabase->getWeatherVisibility();
tmp *= 1.10;
WeatherDatabase->setWeatherVisibility( tmp );
#include <Time/fg_timer.hxx>
#include <Time/sunpos.hxx>
-#ifndef FG_NEW_WEATHER
+#ifdef FG_OLD_WEATHER
# include <Weather/weather.hxx>
#endif
// init routine and we don't have to worry about it again.
#endif
-#ifndef FG_NEW_WEATHER
+#ifdef FG_OLD_WEATHER
current_weather.Update();
#endif
#include <Objects/materialmgr.hxx>
#include <Objects/obj.hxx>
-#ifdef FG_NEW_WEATHER
+#ifndef FG_OLD_WEATHER
# include <WeatherCM/FGLocalWeatherDatabase.h>
#else
# include <Weather/weather.hxx>
if ( t->is_loaded() ) {
// set range selector (LOD trick) to be distance to center
// of tile + bounding radius
-#ifdef FG_NEW_WEATHER
+#ifndef FG_OLD_WEATHER
ranges[1] = WeatherDatabase->getWeatherVisibility()
+ t->bounding_radius;
#else
28.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
08.06.1999 Christian Mayer Added international air preasure formula
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
28.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
28.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+09.10.1999 Christian Mayer changed CloudItem on Durks request
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
/****************************************************************************/
/********************************** CODE ************************************/
/****************************************************************************/
-bool operator<(const FGCloudItem& arg1, const FGCloudItem& arg2)
-{
- return arg1.alt < arg2.alt;
-}
28.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+09.10.1999 Christian Mayer changed CloudItem on Durks request
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
class FGCloudItem
{
private:
+ WeatherPrecition thickness;
+ WeatherPrecition density;
+
protected:
public:
- WeatherPrecition value;
- WeatherPrecition alt;
- FGCloudItem(const WeatherPrecition& a, const WeatherPrecition& v) {alt = a; value = v;}
- FGCloudItem(const WeatherPrecition& v) {alt = 0.0; value = v;}
- FGCloudItem() {alt = 0.0; value = FG_WEATHER_DEFAULT_AIRPRESSURE;}
+ FGCloudItem(const WeatherPrecition& t, const WeatherPrecition& d) {thickness = t; density = d;}
+ FGCloudItem() {thickness = 0.0; density = 0.0;}
- friend bool operator<(const FGCloudItem& arg1, const FGCloudItem& arg2);
+ WeatherPrecition getThickness(void) const { return thickness; }
+ WeatherPrecition getDensity (void) const { return density; }
};
/****************************************************************************/
28.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
if (ret_list.size()<min)
{
- for(i = 0; (i < (min - ret_list.size())) && (ret_list.size() < database.size()); i++)
+ for(i = 0; (i < (int)(min - ret_list.size())) && (ret_list.size() < database.size()); i++)
ret_list.push_back(*it[i]);
}
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
30.06.1999 Christian Mayer STL portability
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
/****************************************************************************/
#include "FGPhysicalProperties.h"
#include "FGPhysicalProperty.h"
+#include "sg.h"
#include <Include/compiler.h>
#include <vector>
#include STL_IOSTREAM
/* Get the physical properties on the specified point p */
/************************************************************************/
FGPhysicalProperties get(const Point2D& p) const;
+ FGPhysicalProperties get(const sgVec2& p) const {return get(Point2D(p[0], p[1]));}
inline FGPhysicalProperty get(const Point3D& p) const {return FGPhysicalProperty(get(Point2D(p)), p.elev());}
+ inline FGPhysicalProperty get(const sgVec3& p) const {return FGPhysicalProperty(get(Point2D(p[0], p[1])), p[3]);}
/************************************************************************/
/* update the database. Since the last call we had dt seconds */
28.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
return global->get(temp);
}
+FGPhysicalProperties FGLocalWeatherDatabase::get(const sgVec2& p) const
+{
+ Point3D temp(p[0], p[1], 0.0);
+
+ unsigned int a = AreaWith(temp);
+ if (a != 0)
+ return WeatherAreas[a-1].get();
+ else //point is outside => ask GlobalWeatherDatabase
+ return global->get(p);
+}
+
WeatherPrecition FGLocalWeatherDatabase::getAirDensity(const Point3D& p) const
{
FGPhysicalProperty dummy;
/****************************************************************************/
/* Add a weather feature at the point p and surrounding area */
/****************************************************************************/
-void FGLocalWeatherDatabase::addWind(const FGWindItem& x, const Point2D& p)
+void FGLocalWeatherDatabase::addWind(const WeatherPrecition alt, const Point3D& x, const Point2D& p)
{
unsigned int a = AreaWith(p);
if (a != 0)
- WeatherAreas[a-1].addWind(x);
+ WeatherAreas[a-1].addWind(alt, x);
}
-void FGLocalWeatherDatabase::addTurbulence(const FGTurbulenceItem& x, const Point2D& p)
+void FGLocalWeatherDatabase::addTurbulence(const WeatherPrecition alt, const Point3D& x, const Point2D& p)
{
unsigned int a = AreaWith(p);
if (a != 0)
- WeatherAreas[a-1].addTurbulence(x);
+ WeatherAreas[a-1].addTurbulence(alt, x);
}
-void FGLocalWeatherDatabase::addTemperature(const FGTemperatureItem& x, const Point2D& p)
+void FGLocalWeatherDatabase::addTemperature(const WeatherPrecition alt, const WeatherPrecition x, const Point2D& p)
{
unsigned int a = AreaWith(p);
if (a != 0)
- WeatherAreas[a-1].addTemperature(x);
+ WeatherAreas[a-1].addTemperature(alt, x);
}
-void FGLocalWeatherDatabase::addAirPressure(const FGAirPressureItem& x, const Point2D& p)
+void FGLocalWeatherDatabase::addAirPressure(const WeatherPrecition alt, const WeatherPrecition x, const Point2D& p)
{
unsigned int a = AreaWith(p);
if (a != 0)
- WeatherAreas[a-1].addAirPressure(x);
+ WeatherAreas[a-1].addAirPressure(alt, x);
}
-void FGLocalWeatherDatabase::addVaporPressure(const FGVaporPressureItem& x, const Point2D& p)
+void FGLocalWeatherDatabase::addVaporPressure(const WeatherPrecition alt, const WeatherPrecition x, const Point2D& p)
{
unsigned int a = AreaWith(p);
if (a != 0)
- WeatherAreas[a-1].addVaporPressure(x);
+ WeatherAreas[a-1].addVaporPressure(alt, x);
}
-void FGLocalWeatherDatabase::addCloud(const FGCloudItem& x, const Point2D& p)
+void FGLocalWeatherDatabase::addCloud(const WeatherPrecition alt, const FGCloudItem& x, const Point2D& p)
{
unsigned int a = AreaWith(p);
if (a != 0)
- WeatherAreas[a-1].addCloud(x);
+ WeatherAreas[a-1].addCloud(alt, x);
}
void FGLocalWeatherDatabase::setSnowRainIntensity(const WeatherPrecition& x, const Point2D& p)
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
30.06.1999 Christian Mayer STL portability
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
/************************************************************************/
FGPhysicalProperty get(const Point3D& p) const;
FGPhysicalProperty get(const sgVec3& p) const;
+ FGPhysicalProperties get(const sgVec2& p) const;
WeatherPrecition getAirDensity(const Point3D& p) const;
WeatherPrecition getAirDensity(const sgVec3& p) const;
/* Add a weather feature at the point p and surrounding area */
/************************************************************************/
- void addWind(const FGWindItem& x, const Point2D& p);
- void addTurbulence(const FGTurbulenceItem& x, const Point2D& p);
- void addTemperature(const FGTemperatureItem& x, const Point2D& p);
- void addAirPressure(const FGAirPressureItem& x, const Point2D& p);
- void addVaporPressure(const FGVaporPressureItem& x, const Point2D& p);
- void addCloud(const FGCloudItem& x, const Point2D& p);
+ void addWind(const WeatherPrecition alt, const Point3D& x, const Point2D& p);
+ void addTurbulence(const WeatherPrecition alt, const Point3D& x, const Point2D& p);
+ void addTemperature(const WeatherPrecition alt, const WeatherPrecition x, const Point2D& p);
+ void addAirPressure(const WeatherPrecition alt, const WeatherPrecition x, const Point2D& p);
+ void addVaporPressure(const WeatherPrecition alt, const WeatherPrecition x, const Point2D& p);
+ void addCloud(const WeatherPrecition alt, const FGCloudItem& x, const Point2D& p);
void setSnowRainIntensity(const WeatherPrecition& x, const Point2D& p);
void setSnowRainType(const SnowRainType& x, const Point2D& p);
28.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
/* Add the features to the micro weather */
/* return succss */
/****************************************************************************/
-void FGMicroWeather::addWind(const FGWindItem& x)
+void FGMicroWeather::addWind(const WeatherPrecition alt, const Point3D& x)
{
- StoredWeather.Wind.insert(x);
+ StoredWeather.Wind[alt] = x;
}
-void FGMicroWeather::addTurbulence(const FGTurbulenceItem& x)
+void FGMicroWeather::addTurbulence(const WeatherPrecition alt, const Point3D& x)
{
- StoredWeather.Turbulence.insert(x);
+ StoredWeather.Turbulence[alt] = x;
}
-void FGMicroWeather::addTemperature(const FGTemperatureItem& x)
+void FGMicroWeather::addTemperature(const WeatherPrecition alt, const WeatherPrecition x)
{
- StoredWeather.Temperature.insert(x);
+ StoredWeather.Temperature[alt] = x;
}
-void FGMicroWeather::addAirPressure(const FGAirPressureItem& x)
+void FGMicroWeather::addAirPressure(const WeatherPrecition alt, const WeatherPrecition x)
{
cerr << "Error: caught attempt to add AirPressure which is logical wrong\n";
- //StoredWeather.AirPressure.insert(x);
+ //StoredWeather.AirPressure[alt] = x;
}
-void FGMicroWeather::addVaporPressure(const FGVaporPressureItem& x)
+void FGMicroWeather::addVaporPressure(const WeatherPrecition alt, const WeatherPrecition x)
{
- StoredWeather.VaporPressure.insert(x);
+ StoredWeather.VaporPressure[alt] = x;
}
-void FGMicroWeather::addCloud(const FGCloudItem& x)
+void FGMicroWeather::addCloud(const WeatherPrecition alt, const FGCloudItem& x)
{
- StoredWeather.Clouds.insert(x);
+ StoredWeather.Clouds[alt] = x;
}
void FGMicroWeather::setSnowRainIntensity(const WeatherPrecition& x)
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
30.06.1999 Christian Mayer STL portability
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
/************************************************************************/
/* Add a feature to the micro weather */
/************************************************************************/
- void addWind(const FGWindItem& x);
- void addTurbulence(const FGTurbulenceItem& x);
- void addTemperature(const FGTemperatureItem& x);
- void addAirPressure(const FGAirPressureItem& x);
- void addVaporPressure(const FGVaporPressureItem& x);
- void addCloud(const FGCloudItem& x);
+ void addWind(const WeatherPrecition alt, const Point3D& x);
+ void addTurbulence(const WeatherPrecition alt, const Point3D& x);
+ void addTemperature(const WeatherPrecition alt, const WeatherPrecition x);
+ void addAirPressure(const WeatherPrecition alt, const WeatherPrecition x);
+ void addVaporPressure(const WeatherPrecition alt, const WeatherPrecition x);
+ void addCloud(const WeatherPrecition alt, const FGCloudItem& x);
void setSnowRainIntensity(const WeatherPrecition& x);
void setSnowRainType(const SnowRainType& x);
return FGPhysicalProperty(StoredWeather, altitude);
}
+ inline FGPhysicalProperties get(void) const
+ {
+ return FGPhysicalProperties();
+ }
+
/************************************************************************/
/* return true if p is inside this micro weather */
/************************************************************************/
29.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
/* This standart constructor fills the class with a standard weather */
/************************************************************************/
- Wind.insert(FGWindItem(-1000.0, Point3D(0.0))); //no Wind by default
- Wind.insert(FGWindItem(10000.0, Point3D(0.0))); //no Wind by default
+ Wind[-1000.0] = Point3D(0.0); //no Wind by default
+ Wind[10000.0] = Point3D(0.0); //no Wind by default
- Turbulence.insert(FGTurbulenceItem(-1000.0, Point3D(0.0))); //no Turbulence by default
- Turbulence.insert(FGTurbulenceItem(10000.0, Point3D(0.0))); //no Turbulence by default
+ Turbulence[-1000.0] = Point3D(0.0); //no Turbulence by default
+ Turbulence[10000.0] = Point3D(0.0); //no Turbulence by default
//Initialice with the CINA atmosphere
- Temperature.insert(FGTemperatureItem( 0.0, (+15.0+273.16)));
- Temperature.insert(FGTemperatureItem(11000.0, (-56.5+273.16)));
- Temperature.insert(FGTemperatureItem(20000.0, (-56.5+273.16)));
+ Temperature[ 0.0] = +15.0 + 273.16;
+ Temperature[11000.0] = -56.5 + 273.16;
+ Temperature[20000.0] = -56.5 + 273.16;
AirPressure = FGAirPressureItem(101325.0);
- VaporPressure.insert(FGVaporPressureItem( 0.0, FG_WEATHER_DEFAULT_VAPORPRESSURE)); //in Pa (I *only* accept SI!)
- VaporPressure.insert(FGVaporPressureItem(10000.0, FG_WEATHER_DEFAULT_VAPORPRESSURE)); //in Pa (I *only* accept SI!)
+ VaporPressure[ 0.0] = FG_WEATHER_DEFAULT_VAPORPRESSURE; //in Pa (I *only* accept SI!)
+ VaporPressure[10000.0] = FG_WEATHER_DEFAULT_VAPORPRESSURE; //in Pa (I *only* accept SI!)
//Clouds.insert(FGCloudItem()) => none
SnowRainIntensity = 0.0;
LightningProbability = 0.0;
}
+unsigned int FGPhysicalProperties::getNumberOfCloudLayers(void) const
+{
+ return Clouds.size();
+}
+
+FGCloudItem FGPhysicalProperties::getCloudLayer(unsigned int nr) const
+{
+ map<WeatherPrecition,FGCloudItem>::const_iterator CloudsIt = Clouds.begin();
+
+ //set the iterator to the 'nr'th entry
+ for (; nr > 0; nr--)
+ CloudsIt++;
+
+ return CloudsIt->second;
+}
+
+
20.06.1999 Christian Mayer Changed struct to class
20.06.1999 Christian Mayer added lots of consts
30.06.1999 Christian Mayer STL portability
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
/****************************************************************************/
#include <Include/compiler.h>
#include <vector>
-#include <set>
+#include <map>
FG_USING_STD(vector);
-FG_USING_STD(set);
+FG_USING_STD(map);
FG_USING_NAMESPACE(std);
#include <Math/point3d.hxx>
#include <Voronoi/point2d.h>
#include "FGWeatherDefs.h"
-#include "FGWindItem.h"
-#include "FGTurbulenceItem.h"
-#include "FGTemperatureItem.h"
#include "FGAirPressureItem.h"
-#include "FGVaporPressureItem.h"
#include "FGCloudItem.h"
#include "FGSnowRain.h"
class FGPhysicalProperties
{
public:
- set<FGWindItem> Wind; //all Wind vectors
- set<FGTurbulenceItem> Turbulence; //all Turbulence vectors
- set<FGTemperatureItem> Temperature; //in deg. Kelvin (I *only* accept SI!)
- FGAirPressureItem AirPressure; //in Pascal (I *only* accept SI!)
- set<FGVaporPressureItem> VaporPressure; //in Pascal (I *only* accept SI!)
+ typedef WeatherPrecition Altitude;
+
+ map<Altitude,Point3D> Wind; //all Wind vectors
+ map<Altitude,Point3D> Turbulence; //all Turbulence vectors
+ map<Altitude,WeatherPrecition> Temperature; //in deg. Kelvin (I *only* accept SI!)
+ FGAirPressureItem AirPressure; //in Pascal (I *only* accept SI!)
+ map<Altitude,WeatherPrecition> VaporPressure; //in Pascal (I *only* accept SI!)
+
+ map<Altitude,FGCloudItem> Clouds; //amount of covering and type
- set<FGCloudItem> Clouds; //amount of covering and type
WeatherPrecition SnowRainIntensity; //this also stands for hail, snow,...
SnowRainType snowRainType;
WeatherPrecition LightningProbability;
WeatherPrecition TemperatureAt(const WeatherPrecition& a) const;
WeatherPrecition AirPressureAt(const WeatherPrecition& a) const;
WeatherPrecition VaporPressureAt(const WeatherPrecition& a) const;
+
+ //for easier access to the cloud stuff:
+ unsigned int getNumberOfCloudLayers(void) const;
+ FGCloudItem getCloudLayer(unsigned int nr) const;
FGPhysicalProperties& operator = ( const FGPhysicalProperties& p );
FGPhysicalProperties& operator *= ( const WeatherPrecition& d );
inline ostream& operator<< ( ostream& out, const FGPhysicalProperties2D& p )
{
- out << "Position: " << p.p << "\nStored Wind: ";
- for (set<FGWindItem>::const_iterator WindIt = p.Wind.begin(); WindIt != p.Wind.end(); WindIt++)
- out << "(" << WindIt->getValue() << ") at " << WindIt->getAlt() << "m; ";
-
- out << "\nStored Turbulence: ";
- for (set<FGTurbulenceItem>::const_iterator TurbulenceIt = p.Turbulence.begin();
- TurbulenceIt != p.Turbulence.end();
- TurbulenceIt++)
- out << "(" << TurbulenceIt->getValue() << ") at " << TurbulenceIt->getAlt() << "m; ";
-
- out << "\nStored Temperature: ";
- for (set<FGTemperatureItem>::const_iterator TemperatureIt = p.Temperature.begin();
- TemperatureIt != p.Temperature.end();
- TemperatureIt++)
- out << TemperatureIt->getValue() << " at " << TemperatureIt->getAlt() << "m; ";
-
- out << "\nStored AirPressure: ";
- out << p.AirPressure.getValue(0) << " at " << 0 << "m; ";
-
- out << "\nStored VaporPressure: ";
- for (set<FGVaporPressureItem>::const_iterator VaporPressureIt = p.VaporPressure.begin();
- VaporPressureIt != p.VaporPressure.end();
- VaporPressureIt++)
- out << VaporPressureIt->getValue() << " at " << VaporPressureIt->getAlt() << "m; ";
-
- return out << "\n";
+ typedef map<FGPhysicalProperties::Altitude, Point3D >::const_iterator vector_iterator;
+ typedef map<FGPhysicalProperties::Altitude, WeatherPrecition>::const_iterator scalar_iterator;
+
+ out << "Position: " << p.p << endl;
+
+ out << "Stored Wind: ";
+ for (vector_iterator WindIt = p.Wind.begin();
+ WindIt != p.Wind.end();
+ WindIt++)
+ out << "(" << WindIt->first << ") at " << WindIt->second << "m; ";
+ out << endl;
+
+ out << "Stored Turbulence: ";
+ for (vector_iterator TurbulenceIt = p.Turbulence.begin();
+ TurbulenceIt != p.Turbulence.end();
+ TurbulenceIt++)
+ out << "(" << TurbulenceIt->first << ") at " << TurbulenceIt->second << "m; ";
+ out << endl;
+
+ out << "Stored Temperature: ";
+ for (scalar_iterator TemperatureIt = p.Temperature.begin();
+ TemperatureIt != p.Temperature.end();
+ TemperatureIt++)
+ out << TemperatureIt->first << " at " << TemperatureIt->second << "m; ";
+ out << endl;
+
+ out << "Stored AirPressure: ";
+ out << p.AirPressure.getValue(0) << " at " << 0.0 << "m; ";
+ out << endl;
+
+ out << "Stored VaporPressure: ";
+ for (scalar_iterator VaporPressureIt = p.VaporPressure.begin();
+ VaporPressureIt != p.VaporPressure.end();
+ VaporPressureIt++)
+ out << VaporPressureIt->first << " at " << VaporPressureIt->second << "m; ";
+ out << endl;
+
+ return out << endl;
}
inline FGPhysicalProperties& FGPhysicalProperties::operator *= ( const WeatherPrecition& d )
{
+ typedef map<FGPhysicalProperties::Altitude, Point3D >::iterator vector_iterator;
+ typedef map<FGPhysicalProperties::Altitude, WeatherPrecition>::iterator scalar_iterator;
- for (set<FGWindItem>::iterator WindIt = Wind.begin();
- WindIt != Wind.end();
- WindIt++)
- *WindIt *= d;
+ for (vector_iterator WindIt = Wind.begin();
+ WindIt != Wind.end();
+ WindIt++)
+ WindIt->second *= d;
- for (set<FGTurbulenceItem>::iterator TurbulenceIt = Turbulence.begin();
- TurbulenceIt != Turbulence.end();
- TurbulenceIt++)
- *TurbulenceIt *= d;
+ for (vector_iterator TurbulenceIt = Turbulence.begin();
+ TurbulenceIt != Turbulence.end();
+ TurbulenceIt++)
+ TurbulenceIt->second *= d;
- for (set<FGTemperatureItem>::iterator TemperatureIt = Temperature.begin();
- TemperatureIt != Temperature.end();
- TemperatureIt++)
- *TemperatureIt *= d;
+ for (scalar_iterator TemperatureIt = Temperature.begin();
+ TemperatureIt != Temperature.end();
+ TemperatureIt++)
+ TemperatureIt->second *= d;
AirPressure *= d;
- for (set<FGVaporPressureItem>::iterator VaporPressureIt = VaporPressure.begin();
- VaporPressureIt != VaporPressure.end();
- VaporPressureIt++)
- *VaporPressureIt *= d;
+ for (scalar_iterator VaporPressureIt = VaporPressure.begin();
+ VaporPressureIt != VaporPressure.end();
+ VaporPressureIt++)
+ VaporPressureIt->second *= d;
return *this;
}
inline FGPhysicalProperties& FGPhysicalProperties::operator += (const FGPhysicalProperties& p)
{
- for (set<FGWindItem>::const_iterator WindIt = p.Wind.begin();
- WindIt != p.Wind.end();
- WindIt++ )
- if (WindIt != Wind.upper_bound( FGWindItem(WindIt->getAlt(), Point3D(0)) ))
- Wind.insert(*WindIt);
- else
- *(Wind.upper_bound( FGWindItem(WindIt->getAlt(), Point3D(0))) ) += WindIt->getValue();
+ typedef map<FGPhysicalProperties::Altitude, Point3D >::const_iterator vector_iterator;
+ typedef map<FGPhysicalProperties::Altitude, WeatherPrecition>::const_iterator scalar_iterator;
+
+ for (vector_iterator WindIt = p.Wind.begin();
+ WindIt != p.Wind.end();
+ WindIt++ )
+ if (!Wind.insert(*WindIt).second) //when it's not inserted => it's already existing
+ Wind[WindIt->first] += WindIt->second; //=> add the value
- for (set<FGTurbulenceItem>::const_iterator TurbulenceIt = p.Turbulence.begin();
- TurbulenceIt != p.Turbulence.end();
- TurbulenceIt++)
- if (TurbulenceIt != Turbulence.upper_bound( FGTurbulenceItem(TurbulenceIt->getAlt(), Point3D(0)) ))
- Turbulence.insert(*TurbulenceIt);
- else
- *(Turbulence.upper_bound( FGTurbulenceItem(TurbulenceIt->getAlt(), Point3D(0)) )) += TurbulenceIt->getValue();
+ for (vector_iterator TurbulenceIt = p.Turbulence.begin();
+ TurbulenceIt != p.Turbulence.end();
+ TurbulenceIt++)
+ if (!Turbulence.insert(*TurbulenceIt).second)
+ Turbulence[TurbulenceIt->first] += TurbulenceIt->second;
- for (set<FGTemperatureItem>::const_iterator TemperatureIt = p.Temperature.begin();
- TemperatureIt != p.Temperature.end();
- TemperatureIt++)
- if (TemperatureIt != Temperature.upper_bound( FGTemperatureItem(TemperatureIt->getAlt(), 0.0) ))
- Temperature.insert(*TemperatureIt);
- else
- *(Temperature.upper_bound( FGTemperatureItem(TemperatureIt->getAlt(), 0.0) )) += TemperatureIt->getValue();
+ for (scalar_iterator TemperatureIt = p.Temperature.begin();
+ TemperatureIt != p.Temperature.end();
+ TemperatureIt++)
+ if (!Temperature.insert(*TemperatureIt).second)
+ Temperature[TemperatureIt->first] += TemperatureIt->second;
AirPressure += p.AirPressure.getValue(0.0);
- for (set<FGVaporPressureItem>::const_iterator VaporPressureIt = p.VaporPressure.begin();
- VaporPressureIt != p.VaporPressure.end();
- VaporPressureIt++)
- if (VaporPressureIt != VaporPressure.upper_bound( FGVaporPressureItem(VaporPressureIt->getAlt(), 0.0) ))
- VaporPressure.insert(*VaporPressureIt);
- else
- *(VaporPressure.upper_bound( FGVaporPressureItem(VaporPressureIt->getAlt(), 0.0) )) += VaporPressureIt->getValue();
+ for (scalar_iterator VaporPressureIt = p.VaporPressure.begin();
+ VaporPressureIt != p.VaporPressure.end();
+ VaporPressureIt++)
+ if (!VaporPressure.insert(*VaporPressureIt).second)
+ VaporPressure[VaporPressureIt->first] += VaporPressureIt->second;
return *this;
}
inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysicalProperties& p)
{
-
- for (set<FGWindItem>::const_iterator WindIt = p.Wind.begin();
- WindIt != p.Wind.end();
- WindIt++)
- if (WindIt != Wind.upper_bound( FGWindItem(WindIt->getAlt(), Point3D(0)) ))
- Wind.insert(-(*WindIt));
- else
- *(Wind.upper_bound( FGWindItem(WindIt->getAlt(), Point3D(0)) )) -= WindIt->getValue();
+ typedef map<FGPhysicalProperties::Altitude, Point3D >::const_iterator vector_iterator;
+ typedef map<FGPhysicalProperties::Altitude, WeatherPrecition>::const_iterator scalar_iterator;
+
+ for (vector_iterator WindIt = p.Wind.begin();
+ WindIt != p.Wind.end();
+ WindIt++ )
+ if (!Wind.insert( make_pair(WindIt->first, -WindIt->second) ).second) //when it's not inserted => it's already existing
+ Wind[WindIt->first] -= WindIt->second; //=> substract the value
- for (set<FGTurbulenceItem>::const_iterator TurbulenceIt = p.Turbulence.begin();
- TurbulenceIt != p.Turbulence.end();
- TurbulenceIt++)
- if (TurbulenceIt != Turbulence.upper_bound( FGTurbulenceItem(TurbulenceIt->getAlt(), Point3D(0)) ))
- Turbulence.insert(-(*TurbulenceIt));
- else
- *(Turbulence.upper_bound( FGTurbulenceItem(TurbulenceIt->getAlt(), Point3D(0)) )) -= TurbulenceIt->getValue();
+ for (vector_iterator TurbulenceIt = p.Turbulence.begin();
+ TurbulenceIt != p.Turbulence.end();
+ TurbulenceIt++)
+ if (!Turbulence.insert( make_pair(TurbulenceIt->first, -TurbulenceIt->second) ).second)
+ Turbulence[TurbulenceIt->first] -= TurbulenceIt->second;
- for (set<FGTemperatureItem>::const_iterator TemperatureIt = p.Temperature.begin();
- TemperatureIt != p.Temperature.end();
- TemperatureIt++)
- if (TemperatureIt != Temperature.upper_bound( FGTemperatureItem(TemperatureIt->getAlt(), 0.0) ))
- Temperature.insert(-(*TemperatureIt));
- else
- *(Temperature.upper_bound( FGTemperatureItem(TemperatureIt->getAlt(), 0.0) )) -= TemperatureIt->getValue();
+ for (scalar_iterator TemperatureIt = p.Temperature.begin();
+ TemperatureIt != p.Temperature.end();
+ TemperatureIt++)
+ if (!Temperature.insert( make_pair(TemperatureIt->first, -TemperatureIt->second) ).second)
+ Temperature[TemperatureIt->first] -= TemperatureIt->second;
AirPressure -= p.AirPressure.getValue(0.0);
- for (set<FGVaporPressureItem>::const_iterator VaporPressureIt = p.VaporPressure.begin();
- VaporPressureIt != p.VaporPressure.end();
- VaporPressureIt++)
- if (VaporPressureIt != VaporPressure.upper_bound( FGVaporPressureItem(VaporPressureIt->getAlt(), 0.0) ))
- VaporPressure.insert(-(*VaporPressureIt));
- else
- *(VaporPressure.upper_bound( FGVaporPressureItem(VaporPressureIt->getAlt(), 0.0) )) -= VaporPressureIt->getValue();
+ for (scalar_iterator VaporPressureIt = p.VaporPressure.begin();
+ VaporPressureIt != p.VaporPressure.end();
+ VaporPressureIt++)
+ if (!VaporPressure.insert( make_pair(VaporPressureIt->first, -VaporPressureIt->second) ).second)
+ VaporPressure[VaporPressureIt->first] -= VaporPressureIt->second;
+
return *this;
}
inline Point3D FGPhysicalProperties::WindAt(const WeatherPrecition& a) const
{
- set<FGWindItem>::const_iterator it = Wind.lower_bound(FGWindItem(a, Point3D(0)));
- set<FGWindItem>::const_iterator it2 = it;
+ typedef map<FGPhysicalProperties::Altitude, Point3D>::const_iterator vector_iterator;
+
+ vector_iterator it = Wind.lower_bound(a);
+ vector_iterator it2 = it;
it--;
//now I've got it->alt < a < it2->alt so I can interpolate
- return ( (it2->getValue() - it->getValue())/(it2->getAlt() - it->getAlt()) )*
- (a - it2->getAlt()) +
- it2->getValue();
+ return ( (it2->second - it->second)/(it2->first - it->first) ) * (a - it2->first) + it2->second;
}
inline Point3D FGPhysicalProperties::TurbulenceAt(const WeatherPrecition& a) const
{
- set<FGTurbulenceItem>::const_iterator it = Turbulence.lower_bound(FGTurbulenceItem(a, Point3D(0)));
- set<FGTurbulenceItem>::const_iterator it2 = it;
+ typedef map<FGPhysicalProperties::Altitude, Point3D>::const_iterator vector_iterator;
+
+ vector_iterator it = Turbulence.lower_bound(a);
+ vector_iterator it2 = it;
it--;
//now I've got it->alt < a < it2->alt so I can interpolate
- return ( (it2->getValue() - it->getValue() )/(it2->getAlt() - it->getAlt()) )*
- (a - it2->getAlt())+ it2->getValue();
+ return ( (it2->second - it->second)/(it2->first - it->first) ) * (a - it2->first) + it2->second;
}
inline WeatherPrecition FGPhysicalProperties::TemperatureAt(const WeatherPrecition& a) const
{
- set<FGTemperatureItem>::const_iterator it = Temperature.lower_bound(FGTemperatureItem(a, 0));
- set<FGTemperatureItem>::const_iterator it2 = it;
+ typedef map<FGPhysicalProperties::Altitude, WeatherPrecition>::const_iterator scalar_iterator;
+
+ scalar_iterator it = Temperature.lower_bound(a);
+ scalar_iterator it2 = it;
it--;
//now I've got it->alt < a < it2->alt so I can interpolate
- return ( (it2->getValue() - it->getValue()) / (it2->getAlt() - it->getAlt()) )*
- (a - it2->getAlt() )+ it2->getValue();
+ return ( (it2->second - it->second)/(it2->first - it->first) ) * (a - it2->first) + it2->second;
}
inline WeatherPrecition FGPhysicalProperties::AirPressureAt(const WeatherPrecition& a) const
inline WeatherPrecition FGPhysicalProperties::VaporPressureAt(const WeatherPrecition& a) const
{
- set<FGVaporPressureItem>::const_iterator it = VaporPressure.lower_bound(FGVaporPressureItem(a, 0));
- set<FGVaporPressureItem>::const_iterator it2 = it;
+ typedef map<FGPhysicalProperties::Altitude, WeatherPrecition>::const_iterator scalar_iterator;
+
+ scalar_iterator it = VaporPressure.lower_bound(a);
+ scalar_iterator it2 = it;
it--;
//now I've got it->alt < a < it2->alt so I can interpolate
- return ( (it2->getValue() - it->getValue() ) / (it2->getAlt() - it->getAlt() ) ) *
- (a - it2->getAlt() )+ it2->getValue();
+ return ( (it2->second - it->second)/(it2->first - it->first) ) * (a - it2->first) + it2->second;
}
-inline FGPhysicalProperties operator * (const FGPhysicalProperties& a, const WeatherPrecition& b)
+inline FGPhysicalProperties operator * (FGPhysicalProperties a, const WeatherPrecition& b)
{
- return FGPhysicalProperties(a) *= b;
+ return a *= b;
}
-inline FGPhysicalProperties operator * (const WeatherPrecition& b, const FGPhysicalProperties& a)
+inline FGPhysicalProperties operator * (const WeatherPrecition& b, FGPhysicalProperties a)
{
- return FGPhysicalProperties(a) *= b;
+ return a *= b;
}
-inline FGPhysicalProperties operator + (const FGPhysicalProperties& a, const FGPhysicalProperties& b)
+inline FGPhysicalProperties operator + (FGPhysicalProperties a, const FGPhysicalProperties& b)
{
- return FGPhysicalProperties(a) += (FGPhysicalProperties)b;
+ return a += b;
}
-inline FGPhysicalProperties operator - (const FGPhysicalProperties& a, const FGPhysicalProperties& b)
+inline FGPhysicalProperties operator - (FGPhysicalProperties a, const FGPhysicalProperties& b)
{
- return FGPhysicalProperties(a) -= (FGPhysicalProperties)b;
+ return a -= b;
}
/****************************************************************************/
29.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
20.06.1999 Christian Mayer Changed struct to class
20.06.1999 Christian Mayer added lots of consts
30.06.1999 Christian Mayer STL portability
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
28.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
28.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
28.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+10.10.1999 Christian Mayer added mutable for gcc 2.95 portability
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
/* INCLUDES */
/****************************************************************************/
#include "FGWeatherDefs.h"
+
+//for the case that mutable isn't supported:
+#include "Include/compiler.h"
/****************************************************************************/
/* DEFINES */
class FGTemperatureItem
{
private:
- WeatherPrecition value;
+ mutable WeatherPrecition value;
WeatherPrecition alt;
protected:
28.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
28.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+10.10.1999 Christian Mayer added mutable for gcc 2.95 portability
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
/****************************************************************************/
#include <Math/point3d.hxx>
#include "FGWeatherDefs.h"
+
+//for the case that mutable isn't supported:
+#include "Include/compiler.h"
/****************************************************************************/
/* DEFINES */
class FGTurbulenceItem
{
private:
- Point3D value;
+ mutable Point3D value;
WeatherPrecition alt;
protected:
28.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
28.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+10.10.1999 Christian Mayer added mutable for gcc 2.95 portability
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
/* INCLUDES */
/****************************************************************************/
#include "FGWeatherDefs.h"
+
+//for the case that mutable isn't supported:
+#include "Include/compiler.h"
/****************************************************************************/
/* DEFINES */
class FGVaporPressureItem
{
private:
- WeatherPrecition value;
+ mutable WeatherPrecition value;
WeatherPrecition alt;
protected:
------------------------------------------------------------------------------
30.05.99 Christian Mayer Created
16.06.99 Durk Talsma Portability for Linux
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
30.06.1999 Christian Mayer STL portability
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
28.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
30.06.1999 Christian Mayer STL portability
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
08.06.1999 Christian Mayer Changed sat_vp
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
28.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
28.05.1999 Christian Mayer Created
16.06.1999 Durk Talsma Portability for Linux
20.06.1999 Christian Mayer added lots of consts
+10.10.1999 Christian Mayer added mutable for gcc 2.95 portability
+11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
+ suggestion
*****************************************************************************/
/****************************************************************************/
/****************************************************************************/
#include <Math/point3d.hxx>
#include "FGWeatherDefs.h"
+
+//for the case that mutable isn't supported:
+#include "Include/compiler.h"
/****************************************************************************/
/* DEFINES */
class FGWindItem
{
private:
- Point3D value;
+ mutable Point3D value;
WeatherPrecition alt;
protected: