#include <orsa_file.h>
Public Member Functions | |
MPCOrbFile () | |
~MPCOrbFile () | |
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 |
Definition at line 343 of file orsa_file.h.
MPCOrbFile | ( | ) |
Definition at line 381 of file orsa_file.cc.
References AsteroidDatabaseFile::db.
00381 : AsteroidDatabaseFile() { 00382 db = new AsteroidDatabase(); 00383 }
~MPCOrbFile | ( | ) |
void Read | ( | ) | [virtual] |
Implements ReadFile.
Definition at line 390 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.
00390 { 00391 00392 Open(); 00393 00394 if (status != OPEN_R) { 00395 ORSA_ERROR("Status error!"); 00396 return; 00397 } 00398 00399 db->clear(); 00400 00401 // Body orb_ref_body("",GetMSun()); 00402 00403 // unsigned int local_index; 00404 00405 char line[300]; 00406 00407 double a,e,i,omega_node,omega_pericenter,M; 00408 // int n; 00409 string number,name,orbit_computer,absolute_magnitude,arc,numobs,epoch; 00410 string mean_anomaly,pericenter,node,inclination,eccentricity,semimajor_axis; 00411 // string ceu; 00412 00413 string year,month,day; 00414 int y=0,m=0,d=0; 00415 00416 // AstorbDataEntry ast; 00417 Asteroid ast; 00418 00419 unsigned int local_index = 0; 00420 bool bool_stop=false; 00421 bool bool_pause=false; 00422 00423 REWIND_FILE(file); 00424 00425 // Date tmp_date(TDT); 00426 Date tmp_date; 00427 00428 /* // skip header, not needed with the check on (strlen(line) < 201)... 00429 do { 00430 GETS_FILE(line,300,file); 00431 } while (line[0] != '-'); 00432 cerr << "below the header..." << endl; 00433 */ 00434 00435 while ( (GETS_FILE(line,300,file)) != 0 ) { 00436 00437 // cerr << "line: -->" << line << "<--" << endl; 00438 00439 ++local_index; 00440 00441 if (strlen(line) < 201) continue; // not a good line, maybe a comment or a white line... 00442 00443 // cerr << "strlen(line): " << strlen(line) << endl; 00444 00445 // cerr << "line: -->" << line << "<--" << endl; 00446 00447 read_progress(local_index,bool_pause,bool_stop); 00448 00449 if (bool_stop) break; 00450 00451 while (bool_pause) { 00452 sleep(1); 00453 read_progress(local_index,bool_pause,bool_stop); 00454 } 00455 00456 // uncomment the ones used 00457 number.assign(line,0,7); 00458 absolute_magnitude.assign(line,8,5); 00459 epoch.assign(line,20,5); 00460 // 00461 mean_anomaly.assign(line,26,9); 00462 pericenter.assign(line,37,9); 00463 node.assign(line,48,9); 00464 inclination.assign(line,59,9); 00465 eccentricity.assign(line,70,9); 00466 semimajor_axis.assign(line,92,11); 00467 // 00468 numobs.assign(line,117,5); 00469 orbit_computer.assign(line,150,10); 00470 00471 if (strlen(line) > 160) { 00472 name.assign(line,166,28); 00473 } else { 00474 name = ""; 00475 } 00476 00477 // conversions 00478 00479 { 00480 // remove -->(NUMBER)<-- 00481 00482 string::size_type pos_open = name.find("(",0); 00483 string::size_type pos_close = name.find(")",0); 00484 00485 if ( (pos_open != pos_close) && 00486 (pos_open != string::npos) && 00487 (pos_close != string::npos) ) { 00488 00489 name.erase(pos_open,pos_close-pos_open+1); 00490 } 00491 } 00492 // 00493 ast.name = name; 00494 remove_leading_trailing_spaces(ast.name); 00495 00496 // ast.n = 0; // arbitrary, for the moment 00497 ast.n = atoi(number.c_str()); 00498 00499 ast.mag = atof(absolute_magnitude.c_str()); 00500 00501 a = atof(semimajor_axis.c_str()); 00502 e = atof(eccentricity.c_str()); 00503 i = (pi/180)*atof(inclination.c_str()); 00504 omega_node = (pi/180)*atof(node.c_str()); 00505 omega_pericenter = (pi/180)*atof(pericenter.c_str()); 00506 M = (pi/180)*atof(mean_anomaly.c_str()); 00507 00508 ast.orb.a = FromUnits(a,AU); 00509 ast.orb.e = e; 00510 ast.orb.i = i; 00511 ast.orb.omega_node = omega_node; 00512 ast.orb.omega_pericenter = omega_pericenter; 00513 ast.orb.M = M; 00514 00515 int ch; 00516 // cerr << "epoch string: " << epoch << endl; 00517 //// epoch 00518 // year 00519 year.assign(epoch,0,1); 00520 ch = (int)year.c_str()[0]; 00521 // cerr << "ch: " << ch << " " << ((int)('I')) << endl; 00522 switch (ch) { 00523 case 'I': y=1800; break; 00524 case 'J': y=1900; break; 00525 case 'K': y=2000; break; 00526 } 00527 // 00528 year.assign(epoch,1,2); 00529 y += atoi(year.c_str()); 00530 // month 00531 month.assign(epoch,3,1); 00532 ch = (int)month.c_str()[0]; 00533 switch (ch) { 00534 case '1': m=1; break; 00535 case '2': m=2; break; 00536 case '3': m=3; break; 00537 case '4': m=4; break; 00538 case '5': m=5; break; 00539 case '6': m=6; break; 00540 case '7': m=7; break; 00541 case '8': m=8; break; 00542 case '9': m=9; break; 00543 case 'A': m=10; break; 00544 case 'B': m=11; break; 00545 case 'C': m=12; break; 00546 } 00547 // day 00548 day.assign(epoch,4,1); 00549 ch = (int)day.c_str()[0]; 00550 switch (ch) { 00551 case '1': d=1; break; 00552 case '2': d=2; break; 00553 case '3': d=3; break; 00554 case '4': d=4; break; 00555 case '5': d=5; break; 00556 case '6': d=6; break; 00557 case '7': d=7; break; 00558 case '8': d=8; break; 00559 case '9': d=9; break; 00560 case 'A': d=10; break; 00561 case 'B': d=11; break; 00562 case 'C': d=12; break; 00563 case 'D': d=13; break; 00564 case 'E': d=14; break; 00565 case 'F': d=15; break; 00566 case 'G': d=16; break; 00567 case 'H': d=17; break; 00568 case 'I': d=18; break; 00569 case 'J': d=19; break; 00570 case 'K': d=20; break; 00571 case 'L': d=21; break; 00572 case 'M': d=22; break; 00573 case 'N': d=23; break; 00574 case 'O': d=24; break; 00575 case 'P': d=25; break; 00576 case 'Q': d=26; break; 00577 case 'R': d=27; break; 00578 case 'S': d=28; break; 00579 case 'T': d=29; break; 00580 case 'U': d=30; break; 00581 case 'V': d=31; break; 00582 } 00583 // 00584 // cerr << "MPC::Read() --> y: " << y << " m: " << m << " d: " << d << endl; 00585 // ast.orb.time = FromUnits(GregorianToSdn(y,m,d)-0.5,DAY); 00586 tmp_date.SetGregor(y,m,d,TDT); 00587 ast.orb.epoch.SetDate(tmp_date); 00588 00589 // ast.orb.T = sqrt(4*pisq/(GetG()*GetMSun())*pow(FromUnits(ast.orb.a,AU),3)); 00590 ast.orb.mu = GetG()*GetMSun(); 00591 // ast.orb.ref_body.mass=GetMSun(); 00592 // ast.orb.ref_body = Body("",GetMSun()); 00593 // ast.orb.ref_body = orb_ref_body; 00594 00595 /* 00596 switch (universe->GetReferenceSystem()) { 00597 case ECLIPTIC: break; 00598 case EQUATORIAL: 00599 { 00600 // cerr << "Rotating astorb orbit..." << endl; 00601 const double obleq_rad = obleq(tmp_date).GetRad(); 00602 Vector position,velocity; 00603 ast.orb.RelativePosVel(position,velocity); 00604 position.rotate(0.0,obleq_rad,0.0); 00605 velocity.rotate(0.0,obleq_rad,0.0); 00606 ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch); 00607 } 00608 break; 00609 } 00610 */ 00611 00612 switch (universe->GetReferenceSystem()) { 00613 case ECLIPTIC: break; 00614 case EQUATORIAL: 00615 { 00616 Vector position,velocity; 00617 ast.orb.RelativePosVel(position,velocity); 00618 EclipticToEquatorial_J2000(position); 00619 EclipticToEquatorial_J2000(velocity); 00620 ast.orb.Compute(position,velocity,ast.orb.mu,ast.orb.epoch); 00621 } 00622 break; 00623 } 00624 00625 // cerr << "adding object: " << ast.name << " a: " << ast.orb.a << endl; 00626 00627 db->push_back(ast); 00628 00629 } 00630 00631 read_finished(); 00632 }
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 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 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; }
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().