AstorbFile Class Reference

Lowell asteroids database file. More...

#include <orsa_file.h>

Inheritance diagram for AstorbFile:

Inheritance graph
[legend]
Collaboration diagram for AstorbFile:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 AstorbFile ()
virtual ~AstorbFile ()
void Read ()
virtual void read_progress (int, bool &, bool &)
virtual void read_finished ()
void Open ()
void Close ()
virtual std::string GetFileName () const
virtual void SetFileName (std::string name_in)
virtual void SetFileName (char *name_in)

Public Attributes

AsteroidDatabasedb

Protected Attributes

std::string filename
FILE_TYPE file
FILE_STATUS status

Detailed Description

Lowell asteroids database file.

Definition at line 317 of file orsa_file.h.


Constructor & Destructor Documentation

AstorbFile  ) 
 

Definition at line 367 of file orsa_file.cc.

00367                          : AsteroidDatabaseFile() {
00368     // status = CLOSE;
00369     // db = new AstorbDatabase();
00370     db = new AsteroidDatabase();
00371   }

~AstorbFile  )  [virtual]
 

Definition at line 373 of file orsa_file.cc.

00373                           {
00374     delete db;
00375     db = 0;
00376   }


Member Function Documentation

void Close  )  [inherited]
 

Definition at line 114 of file orsa_file.cc.

References orsa::CLOSE, CLOSE_FILE, File::file, and File::status.

Referenced by SWIFTFile::AsteroidsInFile(), ReadWriteFile::Open(), OrsaFile::Read(), OrsaConfigFile::Read(), SWIFTFile::Read(), Config::read_from_file(), File::SetFileName(), OrsaFile::Write(), OrsaConfigFile::Write(), Config::write_to_file(), and File::~File().

00114                    {
00115     if (status != CLOSE) {
00116       CLOSE_FILE(file);
00117       status = CLOSE;
00118     }
00119   }

virtual std::string GetFileName  )  const [inline, virtual, inherited]
 

Definition at line 99 of file orsa_file.h.

References File::filename.

Referenced by LocationFile::ObsPos(), and OrsaFile::Read().

00099 { return filename; }

void Open  )  [inherited]
 

Definition at line 59 of file orsa_file.cc.

References orsa::CLOSE, OPEN_FILE, orsa::OPEN_R, OPEN_READ, and ORSA_ERROR.

Referenced by SWIFTFile::AsteroidsInFile(), Mercury5IntegrationFile::Read(), TLEFile::Read(), NEODYSCAT::Read(), JPLDastcomCometFile::Read(), JPLDastcomUnnumFile::Read(), JPLDastcomNumFile::Read(), AstDySMatrixFile::Read(), RadauModIntegrationFile::Read(), SWIFTFile::Read(), LocationFile::Read(), RWOFile::Read(), MPCObsFile::Read(), MPCCometFile::Read(), MPCOrbFile::Read(), and AstorbFile::Read().

00059                       {
00060     if (status != CLOSE) return;
00061     
00062     file = OPEN_FILE(filename.c_str(),OPEN_READ);
00063     
00064     if (file == 0) { 
00065       ORSA_ERROR("Can't open file %s",filename.c_str());
00066     } else {
00067       status = OPEN_R;
00068     }
00069   }

void Read  )  [virtual]
 

Implements ReadFile.

Definition at line 198 of file orsa_file.cc.

References Orbit::a, orsa::AU, OrbitWithEpoch::Compute(), Orbit::e, orsa::ECLIPTIC, orsa::EclipticToEquatorial_J2000(), OrbitWithEpoch::epoch, orsa::EQUATORIAL, orsa::FromUnits(), orsa::GetG(), orsa::GetMSun(), Universe::GetReferenceSystem(), GETS_FILE, Orbit::i, Orbit::M, orsa::M, Asteroid::mag, Orbit::mu, Asteroid::n, Asteroid::name, Orbit::omega_node, Orbit::omega_pericenter, ReadFile::Open(), orsa::OPEN_R, Asteroid::orb, ORSA_ERROR, orsa::pi, AsteroidDatabaseFile::read_finished(), AsteroidDatabaseFile::read_progress(), OrbitWithEpoch::RelativePosVel(), orsa::remove_leading_trailing_spaces(), REWIND_FILE, UniverseTypeAwareTime::SetDate(), Date::SetGregor(), orsa::TDT, and orsa::universe.

