00001 #pragma ident "$Id: SolarSystem.hpp 2293 2010-02-12 18:14:16Z btolman $"
00002
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SOLAR_SYSTEM_EPHEMERIS_INCLUDE
00026 #define SOLAR_SYSTEM_EPHEMERIS_INCLUDE
00027
00028
00029
00030
00031 #include <iostream>
00032 #include <fstream>
00033 #include <string>
00034 #include <vector>
00035 #include <map>
00036
00037
00038 #include "Exception.hpp"
00039 #include "DayTime.hpp"
00040 #include "Position.hpp"
00041 #include "EarthOrientation.hpp"
00042
00043 namespace gpstk {
00044
00067 class SolarSystem{
00068 public:
00070 enum Planet {
00071
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
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
00330
00331
00332 std::ifstream istrm;
00333
00334
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 };
00396
00397 }
00398
00399 #endif // SOLAR_SYSTEM_EPHEMERIS_INCLUDE
00400