]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/atis.cxx
More efficient rotation matrix calc from Norm Vine.
[flightgear.git] / src / ATC / atis.cxx
index 8c1be3ce422dcff5bdaaf219ac499863e2ab4f8f..d2225410e4f1e04b4a7e350a5f98b830cfa2c117 100644 (file)
@@ -40,12 +40,12 @@ SG_USING_STD(cout);
 //#include <simgear/misc/sgstream.hxx>
 #include <simgear/misc/sg_path.hxx>
 
-//#ifndef FG_NEW_ENVIRONMENT
-//sorry, that works only with the new weather system
-#include <WeatherCM/FGLocalWeatherDatabase.h>
-//#else
-//#  include <Environment/environment.hxx>
-//#endif
+#ifdef FG_WEATHERCM
+# include <WeatherCM/FGLocalWeatherDatabase.h>
+#else
+# include <Environment/environment_mgr.hxx>
+# include <Environment/environment.hxx>
+#endif
 
 #include <Main/fg_props.hxx>
 #include <Main/globals.hxx>
@@ -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_WEATHERCM
     sgVec3 position = { lat, lon, elev };
     FGPhysicalProperty stationweather = WeatherDatabase->get(position);
+#else
+    FGEnvironment stationweather =
+      globals->get_environment_mgr()->getEnvironment(lat, lon, elev);
+#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_WEATHERCM
     sprintf(buf, "%i", int(stationweather.Temperature - 273.15));
+#else
+    sprintf(buf, "%i", int(stationweather.get_temperature_degc()));
+#endif
     transmission += "  Temperature ";
     transmission += buf;
     transmission += " degrees Celsius";
@@ -181,15 +190,22 @@ void FGATIS::UpdateTransmission() {
         // pressure is: stationweather.AirPressure in Pascal
 
        // Get the visibility
+#ifdef FG_WEATHERCM
        visibility = fgGetDouble("/environment/visibility-m");
+#else
+        visibility = stationweather.get_visibility_m();
+#endif
        sprintf(buf, "%i", int(visibility/1600));
        transmission += "  Visibility ";
        transmission += buf;
        transmission += " miles";
 
        // Get the cloudbase
-       if(fgGetBool("/environment/clouds/status")) {
-           double cloudbase = fgGetDouble("/environment/clouds/altitude-ft");
+       // FIXME: kludge for now
+       if (!strcmp(fgGetString("/environment/clouds/layer[0]/type"),
+                   "clear")) {
+           double cloudbase =
+             fgGetDouble("/environment/clouds/layer[0]/elevation-ft");
            // For some reason the altitude returned doesn't seem to correspond to the actual cloud altitude.
            char buf3[10];
            // cout << "cloudbase = " << cloudbase << endl;
@@ -204,6 +220,7 @@ void FGATIS::UpdateTransmission() {
        path.append( "runways.mk4" );
        FGRunways runways( path.c_str() );
 
+#ifdef FG_WEATHERCM
        //Set the heading to into the wind
         double wind_x = stationweather.Wind[0];
         double wind_y = stationweather.Wind[1];
@@ -228,6 +245,18 @@ void FGATIS::UpdateTransmission() {
            sprintf(buf2, "%s %i %s %i %s", "  Winds ", int(speed), " knots from ", int(hdg), " degrees");
            transmission += buf2;
        }
+#else
+       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");
+       }
+#endif
 
        string rwy_no = runways.search(ident, int(hdg));
        if(rwy_no != (string)"NN") {
@@ -240,9 +269,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
 }