00198                         {
00199     
00200     // if (db_updated) return;
00201     
00202     // if (status == CLOSE) Open();
00203     
00204     Open();
00205     
00206     if (status != OPEN_R) {
00207       ORSA_ERROR("Status error!");
00208       return;
00209     }
00210     
00211     // reset database 
00212     // cerr << "pre-resize..." << endl;
00213     db->clear();
00214     
00215     // db->reserve(GetSize()); // a little too time consuming...
00216     
00217     // cerr << "reading pass (1)" << endl;
00218     
00219     // int print_step = 0;
00220     // int print_step = 10000;
00221     
00222     char line[300];
00223     
00224     double a,e,i,omega_node,omega_pericenter,M;
00225     // int    n;
00226     string number,name,orbit_computer,absolute_magnitude,arc,numobs,epoch;
00227     string mean_anomaly,pericenter,node,inclination,eccentricity,semimajor_axis;
00228     // string ceu;
00229     
00230     string year,month,day;
00231     int    y,m,d;
00232     
00233     // Body orb_ref_body("",GetMSun());
00234     
00235     // AstorbDataEntry ast;
00236     Asteroid ast;
00237     
00238     // Date tmp_date(TDT);
00239     Date tmp_date;
00240     
00241     unsigned int local_index = 0;
00242     bool bool_stop=false;
00243     bool bool_pause=false;
00244     REWIND_FILE(file);
00245     while ((GETS_FILE(line,300,file)) != 0) {
00246       
00247       // cerr << "AstorbFile::Read() inside the while() loop..." << endl;
00248       
00249       if (strlen(line) < 100) continue; // not a good line, maybe a comment or a white line...
00250       
00251       // cerr << "inside while loop..." << endl;
00252       
00253       local_index++;
00254       read_progress(local_index,bool_pause,bool_stop);
00255       
00256       if (bool_stop) break;
00257       
00258       while (bool_pause) {
00259         // cerr << "AstorbFile::Read() sleeping..." << endl;
00260         sleep(1);
00261         read_progress(local_index,bool_pause,bool_stop);
00262       }
00263       
00264       // uncomment the ones used
00265       number.assign(line,0,5);
00266       name.assign(line,6,18);
00267       orbit_computer.assign(line,25,15);
00268       absolute_magnitude.assign(line,41,5);
00269       //
00270       arc.assign(line,94,5);
00271       numobs.assign(line,99,5);
00272       //
00273       epoch.assign(line,105,8);
00274       //
00275       mean_anomaly.assign(line,114,10);
00276       pericenter.assign(line,125,10);
00277       node.assign(line,136,10);
00278       inclination.assign(line,146,10);
00279       eccentricity.assign(line,157,10);
00280       semimajor_axis.assign(line,168,12);
00281       // ceu.assign(line,190,7);
00282       
00283       //////////////
00284       
00285       ast.n = atoi(number.c_str());
00286       
00287       ast.name = name;
00288       remove_leading_trailing_spaces(ast.name);
00289       
00290       // ast.ceu  = atof(ceu.c_str());
00291       
00292       ast.mag  = atof(absolute_magnitude.c_str());
00293       
00294       a                = atof(semimajor_axis.c_str());
00295       e                = atof(eccentricity.c_str());
00296       i                = (pi/180)*atof(inclination.c_str());
00297       omega_node       = (pi/180)*atof(node.c_str());
00298       omega_pericenter = (pi/180)*atof(pericenter.c_str());
00299       M                = (pi/180)*atof(mean_anomaly.c_str());
00300       
00301       ast.orb.a                = FromUnits(a,AU);
00302       ast.orb.e                = e;
00303       ast.orb.i                = i;
00304       ast.orb.omega_node       = omega_node;
00305       ast.orb.omega_pericenter = omega_pericenter;
00306       ast.orb.M                = M;
00307       
00308       year.assign(epoch,0,4);
00309       month.assign(epoch,4,2);
00310       day.assign(epoch,6,2);
00311       
00312       y = atoi(year.c_str());
00313       m = atoi(month.c_str());
00314       d = atoi(day.c_str());
00315       
00316       tmp_date.SetGregor(y,m,d,TDT);
00317       ast.orb.epoch.SetDate(tmp_date);
00318       // ast.orb.T = sqrt(4*pisq/(GetG()*GetMSun())*pow(FromUnits(ast.orb.a,AU),3));
00319       ast.orb.mu = GetG()*GetMSun();
00320       // ast.orb.ref_body = orb_ref_body;
00321       
00322       /* 
00323          switch (universe->GetReferenceSystem()) {
00324          case ECLIPTIC: break;
00325          case EQUATORIAL:
00326          { 
00327          // cerr << "Rotating astorb orbit..." << endl;
00328          const double obleq_rad = obleq(tmp_date).GetRad();
00329          Vector position,velocity;
00330          ast.orb.RelativePosVel(position,velocity);
00331          position.rotate(0.0,obleq_rad,0.0);
00332          velocity.rotate(0.0,obleq_rad,0.0);
00333          ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch);
00334          }
00335          break;
00336          }
00337       */
00338       
00339       switch (universe->GetReferenceSystem()) {
00340       case ECLIPTIC: break;
00341       case EQUATORIAL:
00342         { 
00343           Vector position,velocity;
00344           ast.orb.RelativePosVel(position,velocity);
00345           EclipticToEquatorial_J2000(position);
00346           EclipticToEquatorial_J2000(velocity);
00347           ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch);
00348         }
00349         break;
00350       }
00351       
00352       db->push_back(ast);
00353       
00354     }
00355     
00356     read_finished();
00357     
00358   }

