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