1
// ephemeris.cxx -- wrap SGEphemeris code in a subsystem
3
// Written by James Turner, started June 2010.
5
// Copyright (C) 2010 Curtis L. Olson - http://www.flightgear.org/~curt
7
// This program is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU General Public License as
9
// published by the Free Software Foundation; either version 2 of the
10
// License, or (at your option) any later version.
12
// This program is distributed in the hope that it will be useful, but
13
// WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
// General Public License for more details.
17
// You should have received a copy of the GNU General Public License
18
// along with this program; if not, write to the Free Software
19
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
#include <Environment/ephemeris.hxx>
25
#include <simgear/timing/sg_time.hxx>
26
#include <simgear/ephemeris/ephemeris.hxx>
28
#include <Main/globals.hxx>
29
#include <Main/fg_props.hxx>
31
Ephemeris::Ephemeris() :
37
Ephemeris::~Ephemeris()
42
void Ephemeris::init()
48
SGPath ephem_data_path(globals->get_fg_root());
49
ephem_data_path.append("Astro");
50
_impl = new SGEphemeris(ephem_data_path.c_str());
51
globals->set_ephem(_impl);
53
_latProp = fgGetNode("/position/latitude-deg", true);
57
void Ephemeris::postinit()
62
static void tieStar(const char* prop, Star* s, double (Star::*getter)() const)
64
fgGetNode(prop, true)->tie(SGRawValueMethods<Star, double>(*s, getter, NULL));
67
void Ephemeris::bind()
69
tieStar("/ephemeris/sun/xs", _impl->get_sun(), &Star::getxs);
70
tieStar("/ephemeris/sun/ys", _impl->get_sun(), &Star::getys);
71
tieStar("/ephemeris/sun/ze", _impl->get_sun(), &Star::getze);
72
tieStar("/ephemeris/sun/ye", _impl->get_sun(), &Star::getye);
74
tieStar("/ephemeris/sun/lat-deg", _impl->get_sun(), &Star::getLat);
77
void Ephemeris::unbind()
81
void Ephemeris::update(double)
83
SGTime* st = globals->get_time_params();
84
_impl->update(st->getMjd(), st->getLst(), _latProp->getDoubleValue());