diff --git a/projects/VC90/FlightGear/FlightGear.vcproj b/projects/VC90/FlightGear/FlightGear.vcproj
index 7661650cf..ce1edc982 100644
--- a/projects/VC90/FlightGear/FlightGear.vcproj
+++ b/projects/VC90/FlightGear/FlightGear.vcproj
@@ -3485,6 +3485,14 @@
RelativePath="..\..\..\src\Environment\ridge_lift.hxx"
>
+
+
+
+
+
+#include
+#include
+
+#include
+#include
+
+Ephemeris::Ephemeris() :
+ _impl(NULL),
+ _latProp(NULL)
+{
+}
+
+Ephemeris::~Ephemeris()
+{
+ delete _impl;
+}
+
+void Ephemeris::init()
+{
+ if (_impl) {
+ return;
+ }
+
+ SGPath ephem_data_path(globals->get_fg_root());
+ ephem_data_path.append("Astro");
+ _impl = new SGEphemeris(ephem_data_path.c_str());
+ globals->set_ephem(_impl);
+}
+
+void Ephemeris::postinit()
+{
+ update(0.0);
+}
+
+static void tieStar(const char* prop, Star* s, double (Star::*getter)() const)
+{
+ fgGetNode(prop, true)->tie(SGRawValueMethods(*s, getter, NULL));
+}
+
+void Ephemeris::bind()
+{
+ _latProp = fgGetNode("/position/latitude-deg", true);
+
+ tieStar("/ephemeris/sun/xs", _impl->get_sun(), &Star::getxs);
+ tieStar("/ephemeris/sun/ys", _impl->get_sun(), &Star::getys);
+ tieStar("/ephemeris/sun/ze", _impl->get_sun(), &Star::getze);
+ tieStar("/ephemeris/sun/ye", _impl->get_sun(), &Star::getye);
+
+ tieStar("/ephemeris/sun/lat-deg", _impl->get_sun(), &Star::getLat);
+}
+
+void Ephemeris::unbind()
+{
+}
+
+void Ephemeris::update(double)
+{
+ SGTime* st = globals->get_time_params();
+ _impl->update(st->getMjd(), st->getLst(), _latProp->getDoubleValue());
+}
diff --git a/src/Environment/ephemeris.hxx b/src/Environment/ephemeris.hxx
new file mode 100644
index 000000000..3a03de5c3
--- /dev/null
+++ b/src/Environment/ephemeris.hxx
@@ -0,0 +1,31 @@
+#ifndef FG_ENVIRONMENT_EPHEMERIS_HXX
+#define FG_ENVIRONMENT_EPHEMERIS_HXX
+
+#include
+
+class SGEphemeris;
+class SGPropertyNode;
+
+/**
+ * Wrap SGEphemeris in a susbsytem/property interface
+ */
+class Ephemeris : public SGSubsystem
+{
+public:
+
+ Ephemeris();
+ ~Ephemeris();
+
+ virtual void bind();
+ virtual void unbind();
+ virtual void update(double dt);
+ virtual void init();
+ virtual void postinit();
+
+private:
+ SGEphemeris* _impl;
+ SGPropertyNode* _latProp;
+};
+
+#endif // of FG_ENVIRONMENT_EPHEMERIS_HXX
+
diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx
index da3de6a46..1ae7c81d2 100644
--- a/src/Main/globals.cxx
+++ b/src/Main/globals.cxx
@@ -131,7 +131,6 @@ FGGlobals::~FGGlobals()
delete subsystem_mgr;
delete event_mgr;
delete time_params;
- delete ephem;
delete mag;
delete matlib;
delete route_mgr;
diff --git a/src/Main/main.cxx b/src/Main/main.cxx
index 679c0e0b5..edf2f84e4 100644
--- a/src/Main/main.cxx
+++ b/src/Main/main.cxx
@@ -41,7 +41,6 @@
#include
// Class references
-#include
#include
#include
#include
@@ -71,6 +70,7 @@
#include
#include