1
0
Fork 0

Fixes to Christian's latest weather submission.

This commit is contained in:
curt 1999-10-21 22:53:12 +00:00
parent 2751545008
commit adf5011f80
4 changed files with 34 additions and 24 deletions

View file

@ -233,7 +233,7 @@ bool fgInitSubsystems( void ) {
} else if ( current_options.get_flight_model() == FGInterface::FG_JSBSIM ) { } else if ( current_options.get_flight_model() == FGInterface::FG_JSBSIM ) {
cur_fdm_state = new FGJSBsim; cur_fdm_state = new FGJSBsim;
} else if ( current_options.get_flight_model() == } else if ( current_options.get_flight_model() ==
FGInterface::FG_BALLOONSIM ) { FGInterface::FG_BALLOONSIM ) {
cur_fdm_state = new FGBalloonSim; cur_fdm_state = new FGBalloonSim;
} else if ( current_options.get_flight_model() == } else if ( current_options.get_flight_model() ==
FGInterface::FG_MAGICCARPET ) { FGInterface::FG_MAGICCARPET ) {
@ -432,18 +432,21 @@ bool fgInitSubsystems( void ) {
#ifndef FG_OLD_WEATHER #ifndef FG_OLD_WEATHER
// Initialize the WeatherDatabase // Initialize the WeatherDatabase
FG_LOG(FG_GENERAL, FG_INFO, "Creating LocalWeatherDatabase"); FG_LOG(FG_GENERAL, FG_INFO, "Creating LocalWeatherDatabase");
sgVec3 position;
sgSetVec3( position, current_aircraft.fdm_state->get_Latitude(),
current_aircraft.fdm_state->get_Longitude(),
current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER );
FGLocalWeatherDatabase::theFGLocalWeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase =
new FGLocalWeatherDatabase( new FGLocalWeatherDatabase( position );
current_aircraft.fdm_state->get_Latitude(), // cout << theFGLocalWeatherDatabase << endl;
current_aircraft.fdm_state->get_Longitude(), // cout << "visibility = "
current_aircraft.fdm_state->get_Altitude() // << theFGLocalWeatherDatabase->getWeatherVisibility() << endl;
* FEET_TO_METER );
WeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase; WeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase;
// register the periodic update of the weather // register the periodic update of the weather
global_events.Register( "weather update", fgUpdateWeatherDatabase, global_events.Register( "weather update", fgUpdateWeatherDatabase,
fgEVENT::FG_EVENT_READY, 30000); fgEVENT::FG_EVENT_READY, 30000);
#else #else
current_weather.Init(); current_weather.Init();
#endif #endif

View file

@ -93,7 +93,7 @@ void FGLocalWeatherDatabase::tileLocalWeather(const FGPhysicalProperties2DVector
FGLocalWeatherDatabase* FGLocalWeatherDatabase::theFGLocalWeatherDatabase = 0; FGLocalWeatherDatabase* FGLocalWeatherDatabase::theFGLocalWeatherDatabase = 0;
FGLocalWeatherDatabase *WeatherDatabase; FGLocalWeatherDatabase *WeatherDatabase;
FGLocalWeatherDatabase::FGLocalWeatherDatabase(const sgVec3& posititon, const WeatherPrecision visibility, const DatabaseWorkingType type) FGLocalWeatherDatabase::FGLocalWeatherDatabase(const sgVec3& position, const WeatherPrecision visibility, const DatabaseWorkingType type)
{ {
cerr << "Initializing FGLocalWeatherDatabase\n"; cerr << "Initializing FGLocalWeatherDatabase\n";
cerr << "-----------------------------------\n"; cerr << "-----------------------------------\n";
@ -109,7 +109,7 @@ FGLocalWeatherDatabase::FGLocalWeatherDatabase(const sgVec3& posititon, const We
DatabaseStatus = type; DatabaseStatus = type;
global = 0; //just get sure... global = 0; //just get sure...
sgCopyVec3(last_known_position, posititon); sgCopyVec3(last_known_position, position);
theFGLocalWeatherDatabase = this; theFGLocalWeatherDatabase = this;
@ -120,7 +120,7 @@ FGLocalWeatherDatabase::FGLocalWeatherDatabase(const sgVec3& posititon, const We
{ {
global = new FGGlobalWeatherDatabase; //initialize GlobalDatabase global = new FGGlobalWeatherDatabase; //initialize GlobalDatabase
global->setDatabaseStatus(FGGlobalWeatherDatabase_working); global->setDatabaseStatus(FGGlobalWeatherDatabase_working);
tileLocalWeather(global->getAll(posititon, WeatherVisibility, 3)); tileLocalWeather(global->getAll(position, WeatherVisibility, 3));
} }
break; break;

View file

@ -130,21 +130,28 @@ public:
/* Constructor and Destructor */ /* Constructor and Destructor */
/************************************************************************/ /************************************************************************/
FGLocalWeatherDatabase( FGLocalWeatherDatabase(
const sgVec3& posititon, const sgVec3& position,
const WeatherPrecision visibility = DEFAULT_WEATHER_VISIBILIY, const WeatherPrecision visibility = DEFAULT_WEATHER_VISIBILITY,
const DatabaseWorkingType type = PREFERED_WORKING_TYPE); const DatabaseWorkingType type = PREFERED_WORKING_TYPE);
FGLocalWeatherDatabase( FGLocalWeatherDatabase(
const WeatherPrecision posititon_lat, const WeatherPrecision position_lat,
const WeatherPrecision posititon_lon, const WeatherPrecision position_lon,
const WeatherPrecision posititon_alt, const WeatherPrecision position_alt,
const WeatherPrecision visibility = DEFAULT_WEATHER_VISIBILIY, const WeatherPrecision visibility = DEFAULT_WEATHER_VISIBILITY,
const DatabaseWorkingType type = PREFERED_WORKING_TYPE) const DatabaseWorkingType type = PREFERED_WORKING_TYPE)
{ {
sgVec3 position; cout << "This constructor is broken and should *NOT* be used!" << endl;
sgSetVec3( position, posititon_lat, posititon_lon, posititon_alt ); exit(-1);
FGLocalWeatherDatabase( position, visibility, type ); sgVec3 position;
sgSetVec3( position, position_lat, position_lon, position_alt );
// Christian: the following line does not do what you intend.
// It just creates a new FGLocalWeatherDatabase which isn't
// assigned to anything so it is immediately discared.
/* BAD --> */ FGLocalWeatherDatabase( position, visibility, type );
} }
~FGLocalWeatherDatabase(); ~FGLocalWeatherDatabase();
@ -202,10 +209,10 @@ void fgUpdateWeatherDatabase(void);
/****************************************************************************/ /****************************************************************************/
void inline FGLocalWeatherDatabase::setWeatherVisibility(const WeatherPrecision visibility) void inline FGLocalWeatherDatabase::setWeatherVisibility(const WeatherPrecision visibility)
{ {
if (visibility >= MINIMUM_WEATHER_VISIBILIY) if (visibility >= MINIMUM_WEATHER_VISIBILITY)
WeatherVisibility = visibility; WeatherVisibility = visibility;
else else
WeatherVisibility = MINIMUM_WEATHER_VISIBILIY; WeatherVisibility = MINIMUM_WEATHER_VISIBILITY;
//This code doesn't belong here as this is the optical visibility and not //This code doesn't belong here as this is the optical visibility and not
//the visibility of the weather database (that should be bigger...). The //the visibility of the weather database (that should be bigger...). The

View file

@ -54,8 +54,8 @@ HISTORY
typedef float WeatherPrecision; typedef float WeatherPrecision;
//set the minimum visibility to get a at least half way realistic weather //set the minimum visibility to get a at least half way realistic weather
#define MINIMUM_WEATHER_VISIBILIY 10.0 /* metres */ #define MINIMUM_WEATHER_VISIBILITY 10.0 /* metres */
#define DEFAULT_WEATHER_VISIBILIY 32000.0 /* metres */ #define DEFAULT_WEATHER_VISIBILITY 32000.0 /* metres */
//prefered way the database is working //prefered way the database is working
#define PREFERED_WORKING_TYPE default_mode #define PREFERED_WORKING_TYPE default_mode