]> git.mxchange.org Git - flightgear.git/blobdiff - src/Environment/environment_ctrl.hxx
ignore resets for now because every z/Z key press would trigger a call to NOAA. We...
[flightgear.git] / src / Environment / environment_ctrl.hxx
index 17ed581d79a131b4154ba248797304c5c0c0cda5..d22e30641496a8d2abb0dc01fa08f4f16cd517df 100644 (file)
@@ -24,6 +24,8 @@
 #define _ENVIRONMENT_CTRL_HXX
 
 #include <simgear/compiler.h>
+#include <simgear/structure/subsystem_mgr.hxx>
+#include <simgear/environment/metar.hxx>
 
 #ifdef SG_HAVE_STD_INCLUDES
 #  include <cmath>
 #  include <math.h>
 #endif
 
+#include <vector>
+
+SG_USING_STD(vector);
+
 class SGPropertyNode;
 
 #include "environment.hxx"
@@ -40,7 +46,7 @@ class SGPropertyNode;
 /**
  * Interface to control environment information for a specific location.
  */
-class FGEnvironmentCtrl
+class FGEnvironmentCtrl : public SGSubsystem
 {
 
 public:
@@ -61,9 +67,6 @@ public:
   virtual double getLatitudeDeg () const { return _lat_deg; }
   virtual double getElevationFt () const { return _elev_ft; }
 
-  virtual void init () = 0;
-  virtual void update (double dt) = 0;
-
 protected:
 
   FGEnvironment * _environment;
@@ -97,4 +100,61 @@ private:
 
 };
 
+
+\f
+/**
+ * Interplation controller using user-supplied parameters.
+ */
+class FGInterpolateEnvironmentCtrl : public FGEnvironmentCtrl
+{
+public:
+    FGInterpolateEnvironmentCtrl ();
+    virtual ~FGInterpolateEnvironmentCtrl ();
+    
+    virtual void init ();
+    virtual void reinit ();
+    virtual void update (double delta_time_sec);
+
+private:
+    
+    struct bucket {
+        double altitude_ft;
+        FGEnvironment environment;
+        bool operator< (const bucket &b) const;
+    };
+
+    void read_table (const SGPropertyNode * node, vector<bucket *> &table);
+    void do_interpolate (vector<bucket *> &table, double altitude_ft,
+                         FGEnvironment * environment);
+
+    FGEnvironment env1, env2;   // temporaries
+
+    vector<bucket *> _boundary_table;
+    vector<bucket *> _aloft_table;
+};
+
+
+\f
+/**
+ * Interplation controller using the SGMetar class
+ */
+class FGMetarEnvironmentCtrl : public FGEnvironmentCtrl
+{
+public:
+    FGMetarEnvironmentCtrl ();
+    virtual ~FGMetarEnvironmentCtrl ();
+
+    virtual void init ();
+    virtual void reinit ();
+    virtual void update (double delta_time_sec);
+
+    virtual void setEnvironment (FGEnvironment * environment);
+
+private:
+    FGInterpolateEnvironmentCtrl *env;
+
+    char *_icao;
+    void fetch_data (const char *icao);
+};
+
 #endif // _ENVIRONMENT_CTRL_HXX