From f8df8ecda911d1fdb0708aa72e20bdab6172eb2b Mon Sep 17 00:00:00 2001 From: david Date: Sat, 11 May 2002 23:22:24 +0000 Subject: [PATCH] Modified to use FGEnvironment as well as WeatherCM. --- src/ATC/approach.cxx | 22 ++++++++++++++-------- src/ATC/atis.cxx | 45 ++++++++++++++++++++++++++++++++------------ 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/src/ATC/approach.cxx b/src/ATC/approach.cxx index dee810903..5c2e6431f 100644 --- a/src/ATC/approach.cxx +++ b/src/ATC/approach.cxx @@ -23,8 +23,13 @@ #include #include -#include +#ifdef FG_NEW_ENVIRONMENT +#include +#include +#else +#include +#endif //Constructor FGApproach::FGApproach(){ @@ -184,9 +189,11 @@ void FGApproach::Update() { // ============================================================================ 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 }; - -#ifndef FG_NEW_ENVIRONMENT FGPhysicalProperty stationweather = WeatherDatabase->get(position); #endif @@ -196,13 +203,11 @@ void FGApproach::get_active_runway() { FGRunways runways( path.c_str() ); //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_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 hdg; @@ -218,6 +223,7 @@ void FGApproach::get_active_runway() { if (hdg < 0.0) hdg += 360.0; } +#endif FGRunway runway; if ( runways.search( ident, int(hdg), &runway) ) { diff --git a/src/ATC/atis.cxx b/src/ATC/atis.cxx index 8c1be3ce4..67b378e67 100644 --- a/src/ATC/atis.cxx +++ b/src/ATC/atis.cxx @@ -40,12 +40,12 @@ SG_USING_STD(cout); //#include #include -//#ifndef FG_NEW_ENVIRONMENT -//sorry, that works only with the new weather system -#include -//#else -//# include -//#endif +#ifdef FG_NEW_ENVIRONMENT +# include +# include +#else +# include +#endif #include
#include
@@ -135,7 +135,6 @@ void FGATIS::Update() { // Sets the actual broadcast ATIS transmission. void FGATIS::UpdateTransmission() { -#if !defined(FG_NEW_ENVIRONMENT) double visibility; char buf[10]; int phonetic_id; @@ -143,8 +142,14 @@ void FGATIS::UpdateTransmission() { string time_str = fgGetString("sim/time/gmt-string"); int hours; // int minutes; + +#ifdef FG_NEW_ENVIRONMENT + FGEnvironment stationweather = + globals->get_environment_mgr()->getEnvironment(lat, lon, elev); +#else sgVec3 position = { lat, lon, elev }; FGPhysicalProperty stationweather = WeatherDatabase->get(position); +#endif transmission = ""; @@ -172,7 +177,11 @@ void FGATIS::UpdateTransmission() { // Get the temperature // (Hardwire it for now since the global property returns the temperature at the current altitude //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)); +#endif transmission += " Temperature "; transmission += buf; transmission += " degrees Celsius"; @@ -181,7 +190,11 @@ void FGATIS::UpdateTransmission() { // pressure is: stationweather.AirPressure in Pascal // Get the visibility +#ifdef FG_NEW_ENVIRONMENT + visibility = stationweather.get_visibility_m(); +#else visibility = fgGetDouble("/environment/visibility-m"); +#endif sprintf(buf, "%i", int(visibility/1600)); transmission += " Visibility "; transmission += buf; @@ -204,6 +217,18 @@ void FGATIS::UpdateTransmission() { path.append( "runways.mk4" ); 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 double wind_x = stationweather.Wind[0]; 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"); transmission += buf2; } +#endif string rwy_no = runways.search(ident, int(hdg)); if(rwy_no != (string)"NN") { @@ -240,9 +266,4 @@ void FGATIS::UpdateTransmission() { transmission += " Advise controller on initial contact you have "; 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 } -- 2.39.5