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