1
0
Fork 0

Modified to use FGEnvironment as well as WeatherCM.

This commit is contained in:
david 2002-05-11 23:22:24 +00:00
parent ee4c3f728d
commit f8df8ecda9
2 changed files with 47 additions and 20 deletions

View file

@ -23,8 +23,13 @@
#include <Airports/runways.hxx> #include <Airports/runways.hxx>
#include <simgear/misc/sg_path.hxx> #include <simgear/misc/sg_path.hxx>
#include <WeatherCM/FGLocalWeatherDatabase.h>
#ifdef FG_NEW_ENVIRONMENT
#include <Environment/environment_mgr.hxx>
#include <Environment/environment.hxx>
#else
#include <WeatherCM/FGLocalWeatherDatabase.h>
#endif
//Constructor //Constructor
FGApproach::FGApproach(){ FGApproach::FGApproach(){
@ -184,9 +189,11 @@ void FGApproach::Update() {
// ============================================================================ // ============================================================================
void FGApproach::get_active_runway() { void FGApproach::get_active_runway() {
#ifdef FG_NEW_ENVIRONMENT
FGEnvironment stationweather =
globals->get_environment_mgr()->getEnvironment(lat, lon, elev);
#else
sgVec3 position = { lat, lon, elev }; sgVec3 position = { lat, lon, elev };
#ifndef FG_NEW_ENVIRONMENT
FGPhysicalProperty stationweather = WeatherDatabase->get(position); FGPhysicalProperty stationweather = WeatherDatabase->get(position);
#endif #endif
@ -196,13 +203,11 @@ void FGApproach::get_active_runway() {
FGRunways runways( path.c_str() ); FGRunways runways( path.c_str() );
//Set the heading to into the wind //Set the heading to into the wind
#ifndef FG_NEW_ENVIRONMENT #ifdef FG_NEW_ENVIRONMENT
double hdg = stationweather.get_wind_from_heading_deg();
#else
double wind_x = stationweather.Wind[0]; double wind_x = stationweather.Wind[0];
double wind_y = stationweather.Wind[1]; double wind_y = stationweather.Wind[1];
#else
double wind_x = 0;
double wind_y = 0; // FIXME
#endif
double speed = sqrt( wind_x*wind_x + wind_y*wind_y ) * SG_METER_TO_NM / (60.0*60.0); double speed = sqrt( wind_x*wind_x + wind_y*wind_y ) * SG_METER_TO_NM / (60.0*60.0);
double hdg; double hdg;
@ -218,6 +223,7 @@ void FGApproach::get_active_runway() {
if (hdg < 0.0) if (hdg < 0.0)
hdg += 360.0; hdg += 360.0;
} }
#endif
FGRunway runway; FGRunway runway;
if ( runways.search( ident, int(hdg), &runway) ) { if ( runways.search( ident, int(hdg), &runway) ) {

View file

@ -40,12 +40,12 @@ SG_USING_STD(cout);
//#include <simgear/misc/sgstream.hxx> //#include <simgear/misc/sgstream.hxx>
#include <simgear/misc/sg_path.hxx> #include <simgear/misc/sg_path.hxx>
//#ifndef FG_NEW_ENVIRONMENT #ifdef FG_NEW_ENVIRONMENT
//sorry, that works only with the new weather system # include <Environment/environment_mgr.hxx>
# include <Environment/environment.hxx>
#else
# include <WeatherCM/FGLocalWeatherDatabase.h> # include <WeatherCM/FGLocalWeatherDatabase.h>
//#else #endif
//# include <Environment/environment.hxx>
//#endif
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include <Main/globals.hxx> #include <Main/globals.hxx>
@ -135,7 +135,6 @@ void FGATIS::Update() {
// Sets the actual broadcast ATIS transmission. // Sets the actual broadcast ATIS transmission.
void FGATIS::UpdateTransmission() { void FGATIS::UpdateTransmission() {
#if !defined(FG_NEW_ENVIRONMENT)
double visibility; double visibility;
char buf[10]; char buf[10];
int phonetic_id; int phonetic_id;
@ -143,8 +142,14 @@ void FGATIS::UpdateTransmission() {
string time_str = fgGetString("sim/time/gmt-string"); string time_str = fgGetString("sim/time/gmt-string");
int hours; int hours;
// int minutes; // int minutes;
#ifdef FG_NEW_ENVIRONMENT
FGEnvironment stationweather =
globals->get_environment_mgr()->getEnvironment(lat, lon, elev);
#else
sgVec3 position = { lat, lon, elev }; sgVec3 position = { lat, lon, elev };
FGPhysicalProperty stationweather = WeatherDatabase->get(position); FGPhysicalProperty stationweather = WeatherDatabase->get(position);
#endif
transmission = ""; transmission = "";
@ -172,7 +177,11 @@ void FGATIS::UpdateTransmission() {
// Get the temperature // Get the temperature
// (Hardwire it for now since the global property returns the temperature at the current altitude // (Hardwire it for now since the global property returns the temperature at the current altitude
//temperature = fgGetDouble("/environment/weather/temperature-K"); //temperature = fgGetDouble("/environment/weather/temperature-K");
#ifdef FG_NEW_ENVIRONMENT
sprintf(buf, "%i", int(stationweather.get_temperature_degc()));
#else
sprintf(buf, "%i", int(stationweather.Temperature - 273.15)); sprintf(buf, "%i", int(stationweather.Temperature - 273.15));
#endif
transmission += " Temperature "; transmission += " Temperature ";
transmission += buf; transmission += buf;
transmission += " degrees Celsius"; transmission += " degrees Celsius";
@ -181,7 +190,11 @@ void FGATIS::UpdateTransmission() {
// pressure is: stationweather.AirPressure in Pascal // pressure is: stationweather.AirPressure in Pascal
// Get the visibility // Get the visibility
#ifdef FG_NEW_ENVIRONMENT
visibility = stationweather.get_visibility_m();
#else
visibility = fgGetDouble("/environment/visibility-m"); visibility = fgGetDouble("/environment/visibility-m");
#endif
sprintf(buf, "%i", int(visibility/1600)); sprintf(buf, "%i", int(visibility/1600));
transmission += " Visibility "; transmission += " Visibility ";
transmission += buf; transmission += buf;
@ -204,6 +217,18 @@ void FGATIS::UpdateTransmission() {
path.append( "runways.mk4" ); path.append( "runways.mk4" );
FGRunways runways( path.c_str() ); FGRunways runways( path.c_str() );
#ifdef FG_NEW_ENVIRONMENT
double speed = stationweather.get_wind_speed_kt();
double hdg = stationweather.get_wind_from_heading_deg();
if (speed == 0) {
transmission += " Winds light and variable";
} else {
// FIXME: get gust factor in somehow
char buf2[72];
sprintf(buf2, "%s %i %s %i %s", " Winds ", int(speed),
" knots from ", int(hdg), " degrees");
}
#else
//Set the heading to into the wind //Set the heading to into the wind
double wind_x = stationweather.Wind[0]; double wind_x = stationweather.Wind[0];
double wind_y = stationweather.Wind[1]; double wind_y = stationweather.Wind[1];
@ -228,6 +253,7 @@ void FGATIS::UpdateTransmission() {
sprintf(buf2, "%s %i %s %i %s", " Winds ", int(speed), " knots from ", int(hdg), " degrees"); sprintf(buf2, "%s %i %s %i %s", " Winds ", int(speed), " knots from ", int(hdg), " degrees");
transmission += buf2; transmission += buf2;
} }
#endif
string rwy_no = runways.search(ident, int(hdg)); string rwy_no = runways.search(ident, int(hdg));
if(rwy_no != (string)"NN") { if(rwy_no != (string)"NN") {
@ -240,9 +266,4 @@ void FGATIS::UpdateTransmission() {
transmission += " Advise controller on initial contact you have "; transmission += " Advise controller on initial contact you have ";
transmission += phonetic_id_string; transmission += phonetic_id_string;
#else
transmission = "Station unavailable (not supported by FG_NEW_ENVIRONMENT)";
//return "Station unavailable (not supported by FG_NEW_ENVIRONMENT)";
#endif // FG_NEW_ENVIRONMENT
} }