X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fephemeris%2Fstardata.cxx;h=a78583338b95ca34d819c7c8ba05dd6dfb412aaa;hb=598b64fa9569c16878c904e344e2e2775e210c42;hp=b5f5d63b554ff958f077ca0319a120a10d685518;hpb=557fade4a7df3f030b943ba6114c3c566c57b73c;p=simgear.git diff --git a/simgear/ephemeris/stardata.cxx b/simgear/ephemeris/stardata.cxx index b5f5d63b..a7858333 100644 --- a/simgear/ephemeris/stardata.cxx +++ b/simgear/ephemeris/stardata.cxx @@ -2,7 +2,7 @@ // // Written by Curtis Olson, started March 2000. // -// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org +// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public @@ -14,30 +14,32 @@ // 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. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id$ +#ifdef HAVE_CONFIG_H +# include +#endif #include -#include +#include +#include #include "stardata.hxx" -#if defined (_MSC_VER) || defined (SG_HAVE_NATIVE_SGI_COMPILERS) - SG_USING_STD(getline); +#if defined (_MSC_VER) + using std::getline; #endif -// Constructor -SGStarData::SGStarData() { -} +using std::string; -SGStarData::SGStarData( FGPath path ) { - data_path = FGPath( path ); - load(); +// Constructor +SGStarData::SGStarData( const SGPath& path ) +{ + load(path); } @@ -46,31 +48,28 @@ SGStarData::~SGStarData() { } -bool SGStarData::load() { +bool SGStarData::load( const SGPath& path ) { - // -dw- avoid local data > 32k error by dynamic allocation of the - // array, problem for some compilers - stars = new sgdVec3[SG_MAX_STARS]; + _stars.clear(); - // build the full path name to the stars data base file - data_path.append( "stars" ); - SG_LOG( SG_ASTRO, SG_INFO, " Loading stars from " << data_path.str() ); + // build the full path name to the stars data base file + SGPath tmp = path; + tmp.append( "stars" ); + SG_LOG( SG_ASTRO, SG_INFO, " Loading stars from " << tmp.str() ); - fg_gzifstream in( data_path.str() ); + sg_gzifstream in( tmp.str() ); if ( ! in.is_open() ) { SG_LOG( SG_ASTRO, SG_ALERT, "Cannot open star file: " - << data_path.str() ); - exit(-1); + << tmp.str() ); + return false; } double ra, dec, mag; char c; string name; - nstars = 0; - // read in each line of the file - while ( ! in.eof() && nstars < SG_MAX_STARS ) { + while ( ! in.eof() ) { in >> skipcomment; getline( in, name, ',' ); @@ -110,13 +109,10 @@ bool SGStarData::load() { in >> mag; // cout << " star data = " << ra << " " << dec << " " << mag << endl; - - sgdSetVec3( stars[nstars], ra, dec, mag ); - - ++nstars; + _stars.push_back(SGVec3d(ra, dec, mag)); } - SG_LOG( SG_ASTRO, SG_INFO, " Loaded " << nstars << " stars" ); + SG_LOG( SG_ASTRO, SG_INFO, " Loaded " << _stars.size() << " stars" ); return true; }