Eberly's spherical interpolation code. This
stops our dependancy on the (ugly) voronoi
code and simplyfies the code structure a lot.
+07.05.2000 Tony Peden Added functionality to get the weather data
+ on 'the bus'
+18.05.2000 Christian Mayer Minor clean-ups. Changed the code to use
+ FGWeatherUtils.h for unit conversion
*****************************************************************************/
/****************************************************************************/
/* INCLUDES */
/****************************************************************************/
-#include <Include/compiler.h>
-#include <Include/fg_constants.h>
+#include <simgear/compiler.h>
+#include <simgear/constants.h>
#include <Aircraft/aircraft.hxx>
#include "FGWeatherParse.h"
+#include "FGWeatherUtils.h"
+
/****************************************************************************/
/********************************** CODE ************************************/
/****************************************************************************/
FGLocalWeatherDatabase* FGLocalWeatherDatabase::theFGLocalWeatherDatabase = 0;
FGLocalWeatherDatabase *WeatherDatabase;
-void FGLocalWeatherDatabase::init(const WeatherPrecision visibility, const DatabaseWorkingType type)
+void FGLocalWeatherDatabase::init( const WeatherPrecision visibility,
+ const DatabaseWorkingType type,
+ const string &root )
{
+ FGPhysicalProperties f[2]; //make an standard weather that's the same at the whole world
+
cerr << "Initializing FGLocalWeatherDatabase\n";
cerr << "-----------------------------------\n";
double x[2] = {0.0, 0.0}; //make an standard weather that's the same at the whole world
double y[2] = {0.0, 0.0}; //make an standard weather that's the same at the whole world
double z[2] = {1.0, -1.0}; //make an standard weather that's the same at the whole world
- FGPhysicalProperties f[2]; //make an standard weather that's the same at the whole world
database = new SphereInterpolate<FGPhysicalProperties>(2,x,y,z,f);
}
break;
/****************************************************************************/
FGPhysicalProperty FGLocalWeatherDatabase::get(const sgVec3& p) const
{
- return FGPhysicalProperty(database->Evaluate(p), p[3]);
+ return FGPhysicalProperty(database->Evaluate(p), p[2]);
}
+#ifdef macintosh
+ /* fix a problem with mw compilers in that they don't know the
+ difference between the next two methods. Since the first one
+ doesn't seem to be used anywhere, I commented it out. This is
+ supposed to be fixed in the forthcoming CodeWarrior Release
+ 6. */
+#else
FGPhysicalProperties FGLocalWeatherDatabase::get(const sgVec2& p) const
{
return database->Evaluate(p);
}
+#endif
WeatherPrecision FGLocalWeatherDatabase::getAirDensity(const sgVec3& p) const
{
- FGPhysicalProperty dummy(database->Evaluate(p), p[3]);
+ FGPhysicalProperty dummy(database->Evaluate(p), p[2]);
return
(dummy.AirPressure*FG_WEATHER_DEFAULT_AIRDENSITY*FG_WEATHER_DEFAULT_TEMPERATURE) /
void fgUpdateWeatherDatabase(void)
{
sgVec3 position;
+ sgVec3 wind;
+
+
sgSetVec3(position,
- current_aircraft.fdm_state->get_Latitude(),
- current_aircraft.fdm_state->get_Longitude(),
- current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER);
-
+ current_aircraft.fdm_state->get_Latitude(),
+ current_aircraft.fdm_state->get_Longitude(),
+ current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER);
+
WeatherDatabase->update( position );
+
+ // get the data on 'the bus' for the FDM
+
+ /* FGPhysicalProperty porperty = WeatherDatabase->get(position);
+
+ current_aircraft.fdm_state->set_Static_temperature( Kelvin2Rankine(porperty.Temperature) );
+ current_aircraft.fdm_state->set_Static_pressure( Pascal2psf(porperty.AirPressure) );
+
+ current_aircraft.fdm_state->set_Density( SIdensity2JSBsim( Density(porperty.AirPressure, porperty.Temperature) ) );
+
+#define MSTOFPS 3.2808 //m/s to ft/s
+ current_aircraft.fdm_state->set_Velocities_Local_Airmass(porperty.Wind[1]*MSTOFPS,
+ porperty.Wind[0]*MSTOFPS,
+ porperty.Wind[2]*MSTOFPS); */
+
+
}