1 #include <Environment/ephemeris.hxx>
3 #include <simgear/timing/sg_time.hxx>
4 #include <simgear/ephemeris/ephemeris.hxx>
6 #include <Main/globals.hxx>
7 #include <Main/fg_props.hxx>
9 Ephemeris::Ephemeris() :
15 Ephemeris::~Ephemeris()
20 void Ephemeris::init()
26 SGPath ephem_data_path(globals->get_fg_root());
27 ephem_data_path.append("Astro");
28 _impl = new SGEphemeris(ephem_data_path.c_str());
29 globals->set_ephem(_impl);
32 void Ephemeris::postinit()
37 static void tieStar(const char* prop, Star* s, double (Star::*getter)() const)
39 fgGetNode(prop, true)->tie(SGRawValueMethods<Star, double>(*s, getter, NULL));
42 void Ephemeris::bind()
44 _latProp = fgGetNode("/position/latitude-deg", true);
46 tieStar("/ephemeris/sun/xs", _impl->get_sun(), &Star::getxs);
47 tieStar("/ephemeris/sun/ys", _impl->get_sun(), &Star::getys);
48 tieStar("/ephemeris/sun/ze", _impl->get_sun(), &Star::getze);
49 tieStar("/ephemeris/sun/ye", _impl->get_sun(), &Star::getye);
51 tieStar("/ephemeris/sun/lat-deg", _impl->get_sun(), &Star::getLat);
54 void Ephemeris::unbind()
58 void Ephemeris::update(double)
60 SGTime* st = globals->get_time_params();
61 _impl->update(st->getMjd(), st->getLst(), _latProp->getDoubleValue());