TLEFile Class Reference

#include <orsa_file.h>

Inheritance diagram for TLEFile:

Inheritance graph
[legend]
Collaboration diagram for TLEFile:

Collaboration graph
[legend]

List of all members.

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< BodyWithEpochsat

Protected Attributes

std::string filename
FILE_TYPE file
FILE_STATUS status


Detailed Description

This class is used to read TLE (Two Lines Elements) files describing Earth's artificial satellites.

Definition at line 550 of file orsa_file.h.


Constructor & Destructor Documentation

TLEFile (  ) 

Definition at line 3288 of file orsa_file.cc.

03288                    : ReadFile() {
03289     
03290   }


Member Function Documentation

void Read (  )  [virtual]

Implements ReadFile.

Definition at line 3292 of file orsa_file.cc.

References Orbit::a, orsa::DAY, Orbit::e, orsa::EARTH, orsa::ECLIPTIC, orsa::FromUnits(), orsa::GetG(), Date::GetJulian(), Angle::GetRad(), 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().

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

Here is the call graph for this function:

virtual void read_progress ( int   )  [inline, virtual]

Definition at line 555 of file orsa_file.h.

Referenced by TLEFile::Read().

00555 { };

void Open (  )  [inherited]

void Close (  )  [inherited]

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().

00101                                                         {
00102       if (status != CLOSE) Close();
00103       filename = name_in;
00104     }

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:


Member Data Documentation

std::vector<BodyWithEpoch> sat

Definition at line 555 of file orsa_file.h.

Referenced by TLEFile::Read().

std::string filename [protected, inherited]

FILE_TYPE file [protected, inherited]

FILE_STATUS status [protected, inherited]


The documentation for this class was generated from the following files:

Generated on Thu Feb 14 21:41:54 2008 for liborsa by  doxygen 1.5.5