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
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
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
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
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
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 };
00370
00371 }
00372
00373
00374 #endif //GPSTK_PLANETEPHEMERIS_HPP
00375