SolarSystem.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: SolarSystem.hpp 2293 2010-02-12 18:14:16Z btolman $"
00002 
00014 // ======================================================================
00015 // This software was developed by Applied Research Laboratories, The
00016 // University of Texas at Austin under contract to an agency or agencies
00017 // within the U.S. Department of Defense. The U.S. Government retains all
00018 // rights to use, duplicate, distribute, disclose, or release this
00019 // software.
00020 // 
00021 // Copyright 2008 The University of Texas at Austin
00022 // ======================================================================
00023 
00024 //------------------------------------------------------------------------------------
00025 #ifndef SOLAR_SYSTEM_EPHEMERIS_INCLUDE
00026 #define SOLAR_SYSTEM_EPHEMERIS_INCLUDE
00027 
00028 //------------------------------------------------------------------------------------
00029 // includes
00030 // system
00031 #include <iostream>
00032 #include <fstream>
00033 #include <string>
00034 #include <vector>
00035 #include <map>
00036 
00037 // GPSTk
00038 #include "Exception.hpp"
00039 #include "DayTime.hpp"             // only for WGS84SolarSystemPosition()
00040 #include "Position.hpp"            // only for WGS84SolarSystemPosition()
00041 #include "EarthOrientation.hpp"    // only for WGS84SolarSystemPosition()
00042 
00043 namespace gpstk {
00044 //------------------------------------------------------------------------------------
00067 class SolarSystem{
00068 public:
00070    enum Planet {
00071       // the following are relative to the solar system barycenter, except MOON
00072       None=0,                
00073       Mercury,               
00074       Venus,                 
00075       Earth,                 
00076       Mars,                  
00077       Jupiter,               
00078       Saturn,                
00079       Uranus,                
00080       Neptune,               
00081       Pluto,                 
00082       Moon,                  
00083       Sun,                   
00084       SolarSystemBarycenter, 
00085       EarthMoonBarycenter,   
00086       Nutations,             
00087       Librations             
00088    };
00089 
00092    SolarSystem(void) throw() : EphemerisNumber(-1) {};
00093 
00101    void readASCIIheader(std::string filename) throw(gpstk::Exception);
00102 
00116    int readASCIIdata(std::vector<std::string>& filenames) throw(gpstk::Exception);
00117 
00126    int readASCIIdata(std::string filename) throw(gpstk::Exception);
00127 
00132    int writeASCIIheader(std::ostream& os) throw(gpstk::Exception);
00133 
00139    int writeASCIIdata(std::ostream& os) throw(gpstk::Exception);
00140 
00147    int writeBinaryFile(std::string filename) throw(gpstk::Exception);
00148 
00151    void clearStorage(void) throw() { store.clear(); }
00152 
00161    int readBinaryFile(std::string filename) throw(gpstk::Exception);
00162 
00171    int initializeWithBinaryFile(std::string filename) throw(gpstk::Exception);
00172 
00202    int computeState(double tt,
00203                               Planet target,
00204                               Planet center,
00205                               double PV[6],
00206                               bool kilometers = true)
00207    throw(gpstk::Exception);
00208 
00213    double AU(void) throw()
00214    { if(EphemerisNumber == -1) return -1.0; return constants["AU"]; }
00215 
00219    int JPLNumber(void) const throw()
00220    { return EphemerisNumber; }
00221 
00224    double getConstant(std::string name) throw() {
00225       if(EphemerisNumber == -1) return -1.0;
00226       if(constants.find(name) != constants.end()) return constants[name];
00227       return 0.0;
00228    }
00229 
00231    gpstk::DayTime startTime(void) const throw(gpstk::Exception)
00232       { gpstk::DayTime t; t.setMJD(startJD - gpstk::DayTime::JD_TO_MJD); return t; }
00233 
00235    gpstk::DayTime endTime(void) const throw(gpstk::Exception)
00236       { gpstk::DayTime t; t.setMJD(endJD - gpstk::DayTime::JD_TO_MJD); return t; }
00237 
00244    gpstk::Position WGS84Position(Planet body,
00245                                  const gpstk::DayTime time,
00246                                  const gpstk::EarthOrientation& eo)
00247       throw(gpstk::Exception);
00248 
00249 private:
00252    void writeBinary(std::ofstream& strm, const char *ptr, size_t size)
00253       throw(gpstk::Exception);
00254 
00257    void readBinary(char *ptr, size_t size) throw(gpstk::Exception);
00258 
00262    void readBinaryHeader(std::string filename) throw(gpstk::Exception);
00263 
00272    int readBinaryData(bool save) throw(gpstk::Exception);
00273 
00280    int readBinaryRecord(std::vector<double>& data_vector) throw(gpstk::Exception);
00281 
00285    enum computeID {
00286       // the following are relative to the solar system barycenter, except MOON
00287       NONE=-1,        
00288       MERCURY,        
00289       VENUS,          
00290       EMBARY,         
00291       MARS,           
00292       JUPITER,        
00293       SATURN,         
00294       URANUS,         
00295       NEPTUNE,        
00296       PLUTO,          
00297       MOON,           
00298       SUN,            
00299       NUTATIONS,      
00300       LIBRATIONS      
00301    };
00302 
00313    int seekToJD(double JD) throw(gpstk::Exception);
00314 
00326    void computeState(double tt, computeID which, double PV[6])
00327       throw(gpstk::Exception);
00328 
00329    // member data ---------------------------------------------------------
00330 
00331    // input stream, for use by readBinary...()
00332    std::ifstream istrm;  
00333 
00334    // header information
00339    int EphemerisNumber;
00342    int Ncoeff;
00343    int Nconst;           
00344    std::string label[3]; 
00345    double startJD;       
00346    double endJD;         
00347    double interval;      
00348    int c_offset[13];     
00349    int c_ncoeff[13];     
00350    int c_nsets[13];      
00351 
00379    std::map<std::string,double> constants;
00380 
00384    std::map<double, std::vector<double> > store;
00385 
00389    std::map<double, long> fileposMap;
00390 
00393    std::vector<double> coefficients;
00394 
00395 }; // end class SolarSystem
00396 
00397 }  // end namespace gpstk
00398 
00399 #endif // SOLAR_SYSTEM_EPHEMERIS_INCLUDE
00400 // nothing below this

Generated on Wed Feb 8 03:31:02 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1