#define _ENVIRONMENT_CTRL_HXX
#include <simgear/compiler.h>
+#include <simgear/structure/subsystem_mgr.hxx>
#ifdef SG_HAVE_STD_INCLUDES
# include <cmath>
# include <math.h>
#endif
+#include <vector>
+
+SG_USING_STD(vector);
+
class SGPropertyNode;
#include "environment.hxx"
/**
* Interface to control environment information for a specific location.
*/
-class FGEnvironmentCtrl
+class FGEnvironmentCtrl : public SGSubsystem
{
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;
};
+
+\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;
+};
+
+
#endif // _ENVIRONMENT_CTRL_HXX