]> git.mxchange.org Git - simgear.git/blobdiff - simgear/ephemeris/stardata.cxx
Attached patches remove BORLANDC, and hence SG_MATH_EXCEPTION_CLASH and SG_INCOM
[simgear.git] / simgear / ephemeris / stardata.cxx
index 4c703cf9cf1eb593a29ef8dee108300ce36106fe..bba1a536a3b4cdd3922a8cc03eae57fcced641cb 100644 (file)
@@ -25,6 +25,7 @@
 #endif
 
 #include <simgear/debug/logstream.hxx>
+#include <simgear/misc/sg_path.hxx>
 #include <simgear/misc/sgstream.hxx>
 
 #include "stardata.hxx"
 #endif
 
 // Constructor
-SGStarData::SGStarData() :
-    nstars(0)
+SGStarData::SGStarData( const SGPath& path )
 {
-}
-
-SGStarData::SGStarData( SGPath path ) :
-    nstars(0)
-{
-    data_path = SGPath( path );
-    load();
+    load(path);
 }
 
 
@@ -52,31 +46,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() );
 
-    sg_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, ',' );
@@ -116,13 +107,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;
 }