From: curt Date: Tue, 10 Oct 2000 17:19:17 +0000 (+0000) Subject: A bit of file renaming to avoid problems with MSVC++ X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e88c915206501d89021b591a73fb2d2f3ccb2868;p=simgear.git A bit of file renaming to avoid problems with MSVC++ --- diff --git a/simgear/ephemeris/Makefile.am b/simgear/ephemeris/Makefile.am index 4f6c4ed7..a119f964 100644 --- a/simgear/ephemeris/Makefile.am +++ b/simgear/ephemeris/Makefile.am @@ -8,11 +8,11 @@ include_HEADERS = \ jupiter.hxx \ mars.hxx \ mercury.hxx \ - moon.hxx \ + moonpos.hxx \ neptune.hxx \ saturn.hxx \ star.hxx \ - stars.hxx \ + stardata.hxx \ uranus.hxx \ venus.hxx @@ -22,12 +22,12 @@ libsgephem_a_SOURCES = \ jupiter.cxx \ mars.cxx \ mercury.cxx \ - moon.cxx \ + moonpos.cxx \ neptune.cxx \ pluto.hxx \ saturn.cxx \ star.cxx \ - stars.cxx \ + stardata.cxx \ uranus.cxx \ venus.cxx diff --git a/simgear/ephemeris/ephemeris.cxx b/simgear/ephemeris/ephemeris.cxx index 77bf3ef6..95ac3402 100644 --- a/simgear/ephemeris/ephemeris.cxx +++ b/simgear/ephemeris/ephemeris.cxx @@ -29,7 +29,7 @@ // Constructor SGEphemeris::SGEphemeris( const string &path ) { our_sun = new Star; - moon = new Moon; + moon = new MoonPos; mercury = new Mercury; venus = new Venus; mars = new Mars; diff --git a/simgear/ephemeris/ephemeris.hxx b/simgear/ephemeris/ephemeris.hxx index 64c0b73b..5b4f7a10 100644 --- a/simgear/ephemeris/ephemeris.hxx +++ b/simgear/ephemeris/ephemeris.hxx @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include #include @@ -45,13 +45,13 @@ #include #include #include -#include +#include class SGEphemeris { Star *our_sun; - Moon *moon; + MoonPos *moon; Mercury *mercury; Venus *venus; Mars *mars; @@ -91,7 +91,7 @@ public: } // moon - inline Moon *get_moon() const { return moon; } + inline MoonPos *get_moon() const { return moon; } inline double getMoonRightAscension() const { return moon->getRightAscension(); } diff --git a/simgear/ephemeris/moon.cxx b/simgear/ephemeris/moon.cxx deleted file mode 100644 index 1226e165..00000000 --- a/simgear/ephemeris/moon.cxx +++ /dev/null @@ -1,191 +0,0 @@ -/************************************************************************** - * moon.cxx - * Written by Durk Talsma. Originally started October 1997, for distribution - * with the FlightGear project. Version 2 was written in August and - * September 1998. This code is based upon algorithms and data kindly - * provided by Mr. Paul Schlyter. (pausch@saaf.se). - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * $Id$ - **************************************************************************/ - - -#include - -#include -#include - -#ifdef __BORLANDC__ -# define exception c_exception -#endif -#include - -// #include - -#include "moon.hxx" - - -/************************************************************************* - * Moon::Moon(double mjd) - * Public constructor for class Moon. Initializes the orbital elements and - * sets up the moon texture. - * Argument: The current time. - * the hard coded orbital elements for Moon are passed to - * CelestialBody::CelestialBody(); - ************************************************************************/ -Moon::Moon(double mjd) : - CelestialBody(125.1228, -0.0529538083, - 5.1454, 0.00000, - 318.0634, 0.1643573223, - 60.266600, 0.000000, - 0.054900, 0.000000, - 115.3654, 13.0649929509, mjd) -{ -} - -Moon::Moon() : - CelestialBody(125.1228, -0.0529538083, - 5.1454, 0.00000, - 318.0634, 0.1643573223, - 60.266600, 0.000000, - 0.054900, 0.000000, - 115.3654, 13.0649929509) -{ -} - - -Moon::~Moon() -{ -} - - -/***************************************************************************** - * void Moon::updatePosition(double mjd, Star *ourSun) - * this member function calculates the actual topocentric position (i.e.) - * the position of the moon as seen from the current position on the surface - * of the moon. - ****************************************************************************/ -void Moon::updatePosition(double mjd, double lst, double lat, Star *ourSun) -{ - double - eccAnom, ecl, actTime, - xv, yv, v, r, xh, yh, zh, xg, yg, zg, xe, ye, ze, - Ls, Lm, D, F, mpar, gclat, rho, HA, g, - geoRa, geoDec; - - updateOrbElements(mjd); - actTime = sgCalcActTime(mjd); - - // calculate the angle between ecliptic and equatorial coordinate system - // in Radians - ecl = ((DEG_TO_RAD * 23.4393) - (DEG_TO_RAD * 3.563E-7) * actTime); - eccAnom = sgCalcEccAnom(M, e); // Calculate the eccentric anomaly - xv = a * (cos(eccAnom) - e); - yv = a * (sqrt(1.0 - e*e) * sin(eccAnom)); - v = atan2(yv, xv); // the moon's true anomaly - r = sqrt (xv*xv + yv*yv); // and its distance - - // estimate the geocentric rectangular coordinates here - xh = r * (cos(N) * cos (v+w) - sin (N) * sin(v+w) * cos(i)); - yh = r * (sin(N) * cos (v+w) + cos (N) * sin(v+w) * cos(i)); - zh = r * (sin(v+w) * sin(i)); - - // calculate the ecliptic latitude and longitude here - lonEcl = atan2 (yh, xh); - latEcl = atan2(zh, sqrt(xh*xh + yh*yh)); - - /* Calculate a number of perturbatioin, i.e. disturbances caused by the - * gravitational infuence of the sun and the other major planets. - * The largest of these even have a name */ - Ls = ourSun->getM() + ourSun->getw(); - Lm = M + w + N; - D = Lm - Ls; - F = Lm - N; - - lonEcl += DEG_TO_RAD * (-1.274 * sin (M - 2*D) - +0.658 * sin (2*D) - -0.186 * sin(ourSun->getM()) - -0.059 * sin(2*M - 2*D) - -0.057 * sin(M - 2*D + ourSun->getM()) - +0.053 * sin(M + 2*D) - +0.046 * sin(2*D - ourSun->getM()) - +0.041 * sin(M - ourSun->getM()) - -0.035 * sin(D) - -0.031 * sin(M + ourSun->getM()) - -0.015 * sin(2*F - 2*D) - +0.011 * sin(M - 4*D) - ); - latEcl += DEG_TO_RAD * (-0.173 * sin(F-2*D) - -0.055 * sin(M - F - 2*D) - -0.046 * sin(M + F - 2*D) - +0.033 * sin(F + 2*D) - +0.017 * sin(2*M + F) - ); - r += (-0.58 * cos(M - 2*D) - -0.46 * cos(2*D) - ); - // FG_LOG(FG_GENERAL, FG_INFO, "Running moon update"); - xg = r * cos(lonEcl) * cos(latEcl); - yg = r * sin(lonEcl) * cos(latEcl); - zg = r * sin(latEcl); - - xe = xg; - ye = yg * cos(ecl) -zg * sin(ecl); - ze = yg * sin(ecl) +zg * cos(ecl); - - geoRa = atan2(ye, xe); - geoDec = atan2(ze, sqrt(xe*xe + ye*ye)); - - /* FG_LOG( FG_GENERAL, FG_INFO, - "(geocentric) geoRa = (" << (RAD_TO_DEG * geoRa) - << "), geoDec= (" << (RAD_TO_DEG * geoDec) << ")" ); */ - - - // Given the moon's geocentric ra and dec, calculate its - // topocentric ra and dec. i.e. the position as seen from the - // surface of the earth, instead of the center of the earth - - // First calculate the moon's parrallax, that is, the apparent size of the - // (equatorial) radius of the earth, as seen from the moon - mpar = asin ( 1 / r); - // FG_LOG( FG_GENERAL, FG_INFO, "r = " << r << " mpar = " << mpar ); - // FG_LOG( FG_GENERAL, FG_INFO, "lat = " << f->get_Latitude() ); - - gclat = lat - 0.003358 * - sin (2 * DEG_TO_RAD * lat ); - // FG_LOG( FG_GENERAL, FG_INFO, "gclat = " << gclat ); - - rho = 0.99883 + 0.00167 * cos(2 * DEG_TO_RAD * lat); - // FG_LOG( FG_GENERAL, FG_INFO, "rho = " << rho ); - - if (geoRa < 0) - geoRa += (2*FG_PI); - - HA = lst - (3.8197186 * geoRa); - /* FG_LOG( FG_GENERAL, FG_INFO, "t->getLst() = " << t->getLst() - << " HA = " << HA ); */ - - g = atan (tan(gclat) / cos ((HA / 3.8197186))); - // FG_LOG( FG_GENERAL, FG_INFO, "g = " << g ); - - rightAscension = geoRa - mpar * rho * cos(gclat) * sin(HA) / cos (geoDec); - declination = geoDec - mpar * rho * sin (gclat) * sin (g - geoDec) / sin(g); - - /* FG_LOG( FG_GENERAL, FG_INFO, - "Ra = (" << (RAD_TO_DEG *rightAscension) - << "), Dec= (" << (RAD_TO_DEG *declination) << ")" ); */ -} diff --git a/simgear/ephemeris/moon.hxx b/simgear/ephemeris/moon.hxx deleted file mode 100644 index 94958d6d..00000000 --- a/simgear/ephemeris/moon.hxx +++ /dev/null @@ -1,60 +0,0 @@ -/************************************************************************** - * moon.hxx - * Written by Durk Talsma. Originally started October 1997, for distribution - * with the FlightGear project. Version 2 was written in August and - * September 1998. This code is based upon algorithms and data kindly - * provided by Mr. Paul Schlyter. (pausch@saaf.se). - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * $Id$ - **************************************************************************/ -#ifndef _MOON_HXX_ -#define _MOON_HXX_ - - -#include - -#include -#include - -class Moon : public CelestialBody -{ - -private: - - // void TexInit(); // This should move to the constructor eventually. - - // GLUquadricObj *moonObject; - // GLuint Sphere; - // GLuint moon_texid; - // GLuint moon_halotexid; - // GLubyte *moon_texbuf; - // GLubyte *moon_halotexbuf; - - // void setHalo(); - -public: - - Moon(double mjd); - Moon(); - ~Moon(); - void updatePosition(double mjd, double lst, double lat, Star *ourSun); - // void newImage(); -}; - - -#endif // _MOON_HXX_ diff --git a/simgear/ephemeris/moonpos.cxx b/simgear/ephemeris/moonpos.cxx new file mode 100644 index 00000000..c0fb5753 --- /dev/null +++ b/simgear/ephemeris/moonpos.cxx @@ -0,0 +1,191 @@ +/************************************************************************** + * moonpos.cxx + * Written by Durk Talsma. Originally started October 1997, for distribution + * with the FlightGear project. Version 2 was written in August and + * September 1998. This code is based upon algorithms and data kindly + * provided by Mr. Paul Schlyter. (pausch@saaf.se). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * $Id$ + **************************************************************************/ + + +#include + +#include +#include + +#ifdef __BORLANDC__ +# define exception c_exception +#endif +#include + +// #include + +#include "moonpos.hxx" + + +/************************************************************************* + * MoonPos::MoonPos(double mjd) + * Public constructor for class MoonPos. Initializes the orbital elements and + * sets up the moon texture. + * Argument: The current time. + * the hard coded orbital elements for MoonPos are passed to + * CelestialBody::CelestialBody(); + ************************************************************************/ +MoonPos::MoonPos(double mjd) : + CelestialBody(125.1228, -0.0529538083, + 5.1454, 0.00000, + 318.0634, 0.1643573223, + 60.266600, 0.000000, + 0.054900, 0.000000, + 115.3654, 13.0649929509, mjd) +{ +} + +MoonPos::MoonPos() : + CelestialBody(125.1228, -0.0529538083, + 5.1454, 0.00000, + 318.0634, 0.1643573223, + 60.266600, 0.000000, + 0.054900, 0.000000, + 115.3654, 13.0649929509) +{ +} + + +MoonPos::~MoonPos() +{ +} + + +/***************************************************************************** + * void MoonPos::updatePosition(double mjd, Star *ourSun) + * this member function calculates the actual topocentric position (i.e.) + * the position of the moon as seen from the current position on the surface + * of the moon. + ****************************************************************************/ +void MoonPos::updatePosition(double mjd, double lst, double lat, Star *ourSun) +{ + double + eccAnom, ecl, actTime, + xv, yv, v, r, xh, yh, zh, xg, yg, zg, xe, ye, ze, + Ls, Lm, D, F, mpar, gclat, rho, HA, g, + geoRa, geoDec; + + updateOrbElements(mjd); + actTime = sgCalcActTime(mjd); + + // calculate the angle between ecliptic and equatorial coordinate system + // in Radians + ecl = ((DEG_TO_RAD * 23.4393) - (DEG_TO_RAD * 3.563E-7) * actTime); + eccAnom = sgCalcEccAnom(M, e); // Calculate the eccentric anomaly + xv = a * (cos(eccAnom) - e); + yv = a * (sqrt(1.0 - e*e) * sin(eccAnom)); + v = atan2(yv, xv); // the moon's true anomaly + r = sqrt (xv*xv + yv*yv); // and its distance + + // estimate the geocentric rectangular coordinates here + xh = r * (cos(N) * cos (v+w) - sin (N) * sin(v+w) * cos(i)); + yh = r * (sin(N) * cos (v+w) + cos (N) * sin(v+w) * cos(i)); + zh = r * (sin(v+w) * sin(i)); + + // calculate the ecliptic latitude and longitude here + lonEcl = atan2 (yh, xh); + latEcl = atan2(zh, sqrt(xh*xh + yh*yh)); + + /* Calculate a number of perturbatioin, i.e. disturbances caused by the + * gravitational infuence of the sun and the other major planets. + * The largest of these even have a name */ + Ls = ourSun->getM() + ourSun->getw(); + Lm = M + w + N; + D = Lm - Ls; + F = Lm - N; + + lonEcl += DEG_TO_RAD * (-1.274 * sin (M - 2*D) + +0.658 * sin (2*D) + -0.186 * sin(ourSun->getM()) + -0.059 * sin(2*M - 2*D) + -0.057 * sin(M - 2*D + ourSun->getM()) + +0.053 * sin(M + 2*D) + +0.046 * sin(2*D - ourSun->getM()) + +0.041 * sin(M - ourSun->getM()) + -0.035 * sin(D) + -0.031 * sin(M + ourSun->getM()) + -0.015 * sin(2*F - 2*D) + +0.011 * sin(M - 4*D) + ); + latEcl += DEG_TO_RAD * (-0.173 * sin(F-2*D) + -0.055 * sin(M - F - 2*D) + -0.046 * sin(M + F - 2*D) + +0.033 * sin(F + 2*D) + +0.017 * sin(2*M + F) + ); + r += (-0.58 * cos(M - 2*D) + -0.46 * cos(2*D) + ); + // FG_LOG(FG_GENERAL, FG_INFO, "Running moon update"); + xg = r * cos(lonEcl) * cos(latEcl); + yg = r * sin(lonEcl) * cos(latEcl); + zg = r * sin(latEcl); + + xe = xg; + ye = yg * cos(ecl) -zg * sin(ecl); + ze = yg * sin(ecl) +zg * cos(ecl); + + geoRa = atan2(ye, xe); + geoDec = atan2(ze, sqrt(xe*xe + ye*ye)); + + /* FG_LOG( FG_GENERAL, FG_INFO, + "(geocentric) geoRa = (" << (RAD_TO_DEG * geoRa) + << "), geoDec= (" << (RAD_TO_DEG * geoDec) << ")" ); */ + + + // Given the moon's geocentric ra and dec, calculate its + // topocentric ra and dec. i.e. the position as seen from the + // surface of the earth, instead of the center of the earth + + // First calculate the moon's parrallax, that is, the apparent size of the + // (equatorial) radius of the earth, as seen from the moon + mpar = asin ( 1 / r); + // FG_LOG( FG_GENERAL, FG_INFO, "r = " << r << " mpar = " << mpar ); + // FG_LOG( FG_GENERAL, FG_INFO, "lat = " << f->get_Latitude() ); + + gclat = lat - 0.003358 * + sin (2 * DEG_TO_RAD * lat ); + // FG_LOG( FG_GENERAL, FG_INFO, "gclat = " << gclat ); + + rho = 0.99883 + 0.00167 * cos(2 * DEG_TO_RAD * lat); + // FG_LOG( FG_GENERAL, FG_INFO, "rho = " << rho ); + + if (geoRa < 0) + geoRa += (2*FG_PI); + + HA = lst - (3.8197186 * geoRa); + /* FG_LOG( FG_GENERAL, FG_INFO, "t->getLst() = " << t->getLst() + << " HA = " << HA ); */ + + g = atan (tan(gclat) / cos ((HA / 3.8197186))); + // FG_LOG( FG_GENERAL, FG_INFO, "g = " << g ); + + rightAscension = geoRa - mpar * rho * cos(gclat) * sin(HA) / cos (geoDec); + declination = geoDec - mpar * rho * sin (gclat) * sin (g - geoDec) / sin(g); + + /* FG_LOG( FG_GENERAL, FG_INFO, + "Ra = (" << (RAD_TO_DEG *rightAscension) + << "), Dec= (" << (RAD_TO_DEG *declination) << ")" ); */ +} diff --git a/simgear/ephemeris/moonpos.hxx b/simgear/ephemeris/moonpos.hxx new file mode 100644 index 00000000..96092b9f --- /dev/null +++ b/simgear/ephemeris/moonpos.hxx @@ -0,0 +1,61 @@ +/************************************************************************** + * moonpos.hxx + * Written by Durk Talsma. Originally started October 1997, for distribution + * with the FlightGear project. Version 2 was written in August and + * September 1998. This code is based upon algorithms and data kindly + * provided by Mr. Paul Schlyter. (pausch@saaf.se). + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * $Id$ + **************************************************************************/ +#ifndef _MOONPOS_HXX_ +#define _MOONPOS_HXX_ + + +#include + +#include +#include + + +class MoonPos : public CelestialBody +{ + +private: + + // void TexInit(); // This should move to the constructor eventually. + + // GLUquadricObj *moonObject; + // GLuint Sphere; + // GLuint moon_texid; + // GLuint moon_halotexid; + // GLubyte *moon_texbuf; + // GLubyte *moon_halotexbuf; + + // void setHalo(); + +public: + + MoonPos(double mjd); + MoonPos(); + ~MoonPos(); + void updatePosition(double mjd, double lst, double lat, Star *ourSun); + // void newImage(); +}; + + +#endif // _MOONPOS_HXX_ diff --git a/simgear/ephemeris/stardata.cxx b/simgear/ephemeris/stardata.cxx new file mode 100644 index 00000000..3804988e --- /dev/null +++ b/simgear/ephemeris/stardata.cxx @@ -0,0 +1,122 @@ +// stardata.cxx -- manage star data +// +// Written by Curtis Olson, started March 2000. +// +// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the +// Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. +// +// $Id$ + + +#include +#include + +#include "stardata.hxx" + +#ifdef _MSC_VER + FG_USING_STD(getline); +#endif + +// Constructor +SGStarData::SGStarData() { +} + +SGStarData::SGStarData( FGPath path ) { + data_path = FGPath( path ); + load(); +} + + +// Destructor +SGStarData::~SGStarData() { +} + + +bool SGStarData::load() { + + // -dw- avoid local data > 32k error by dynamic allocation of the + // array, problem for some compilers + stars = new sgdVec3[SG_MAX_STARS]; + + // build the full path name to the stars data base file + data_path.append( "stars" ); + FG_LOG( FG_ASTRO, FG_INFO, " Loading stars from " << data_path.str() ); + + fg_gzifstream in( data_path.str() ); + if ( ! in.is_open() ) { + FG_LOG( FG_ASTRO, FG_ALERT, "Cannot open star file: " + << data_path.str() ); + exit(-1); + } + + double ra, dec, mag; + char c; + string name; + + nstars = 0; + + // read in each line of the file + while ( ! in.eof() && nstars < SG_MAX_STARS ) { + in >> skipcomment; + + getline( in, name, ',' ); + // cout << " data = " << name << endl; + + // read name and first comma + while ( in.get(c) ) { + if ( (c != ' ') && (c != ',') ) { + // push back on the stream + in.putback(c); + break; + } + } + + in >> ra; + + // read past optional comma + while ( in.get(c) ) { + if ( (c != ' ') && (c != ',') ) { + // push back on the stream + in.putback(c); + break; + } + } + + in >> dec; + + // read past optional comma + while ( in.get(c) ) { + if ( (c != ' ') && (c != ',') ) { + // push back on the stream + in.putback(c); + break; + } + } + + in >> mag; + + // cout << " star data = " << ra << " " << dec << " " << mag << endl; + + sgdSetVec3( stars[nstars], ra, dec, mag ); + + ++nstars; + } + + FG_LOG( FG_ASTRO, FG_INFO, " Loaded " << nstars << " stars" ); + + return true; +} diff --git a/simgear/ephemeris/stardata.hxx b/simgear/ephemeris/stardata.hxx new file mode 100644 index 00000000..0f9f7ae7 --- /dev/null +++ b/simgear/ephemeris/stardata.hxx @@ -0,0 +1,62 @@ +// stardata.hxx -- manage star data +// +// Written by Curtis Olson, started March 2000. +// +// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the +// Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. +// +// $Id$ + + +#ifndef _SG_STARDATA_HXX +#define _SG_STARDATA_HXX + + +#include + +#include + + +#define SG_MAX_STARS 850 + + +class SGStarData { + + int nstars; + sgdVec3 *stars; + + FGPath data_path; + +public: + + // Constructor + SGStarData(); + SGStarData( FGPath path ); + + // Destructor + ~SGStarData(); + + // load the stars database + bool load(); + + // stars + inline int getNumStars() const { return nstars; } + inline sgdVec3 *getStars() { return stars; } +}; + + +#endif // _SG_STARDATA_HXX diff --git a/simgear/ephemeris/stars.cxx b/simgear/ephemeris/stars.cxx deleted file mode 100644 index 413dee66..00000000 --- a/simgear/ephemeris/stars.cxx +++ /dev/null @@ -1,122 +0,0 @@ -// stars.cxx -- manage star data -// -// Written by Curtis Olson, started March 2000. -// -// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the -// Free Software Foundation, Inc., 59 Temple Place - Suite 330, -// Boston, MA 02111-1307, USA. -// -// $Id$ - - -#include -#include - -#include "stars.hxx" - -#ifdef _MSC_VER - FG_USING_STD(getline); -#endif - -// Constructor -SGStarData::SGStarData() { -} - -SGStarData::SGStarData( FGPath path ) { - data_path = FGPath( path ); - load(); -} - - -// Destructor -SGStarData::~SGStarData() { -} - - -bool SGStarData::load() { - - // -dw- avoid local data > 32k error by dynamic allocation of the - // array, problem for some compilers - stars = new sgdVec3[SG_MAX_STARS]; - - // build the full path name to the stars data base file - data_path.append( "stars" ); - FG_LOG( FG_ASTRO, FG_INFO, " Loading stars from " << data_path.str() ); - - fg_gzifstream in( data_path.str() ); - if ( ! in.is_open() ) { - FG_LOG( FG_ASTRO, FG_ALERT, "Cannot open star file: " - << data_path.str() ); - exit(-1); - } - - double ra, dec, mag; - char c; - string name; - - nstars = 0; - - // read in each line of the file - while ( ! in.eof() && nstars < SG_MAX_STARS ) { - in >> skipcomment; - - getline( in, name, ',' ); - // cout << " data = " << name << endl; - - // read name and first comma - while ( in.get(c) ) { - if ( (c != ' ') && (c != ',') ) { - // push back on the stream - in.putback(c); - break; - } - } - - in >> ra; - - // read past optional comma - while ( in.get(c) ) { - if ( (c != ' ') && (c != ',') ) { - // push back on the stream - in.putback(c); - break; - } - } - - in >> dec; - - // read past optional comma - while ( in.get(c) ) { - if ( (c != ' ') && (c != ',') ) { - // push back on the stream - in.putback(c); - break; - } - } - - in >> mag; - - // cout << " star data = " << ra << " " << dec << " " << mag << endl; - - sgdSetVec3( stars[nstars], ra, dec, mag ); - - ++nstars; - } - - FG_LOG( FG_ASTRO, FG_INFO, " Loaded " << nstars << " stars" ); - - return true; -} diff --git a/simgear/ephemeris/stars.hxx b/simgear/ephemeris/stars.hxx deleted file mode 100644 index 24f1c503..00000000 --- a/simgear/ephemeris/stars.hxx +++ /dev/null @@ -1,62 +0,0 @@ -// stars.hxx -- manage star data -// -// Written by Curtis Olson, started March 2000. -// -// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the -// Free Software Foundation, Inc., 59 Temple Place - Suite 330, -// Boston, MA 02111-1307, USA. -// -// $Id$ - - -#ifndef _SG_STARDATA_HXX -#define _SG_STARDATA_HXX - - -#include - -#include - - -#define SG_MAX_STARS 850 - - -class SGStarData { - - int nstars; - sgdVec3 *stars; - - FGPath data_path; - -public: - - // Constructor - SGStarData(); - SGStarData( FGPath path ); - - // Destructor - ~SGStarData(); - - // load the stars database - bool load(); - - // stars - inline int getNumStars() const { return nstars; } - inline sgdVec3 *getStars() { return stars; } -}; - - -#endif // _SG_STARDATA_HXX