PlanetEphemeris.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: PlanetEphemeris.hpp 2950 2011-10-27 16:21:52Z yanweignss $"
00002 
00008 #ifndef GPSTK_PLANETEPHEMERIS_HPP
00009 #define GPSTK_PLANETEPHEMERIS_HPP
00010 
00011 //============================================================================
00012 //
00013 //  This file is part of GPSTk, the GPS Toolkit.
00014 //
00015 //  The GPSTk is free software; you can redistribute it and/or modify
00016 //  it under the terms of the GNU Lesser General Public License as published
00017 //  by the Free Software Foundation; either version 2.1 of the License, or
00018 //  any later version.
00019 //
00020 //  The GPSTk is distributed in the hope that it will be useful,
00021 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 //  GNU Lesser General Public License for more details.
00024 //
00025 //  You should have received a copy of the GNU Lesser General Public
00026 //  License along with GPSTk; if not, write to the Free Software Foundation,
00027 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 //
00029 //  Wei Yan - Chinese Academy of Sciences . 2011
00030 //
00031 //============================================================================
00032 
00033 #include <iostream>
00034 #include <fstream>
00035 #include <string>
00036 #include <vector>
00037 #include <map>
00038 
00039 #include "Exception.hpp"
00040 #include "DayTime.hpp" 
00041 #include "Position.hpp"           
00042 
00043 namespace gpstk
00044 {
00049    class PlanetEphemeris
00050    {
00051    public:
00053       enum Planet {
00054          // the following are relative to the solar system barycenter, except MOON
00055          None=0,                
00056          Mercury,               
00057          Venus,                 
00058          Earth,                 
00059          Mars,                  
00060          Jupiter,               
00061          Saturn,                
00062          Uranus,                
00063          Neptune,               
00064          Pluto,                 
00065          Moon,                  
00066          Sun,                   
00067          SolarSystemBarycenter, 
00068          EarthMoonBarycenter,   
00069          Nutations,             
00070          Librations             
00071       };
00072 
00075       PlanetEphemeris(void) throw() : EphemerisNumber(-1) {};
00076 
00084       void readASCIIheader(std::string filename) throw(gpstk::Exception);
00085 
00099       int readASCIIdata(std::vector<std::string>& filenames) throw(gpstk::Exception);
00100 
00109       int readASCIIdata(std::string filename) throw(gpstk::Exception);
00110 
00115       int writeASCIIheader(std::ostream& os) throw(gpstk::Exception);
00116 
00122       int writeASCIIdata(std::ostream& os) throw(gpstk::Exception);
00123 
00130       int writeBinaryFile(std::string filename) throw(gpstk::Exception);
00131 
00134       void clearStorage(void) throw() { store.clear(); }
00135 
00144       int readBinaryFile(std::string filename) throw(gpstk::Exception);
00145 
00154       int initializeWithBinaryFile(std::string filename) throw(gpstk::Exception);
00155 
00185       int computeState(double tt,
00186          Planet target,
00187          Planet center,
00188          double PV[6],
00189          bool kilometers = true)
00190          throw(gpstk::Exception);
00191 
00196       double AU(void) throw()
00197       { if(EphemerisNumber == -1) return -1.0; return constants["AU"]; }
00198 
00202       int JPLNumber(void) const throw()
00203       { return EphemerisNumber; }
00204 
00207       double getConstant(std::string name) throw() {
00208          if(EphemerisNumber == -1) return -1.0;
00209          if(constants.find(name) != constants.end()) return constants[name];
00210          return 0.0;
00211       }
00212 
00214       gpstk::DayTime startTime(void) const throw(gpstk::Exception)
00215       { gpstk::DayTime t; t.setMJD(startJD - gpstk::DayTime::JD_TO_MJD); return t; }
00216 
00218       gpstk::DayTime endTime(void) const throw(gpstk::Exception)
00219       { gpstk::DayTime t; t.setMJD(endJD - gpstk::DayTime::JD_TO_MJD); return t; }
00220 
00221 
00222    private:
00225       void writeBinary(std::ofstream& strm, const char *ptr, size_t size)
00226          throw(gpstk::Exception);
00227 
00230       void readBinary(char *ptr, size_t size) throw(gpstk::Exception);
00231 
00235       void readBinaryHeader(std::string filename) throw(gpstk::Exception);
00236 
00245       int readBinaryData(bool save) throw(gpstk::Exception);
00246 
00253       int readBinaryRecord(std::vector<double>& data_vector) throw(gpstk::Exception);
00254 
00258       enum computeID {
00259          // the following are relative to the solar system barycenter, except MOON
00260          NONE=-1,        
00261          MERCURY,        
00262          VENUS,          
00263          EMBARY,         
00264          MARS,           
00265          JUPITER,        
00266          SATURN,         
00267          URANUS,         
00268          NEPTUNE,        
00269          PLUTO,          
00270          MOON,           
00271          SUN,            
00272          NUTATIONS,      
00273          LIBRATIONS      
00274       };
00275 
00286       int seekToJD(double JD) throw(gpstk::Exception);
00287 
00299       void computeState(double tt, computeID which, double PV[6])
00300          throw(gpstk::Exception);
00301 
00302       // member data ---------------------------------------------------------
00303 
00305       std::ifstream istrm;  
00306 
00312       int EphemerisNumber;
00313 
00316       int Ncoeff;
00317       int Nconst;           
00318       std::string label[3]; 
00319       double startJD;       
00320       double endJD;         
00321       double interval;      
00322       int c_offset[13];     
00323       int c_ncoeff[13];     
00324       int c_nsets[13];      
00325 
00353       std::map<std::string,double> constants;
00354 
00358       std::map<double, std::vector<double> > store;
00359 
00363       std::map<double, long> fileposMap;
00364 
00367       std::vector<double> coefficients;
00368 
00369    }; // end class PlanetEphemeris
00370  
00371 }   // End of namespace gpstk
00372 
00373 
00374 #endif  //GPSTK_PLANETEPHEMERIS_HPP
00375 

Generated on Tue May 22 03:31:00 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1