diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 8d24d47d9..ac3916ed3 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -233,7 +233,7 @@ bool fgInitSubsystems( void ) { } else if ( current_options.get_flight_model() == FGInterface::FG_JSBSIM ) { cur_fdm_state = new FGJSBsim; } else if ( current_options.get_flight_model() == - FGInterface::FG_BALLOONSIM ) { + FGInterface::FG_BALLOONSIM ) { cur_fdm_state = new FGBalloonSim; } else if ( current_options.get_flight_model() == FGInterface::FG_MAGICCARPET ) { @@ -432,18 +432,21 @@ bool fgInitSubsystems( void ) { #ifndef FG_OLD_WEATHER // Initialize the WeatherDatabase 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 = - new FGLocalWeatherDatabase( - current_aircraft.fdm_state->get_Latitude(), - current_aircraft.fdm_state->get_Longitude(), - current_aircraft.fdm_state->get_Altitude() - * FEET_TO_METER ); + new FGLocalWeatherDatabase( position ); + // cout << theFGLocalWeatherDatabase << endl; + // cout << "visibility = " + // << theFGLocalWeatherDatabase->getWeatherVisibility() << endl; WeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase; - + // register the periodic update of the weather global_events.Register( "weather update", fgUpdateWeatherDatabase, - fgEVENT::FG_EVENT_READY, 30000); + fgEVENT::FG_EVENT_READY, 30000); #else current_weather.Init(); #endif diff --git a/src/WeatherCM/FGLocalWeatherDatabase.cpp b/src/WeatherCM/FGLocalWeatherDatabase.cpp index f88e87b7e..6dd14c86b 100644 --- a/src/WeatherCM/FGLocalWeatherDatabase.cpp +++ b/src/WeatherCM/FGLocalWeatherDatabase.cpp @@ -93,7 +93,7 @@ void FGLocalWeatherDatabase::tileLocalWeather(const FGPhysicalProperties2DVector FGLocalWeatherDatabase* FGLocalWeatherDatabase::theFGLocalWeatherDatabase = 0; 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 << "-----------------------------------\n"; @@ -109,7 +109,7 @@ FGLocalWeatherDatabase::FGLocalWeatherDatabase(const sgVec3& posititon, const We DatabaseStatus = type; global = 0; //just get sure... - sgCopyVec3(last_known_position, posititon); + sgCopyVec3(last_known_position, position); theFGLocalWeatherDatabase = this; @@ -120,7 +120,7 @@ FGLocalWeatherDatabase::FGLocalWeatherDatabase(const sgVec3& posititon, const We { global = new FGGlobalWeatherDatabase; //initialize GlobalDatabase global->setDatabaseStatus(FGGlobalWeatherDatabase_working); - tileLocalWeather(global->getAll(posititon, WeatherVisibility, 3)); + tileLocalWeather(global->getAll(position, WeatherVisibility, 3)); } break; diff --git a/src/WeatherCM/FGLocalWeatherDatabase.h b/src/WeatherCM/FGLocalWeatherDatabase.h index dcd6c016b..3ca680727 100644 --- a/src/WeatherCM/FGLocalWeatherDatabase.h +++ b/src/WeatherCM/FGLocalWeatherDatabase.h @@ -130,21 +130,28 @@ public: /* Constructor and Destructor */ /************************************************************************/ FGLocalWeatherDatabase( - const sgVec3& posititon, - const WeatherPrecision visibility = DEFAULT_WEATHER_VISIBILIY, + const sgVec3& position, + const WeatherPrecision visibility = DEFAULT_WEATHER_VISIBILITY, const DatabaseWorkingType type = PREFERED_WORKING_TYPE); FGLocalWeatherDatabase( - const WeatherPrecision posititon_lat, - const WeatherPrecision posititon_lon, - const WeatherPrecision posititon_alt, - const WeatherPrecision visibility = DEFAULT_WEATHER_VISIBILIY, + const WeatherPrecision position_lat, + const WeatherPrecision position_lon, + const WeatherPrecision position_alt, + const WeatherPrecision visibility = DEFAULT_WEATHER_VISIBILITY, const DatabaseWorkingType type = PREFERED_WORKING_TYPE) { - sgVec3 position; - sgSetVec3( position, posititon_lat, posititon_lon, posititon_alt ); + cout << "This constructor is broken and should *NOT* be used!" << endl; + 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(); @@ -202,10 +209,10 @@ void fgUpdateWeatherDatabase(void); /****************************************************************************/ void inline FGLocalWeatherDatabase::setWeatherVisibility(const WeatherPrecision visibility) { - if (visibility >= MINIMUM_WEATHER_VISIBILIY) + if (visibility >= MINIMUM_WEATHER_VISIBILITY) WeatherVisibility = visibility; else - WeatherVisibility = MINIMUM_WEATHER_VISIBILIY; + WeatherVisibility = MINIMUM_WEATHER_VISIBILITY; //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 diff --git a/src/WeatherCM/FGWeatherDefs.h b/src/WeatherCM/FGWeatherDefs.h index 49a6c774f..f1476b0c8 100644 --- a/src/WeatherCM/FGWeatherDefs.h +++ b/src/WeatherCM/FGWeatherDefs.h @@ -54,8 +54,8 @@ HISTORY typedef float WeatherPrecision; //set the minimum visibility to get a at least half way realistic weather -#define MINIMUM_WEATHER_VISIBILIY 10.0 /* metres */ -#define DEFAULT_WEATHER_VISIBILIY 32000.0 /* metres */ +#define MINIMUM_WEATHER_VISIBILITY 10.0 /* metres */ +#define DEFAULT_WEATHER_VISIBILITY 32000.0 /* metres */ //prefered way the database is working #define PREFERED_WORKING_TYPE default_mode