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 3289 of file orsa_file.cc.

03289                    : ReadFile() {
03290     
03291   }


Member Function Documentation

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; }

void Open (  )  [inherited]
void Read (  )  [virtual]

Implements ReadFile.

Definition at line 3293 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().

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

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 { };

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

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

Here is the call graph for this function:


Member Data Documentation

FILE_TYPE file [protected, inherited]
std::string filename [protected, inherited]
std::vector<BodyWithEpoch> sat

Definition at line 555 of file orsa_file.h.

Referenced by TLEFile::Read().

FILE_STATUS status [protected, inherited]

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

Generated on Fri Nov 6 11:19:55 2009 for liborsa by  doxygen 1.6.1