#include <orsa_file.h>
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 | |
AsteroidDatabase * | db |
Protected Attributes | |
std::string | filename |
FILE_TYPE | file |
FILE_STATUS | status |
Lowell asteroids database file
Definition at line 317 of file orsa_file.h.
AstorbFile | ( | ) |
Definition at line 368 of file orsa_file.cc.
References AsteroidDatabaseFile::db.
00368 : AsteroidDatabaseFile() { 00369 // status = CLOSE; 00370 // db = new AstorbDatabase(); 00371 db = new AsteroidDatabase(); 00372 }
~AstorbFile | ( | ) | [virtual] |
void Read | ( | ) | [virtual] |
Implements ReadFile.
Definition at line 199 of file orsa_file.cc.
References Orbit::a, orsa::AU, OrbitWithEpoch::Compute(), AsteroidDatabaseFile::db, Orbit::e, orsa::ECLIPTIC, orsa::EclipticToEquatorial_J2000(), OrbitWithEpoch::epoch, orsa::EQUATORIAL, File::file, 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(), File::status, orsa::TDT, and orsa::universe.
00199 { 00200 00201 // if (db_updated) return; 00202 00203 // if (status == CLOSE) Open(); 00204 00205 Open(); 00206 00207 if (status != OPEN_R) { 00208 ORSA_ERROR("Status error!"); 00209 return; 00210 } 00211 00212 // reset database 00213 // cerr << "pre-resize..." << endl; 00214 db->clear(); 00215 00216 // db->reserve(GetSize()); // a little too time consuming... 00217 00218 // cerr << "reading pass (1)" << endl; 00219 00220 // int print_step = 0; 00221 // int print_step = 10000; 00222 00223 char line[300]; 00224 00225 double a,e,i,omega_node,omega_pericenter,M; 00226 // int n; 00227 string number,name,orbit_computer,absolute_magnitude,arc,numobs,epoch; 00228 string mean_anomaly,pericenter,node,inclination,eccentricity,semimajor_axis; 00229 // string ceu; 00230 00231 string year,month,day; 00232 int y,m,d; 00233 00234 // Body orb_ref_body("",GetMSun()); 00235 00236 // AstorbDataEntry ast; 00237 Asteroid ast; 00238 00239 // Date tmp_date(TDT); 00240 Date tmp_date; 00241 00242 unsigned int local_index = 0; 00243 bool bool_stop=false; 00244 bool bool_pause=false; 00245 REWIND_FILE(file); 00246 while ((GETS_FILE(line,300,file)) != 0) { 00247 00248 // cerr << "AstorbFile::Read() inside the while() loop..." << endl; 00249 00250 if (strlen(line) < 100) continue; // not a good line, maybe a comment or a white line... 00251 00252 // cerr << "inside while loop..." << endl; 00253 00254 local_index++; 00255 read_progress(local_index,bool_pause,bool_stop); 00256 00257 if (bool_stop) break; 00258 00259 while (bool_pause) { 00260 // cerr << "AstorbFile::Read() sleeping..." << endl; 00261 sleep(1); 00262 read_progress(local_index,bool_pause,bool_stop); 00263 } 00264 00265 // uncomment the ones used 00266 number.assign(line,0,5); 00267 name.assign(line,6,18); 00268 orbit_computer.assign(line,25,15); 00269 absolute_magnitude.assign(line,41,5); 00270 // 00271 arc.assign(line,94,5); 00272 numobs.assign(line,99,5); 00273 // 00274 epoch.assign(line,105,8); 00275 // 00276 mean_anomaly.assign(line,114,10); 00277 pericenter.assign(line,125,10); 00278 node.assign(line,136,10); 00279 inclination.assign(line,146,10); 00280 eccentricity.assign(line,157,10); 00281 semimajor_axis.assign(line,168,12); 00282 // ceu.assign(line,190,7); 00283 00284 ////////////// 00285 00286 ast.n = atoi(number.c_str()); 00287 00288 ast.name = name; 00289 remove_leading_trailing_spaces(ast.name); 00290 00291 // ast.ceu = atof(ceu.c_str()); 00292 00293 ast.mag = atof(absolute_magnitude.c_str()); 00294 00295 a = atof(semimajor_axis.c_str()); 00296 e = atof(eccentricity.c_str()); 00297 i = (pi/180)*atof(inclination.c_str()); 00298 omega_node = (pi/180)*atof(node.c_str()); 00299 omega_pericenter = (pi/180)*atof(pericenter.c_str()); 00300 M = (pi/180)*atof(mean_anomaly.c_str()); 00301 00302 ast.orb.a = FromUnits(a,AU); 00303 ast.orb.e = e; 00304 ast.orb.i = i; 00305 ast.orb.omega_node = omega_node; 00306 ast.orb.omega_pericenter = omega_pericenter; 00307 ast.orb.M = M; 00308 00309 year.assign(epoch,0,4); 00310 month.assign(epoch,4,2); 00311 day.assign(epoch,6,2); 00312 00313 y = atoi(year.c_str()); 00314 m = atoi(month.c_str()); 00315 d = atoi(day.c_str()); 00316 00317 tmp_date.SetGregor(y,m,d,TDT); 00318 ast.orb.epoch.SetDate(tmp_date); 00319 // ast.orb.T = sqrt(4*pisq/(GetG()*GetMSun())*pow(FromUnits(ast.orb.a,AU),3)); 00320 ast.orb.mu = GetG()*GetMSun(); 00321 // ast.orb.ref_body = orb_ref_body; 00322 00323 /* 00324 switch (universe->GetReferenceSystem()) { 00325 case ECLIPTIC: break; 00326 case EQUATORIAL: 00327 { 00328 // cerr << "Rotating astorb orbit..." << endl; 00329 const double obleq_rad = obleq(tmp_date).GetRad(); 00330 Vector position,velocity; 00331 ast.orb.RelativePosVel(position,velocity); 00332 position.rotate(0.0,obleq_rad,0.0); 00333 velocity.rotate(0.0,obleq_rad,0.0); 00334 ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch); 00335 } 00336 break; 00337 } 00338 */ 00339 00340 switch (universe->GetReferenceSystem()) { 00341 case ECLIPTIC: break; 00342 case EQUATORIAL: 00343 { 00344 Vector position,velocity; 00345 ast.orb.RelativePosVel(position,velocity); 00346 EclipticToEquatorial_J2000(position); 00347 EclipticToEquatorial_J2000(velocity); 00348 ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch); 00349 } 00350 break; 00351 } 00352 00353 db->push_back(ast); 00354 00355 } 00356 00357 read_finished(); 00358 00359 }
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().
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().
void Open | ( | ) | [inherited] |
Definition at line 60 of file orsa_file.cc.
References orsa::CLOSE, File::file, File::filename, OPEN_FILE, orsa::OPEN_R, OPEN_READ, ORSA_ERROR, and File::status.
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().
00060 { 00061 if (status != CLOSE) return; 00062 00063 file = OPEN_FILE(filename.c_str(),OPEN_READ); 00064 00065 if (file == 0) { 00066 ORSA_ERROR("Can't open file %s",filename.c_str()); 00067 } else { 00068 status = OPEN_R; 00069 } 00070 }
void Close | ( | ) | [inherited] |
Definition at line 115 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().
virtual std::string GetFileName | ( | ) | const [inline, virtual, inherited] |
Definition at line 99 of file orsa_file.h.
References File::filename.
Referenced by OrsaFile::Read().
00099 { return filename; }
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().
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 }
AsteroidDatabase* db [inherited] |
Definition at line 254 of file orsa_file.h.
Referenced by AstDySMatrixFile::AstDySMatrixFile(), AsteroidDatabaseFile::AsteroidDatabaseFile(), AstorbFile::AstorbFile(), JPLDastcomCometFile::JPLDastcomCometFile(), JPLDastcomNumFile::JPLDastcomNumFile(), JPLDastcomUnnumFile::JPLDastcomUnnumFile(), MPCCometFile::MPCCometFile(), MPCOrbFile::MPCOrbFile(), NEODYSCAT::NEODYSCAT(), NEODYSCAT::Read(), JPLDastcomCometFile::Read(), JPLDastcomUnnumFile::Read(), JPLDastcomNumFile::Read(), AstDySMatrixFile::Read(), MPCCometFile::Read(), MPCOrbFile::Read(), AstorbFile::Read(), AstDySMatrixFile::~AstDySMatrixFile(), AstorbFile::~AstorbFile(), JPLDastcomCometFile::~JPLDastcomCometFile(), JPLDastcomNumFile::~JPLDastcomNumFile(), JPLDastcomUnnumFile::~JPLDastcomUnnumFile(), MPCCometFile::~MPCCometFile(), MPCOrbFile::~MPCOrbFile(), and NEODYSCAT::~NEODYSCAT().
std::string filename [protected, inherited] |
Definition at line 112 of file orsa_file.h.
Referenced by File::GetFileName(), ReadWriteFile::Open(), WriteFile::Open(), ReadFile::Open(), and File::SetFileName().
FILE_TYPE file [protected, inherited] |
Definition at line 113 of file orsa_file.h.
Referenced by SWIFTFile::AsteroidsInFile(), File::Close(), File::File(), ReadWriteFile::Open(), WriteFile::Open(), ReadFile::Open(), Mercury5IntegrationFile::Read(), OrsaFile::Read(), OrsaConfigFile::Read(), SWIFTFile::Read(), LocationFile::Read(), RWOFile::Read(), MPCObsFile::Read(), MPCCometFile::Read(), MPCOrbFile::Read(), AstorbFile::Read(), OrsaFile::Write(), and OrsaConfigFile::Write().
FILE_STATUS status [protected, inherited] |
Definition at line 114 of file orsa_file.h.
Referenced by File::Close(), File::File(), Mercury5IntegrationFile::Mercury5IntegrationFile(), ReadWriteFile::Open(), WriteFile::Open(), ReadFile::Open(), Mercury5IntegrationFile::Read(), TLEFile::Read(), NEODYSCAT::Read(), JPLDastcomCometFile::Read(), JPLDastcomUnnumFile::Read(), JPLDastcomNumFile::Read(), AstDySMatrixFile::Read(), RadauModIntegrationFile::Read(), OrsaFile::Read(), OrsaConfigFile::Read(), SWIFTFile::Read(), LocationFile::Read(), MPCObsFile::Read(), MPCCometFile::Read(), MPCOrbFile::Read(), AstorbFile::Read(), File::SetFileName(), OrsaFile::Write(), and OrsaConfigFile::Write().