]> git.mxchange.org Git - simgear.git/blobdiff - simgear/ephemeris/stardata.cxx
Linux test_HTTP fixes.
[simgear.git] / simgear / ephemeris / stardata.cxx
index e45b2092e77713920e806c5be2daa3e52bbefba8..a78583338b95ca34d819c7c8ba05dd6dfb412aaa 100644 (file)
 // 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 <simgear_config.h>
+#endif
 
 #include <simgear/debug/logstream.hxx>
+#include <simgear/misc/sg_path.hxx>
 #include <simgear/misc/sgstream.hxx>
 
 #include "stardata.hxx"
 
 #if defined (_MSC_VER)
-  SG_USING_STD(getline);
+  using std::getline;
 #endif
 
-// Constructor
-SGStarData::SGStarData() :
-    nstars(0)
-{
-}
+using std::string;
 
-SGStarData::SGStarData( SGPath path ) :
-    nstars(0)
+// Constructor
+SGStarData::SGStarData( const SGPath& path )
 {
-    data_path = SGPath( path );
-    load();
+    load(path);
 }
 
 
@@ -50,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() );
 
-    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, ',' );
@@ -114,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;
 }