Here is the call graph for this function:

virtual void read_finished  )  [inline, virtual, inherited]
 

Definition at line 257 of file orsa_file.h.

Referenced by NEODYSCAT::Read(), JPLDastcomCometFile::Read(), JPLDastcomUnnumFile::Read(), JPLDastcomNumFile::Read(), AstDySMatrixFile::Read(), MPCCometFile::Read(), MPCOrbFile::Read(), and AstorbFile::Read().

00257 { };

virtual void read_progress int  ,
bool &  ,
bool & 
[inline, virtual, inherited]
 

Definition at line 256 of file orsa_file.h.

Referenced by NEODYSCAT::Read(), JPLDastcomCometFile::Read(), JPLDastcomUnnumFile::Read(), JPLDastcomNumFile::Read(), AstDySMatrixFile::Read(), MPCCometFile::Read(), MPCOrbFile::Read(), and AstorbFile::Read().

00256 { };

virtual void SetFileName char *  name_in  )  [inline, virtual, inherited]
 

Definition at line 106 of file orsa_file.h.

References File::SetFileName().

00106                                                      {
00107       std::string n = name_in;
00108       SetFileName (n);
00109     }

Here is the call graph for this function:

virtual void SetFileName std::string  name_in  )  [inline, virtual, inherited]
 

Definition at line 101 of file orsa_file.h.

References File::Close(), orsa::CLOSE, File::filename, and File::status.

Referenced by OrsaConfigFile::OrsaConfigFile(), and File::SetFileName().

00101                                                         {
00102       if (status != CLOSE) Close();
00103       filename = name_in;
00104     }

Here is the call graph for this function:


Member Data Documentation

AsteroidDatabase* db [inherited]
 

Definition at line 254 of file orsa_file.h.

Referenced by AsteroidDatabaseFile::AsteroidDatabaseFile().

FILE_TYPE file [protected, inherited]
 

Definition at line 113 of file orsa_file.h.

Referenced by File::Close(), and File::File().

std::string filename [protected, inherited]
 

Definition at line 112 of file orsa_file.h.

Referenced by File::GetFileName(), and File::SetFileName().

FILE_STATUS status [protected, inherited]
 

Definition at line 114 of file orsa_file.h.

Referenced by File::Close(), File::File(), and File::SetFileName().


The documentation for this class was generated from the following files:
Generated on Tue Jan 11 15:28:35 2005 for liborsa by  doxygen 1.4.0