LocationFile Class Reference

Locations of the observatories. More...

#include <orsa_file.h>

Inheritance diagram for LocationFile:

Inheritance graph
[legend]
Collaboration diagram for LocationFile:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 LocationFile ()
void Read ()
Vector ObsPos (const std::string, const Date &)
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::map< std::string, Locationlocations
std::list< std::string > codes

Protected Attributes

std::string filename
FILE_TYPE file
FILE_STATUS status

Detailed Description

Locations of the observatories.

Definition at line 200 of file orsa_file.h.


Constructor & Destructor Documentation

LocationFile  ) 
 

Definition at line 1056 of file orsa_file.cc.

01056 : ReadFile() { }


Member Function Documentation

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

00114                    {
00115     if (status != CLOSE) {
00116       CLOSE_FILE(file);
00117       status = CLOSE;
00118     }
00119   }

virtual std::string GetFileName  )  const [inline, virtual, inherited]
 

Definition at line 99 of file orsa_file.h.

References File::filename.

Referenced by LocationFile::ObsPos(), and OrsaFile::Read().

00099 { return filename; }

Vector ObsPos const std::string  ,
const Date
 

Definition at line 1127 of file orsa_file.cc.

References LocationFile::codes, orsa::cos(), orsa::ECLIPTIC, orsa::EquatorialToEcliptic_J2000(), File::GetFileName(), Universe::GetReferenceSystem(), orsa::gmst(), LocationFile::locations, Location::lon, ORSA_ERROR, Location::pxy, Location::pz, Vector::rotate(), orsa::sin(), and orsa::universe.

Referenced by orsa::Compute_Gauss(), orsa::Compute_TestMethod(), OptimizedOrbitPositions::PropagatedSky_J2000(), and orsa::PropagatedSky_J2000().

01127                                                                     {
01128     
01129     std::list<std::string>::iterator it_find = find(codes.begin(),codes.end(),obscode);
01130     if (it_find == codes.end()) {
01131       ORSA_ERROR("obscode %s not found in file %s",obscode.c_str(),GetFileName().c_str());      
01132       return Vector();
01133     }
01134     
01135     const double lon = locations[obscode].lon;
01136     const double pxy = locations[obscode].pxy;
01137     const double pz  = locations[obscode].pz;
01138     
01139 #ifdef HAVE_SINCOS
01140     double s,c;
01141     ::sincos(lon,&s,&c);
01142     Vector obspos(pxy*c,pxy*s,pz);
01143 #else // HAVE_SINCOS    
01144     Vector obspos(pxy*cos(lon),pxy*sin(lon),pz);
01145 #endif // HAVE_SINCOS
01146     
01147     obspos.rotate(gmst(date).GetRad(),0,0);
01148     
01149     if (universe->GetReferenceSystem() == ECLIPTIC) {
01150       EquatorialToEcliptic_J2000(obspos);
01151     }
01152     
01153     return obspos;
01154   }

Here is the call graph for this function:

void Open  )  [inherited]
 

Definition at line 59 of file orsa_file.cc.

References orsa::CLOSE, OPEN_FILE, orsa::OPEN_R, OPEN_READ, and ORSA_ERROR.

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

References LocationFile::codes, orsa::FromUnits(), GETS_FILE, LocationFile::locations, Location::lon, Location::name, ReadFile::Open(), orsa::OPEN_R, ORSA_ERROR, orsa::pi, Location::pxy, Location::pz, orsa::REARTH, orsa::remove_leading_trailing_spaces(), and REWIND_FILE.

01058                           {
01059     
01060     Open();
01061     
01062     if (status != OPEN_R) {
01063       ORSA_ERROR("Status error!");
01064       return;
01065     }
01066     
01067     string obscode,longitude,pos_xy,pos_z,name;
01068     
01069     char line[300];
01070     
01071     Location dummy_loc;
01072     
01073     // dummy_loc.present = true;
01074     
01075     REWIND_FILE(file);
01076     
01077     string stag, spre="<pre>", spreend="</pre>";
01078     char tag[256];
01079     
01080     // reach <pre> and skip header
01081     while (GETS_FILE(line,300,file) != 0) {
01082       sscanf(line,"%s",tag);
01083       stag = tag;
01084       if (stag == spre) {
01085         // skip another line (header) and break;
01086         GETS_FILE(line,300,file);
01087         break;
01088       } 
01089     }
01090     
01091     while (GETS_FILE(line,300,file) != 0) {
01092       
01093       sscanf(line,"%s",tag);
01094       stag = tag;
01095       // cerr << "stag: " << stag << endl;
01096       if (stag == spreend) break;
01097       
01098       if (strlen(line) < 30) continue;
01099       
01100       obscode.assign(line,0,3);
01101       longitude.assign(line,4,8);
01102       pos_xy.assign(line,13,7);
01103       pos_z.assign(line,21,8);
01104       name.assign(line,30,strlen(line)-30-1); // the last -1 is set to avoid the '\n' character in the name
01105       
01106       remove_leading_trailing_spaces(longitude);
01107       remove_leading_trailing_spaces(pos_xy);
01108       remove_leading_trailing_spaces(pos_z);
01109       remove_leading_trailing_spaces(name);
01110       
01111       // set zero values, for locations like SOHO, HST...
01112       dummy_loc.lon = dummy_loc.pxy = dummy_loc.pz = 0.0;
01113       
01114       if (longitude.size()) dummy_loc.lon  = (pi/180.0) * atof(longitude.c_str());
01115       if (pos_xy.size())    dummy_loc.pxy  = FromUnits(atof(pos_xy.c_str()),REARTH);
01116       if (pos_z.size())     dummy_loc.pz   = FromUnits(atof(pos_z.c_str()), REARTH);
01117       //
01118       dummy_loc.name = name;
01119       
01120       locations[obscode] = dummy_loc;
01121       
01122       codes.push_back(obscode);
01123     }
01124     
01125   }

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:

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

std::list<std::string> codes
 

Definition at line 215 of file orsa_file.h.

Referenced by LocationFile::ObsPos(), and LocationFile::Read().

FILE_TYPE file [protected, inherited]
 

Definition at line 113 of file orsa_file.h.

Referenced by File::Close(), and File::File().

std::string filename [protected, inherited]
 

Definition at line 112 of file orsa_file.h.

Referenced by File::GetFileName(), and File::SetFileName().

std::map<std::string,Location> locations
 

Definition at line 211 of file orsa_file.h.

Referenced by LocationFile::ObsPos(), and LocationFile::Read().

FILE_STATUS status [protected, inherited]
 

Definition at line 114 of file orsa_file.h.

Referenced by File::Close(), File::File(), and File::SetFileName().


The documentation for this class was generated from the following files:
Generated on Tue Jan 11 15:28:21 2005 for liborsa by  doxygen 1.4.0