#include <orsa_file.h>
Inheritance diagram for TLEFile:
Public Member Functions | |
TLEFile () | |
void | Read () |
virtual void | read_progress (int) |
void | Open () |
void | Close () |
virtual std::string | GetFileName () const |
virtual void | SetFileName (std::string name_in) |
virtual void | SetFileName (char *name_in) |
Public Attributes | |
std::vector< BodyWithEpoch > | sat |
Protected Attributes | |
std::string | filename |
FILE_TYPE | file |
FILE_STATUS | status |
Definition at line 550 of file orsa_file.h.
TLEFile | ( | ) |
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().
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 59 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().
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 3291 of file orsa_file.cc.
References Orbit::a, orsa::DAY, Orbit::e, orsa::EARTH, orsa::ECLIPTIC, orsa::FromUnits(), orsa::GetG(), Date::GetJulian(), Universe::GetReferenceSystem(), GETS_FILE, Orbit::i, Orbit::M, orsa::M, Body::mass(), MIN, Orbit::mu, orsa::obleq_J2000(), Orbit::omega_node, Orbit::omega_pericenter, ReadFile::Open(), orsa::OPEN_R, ORSA_ERROR, orsa::pi, orsa::pisq, Body::position(), TLEFile::read_progress(), Orbit::RelativePosVel(), orsa::remove_leading_trailing_spaces(), Vector::rotate(), TLEFile::sat, Date::SetGregor(), Date::SetJulian(), File::status, orsa::universe, orsa::UTC, and Body::velocity().
03291 { 03292 Open(); 03293 if (status != OPEN_R) { 03294 ORSA_ERROR("Status error!"); 03295 return; 03296 } 03297 sat.clear(); 03298 string name; 03299 string s_tmp; 03300 int year=0; 03301 double days=0.0; 03302 double inclination=0.0,node=0.0,eccentricity=0.0,peri=0.0,M=0.0,period=0.0; 03303 bool have_one=false; 03304 bool have_two=false; 03305 char line[1024]; 03306 unsigned int local_index = 0; 03307 while (GETS_FILE(line,1024,file) != 0) { 03308 03309 if (line[0] == '1') { 03310 03311 if (strlen(line) < 69) continue; 03312 03313 if (isalpha(line[6])) continue; // test for single chars... 03314 03315 s_tmp.assign(line,18,2); 03316 year = atoi(s_tmp.c_str()); 03317 if (year > 70) 03318 year += 1900; 03319 else 03320 year += 2000; 03321 03322 s_tmp.assign(line,20,12); 03323 days = atof(s_tmp.c_str()); 03324 03325 have_one = true; 03326 have_two = false; 03327 03328 } else if (line[0] == '2') { 03329 03330 if (strlen(line) < 69) continue; 03331 03332 if (!have_one) continue; 03333 03334 if (isalpha(line[6])) continue; // test for single chars... 03335 03336 s_tmp.assign(line,8,8); 03337 inclination = (pi/180.0)*atof(s_tmp.c_str()); 03338 03339 s_tmp.assign(line,17,8); 03340 node = (pi/180.0)*atof(s_tmp.c_str()); 03341 03342 s_tmp.assign(line,26,7); 03343 eccentricity = 1.0e-7*atof(s_tmp.c_str()); 03344 03345 s_tmp.assign(line,34,8); 03346 peri = (pi/180.0)*atof(s_tmp.c_str()); 03347 03348 s_tmp.assign(line,43,8); 03349 M = (pi/180.0)*atof(s_tmp.c_str()); 03350 03351 s_tmp.assign(line,52,11); 03352 period = FromUnits(1.0/atof(s_tmp.c_str()),DAY); 03353 03354 have_two = true; 03355 03356 } else { 03357 name.assign(line,0,MIN(24,strlen(line)-1)); // the last -1 is set to avoid the '\n' character in the name 03358 remove_leading_trailing_spaces(name); 03359 have_one = false; 03360 have_two = false; 03361 } 03362 03363 if (have_one && have_two) { 03364 03365 Date epoch; 03366 epoch.SetGregor(year,1,1,UTC); // UTC? 03367 double jd = epoch.GetJulian(UTC); 03368 jd += days-1.0; 03369 epoch.SetJulian(jd,UTC); 03370 03371 JPLBody Earth(EARTH,epoch); 03372 03373 Orbit orbit; 03374 orbit.mu = GetG()*Earth.mass(); 03375 orbit.a = cbrt(period*period*orbit.mu/(4*pisq)); 03376 orbit.e = eccentricity; 03377 orbit.i = inclination; 03378 orbit.omega_node = node; 03379 orbit.omega_pericenter = peri; 03380 orbit.M = M; 03381 03382 Vector position,velocity; 03383 orbit.RelativePosVel(position,velocity); 03384 03385 if (universe->GetReferenceSystem() == ECLIPTIC) { 03386 Angle obl = obleq_J2000(); 03387 position.rotate(0.0,-obl.GetRad(),0.0); 03388 velocity.rotate(0.0,-obl.GetRad(),0.0); 03389 } 03390 03391 position += Earth.position(); 03392 velocity += Earth.velocity(); 03393 03394 sat.push_back(BodyWithEpoch(name,0.0,position,velocity,epoch)); 03395 03396 ++local_index; 03397 read_progress(local_index); 03398 03399 // cerr << name << " period[DAYS]: " << FromUnits(period,DAY,-1) << " a[ER]: " << FromUnits(orbit.a,ER,-1) << endl; 03400 03401 have_one = have_two = false; 03402 } 03403 } 03404 }
Here is the call graph for this function:
virtual void read_progress | ( | int | ) | [inline, virtual] |
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().
Here is the call graph for this function:
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().
std::vector<BodyWithEpoch> sat |
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().