orsa_file_jpl.h

Go to the documentation of this file.
00001 /* 
00002    ORSA - Orbit Reconstruction, Simulation and Analysis
00003    Copyright (C) 2002-2004 Pasquale Tricarico
00004    
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU General Public License
00007    as published by the Free Software Foundation; either version 2
00008    of the License, or (at your option) any later version.
00009    
00010    As a special exception, Pasquale Tricarico gives permission to
00011    link this program with Qt commercial edition, and distribute the
00012    resulting executable, without including the source code for the Qt
00013    commercial edition in the source distribution.
00014    
00015    This program is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018    GNU General Public License for more details.
00019    
00020    You should have received a copy of the GNU General Public License
00021    along with this program; if not, write to the Free Software
00022    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 */
00024 
00025 #ifndef _ORSA_FILE_JPL_H_
00026 #define _ORSA_FILE_JPL_H_
00027 
00028 namespace orsa {
00029   
00030   enum JPL_planets {
00031     NONE=0,
00032     MERCURY=1,
00033     VENUS=2,
00034     EARTH=3,
00035     MARS=4,
00036     JUPITER=5,
00037     SATURN=6,
00038     URANUS=7,
00039     NEPTUNE=8,
00040     PLUTO=9,
00041     MOON=10,
00042     SUN=11,
00043     SOLAR_SYSTEM_BARYCENTER=12,
00044     EARTH_MOON_BARYCENTER=13,
00045     NUTATIONS=14,
00046     LIBRATIONS=15,
00047     EARTH_AND_MOON=1000
00048   };
00049   // note: EARTH_AND_MOON is only an useful definition, not used in orsa files or by JPL...
00050   // same thing for NONE...
00051   
00052 } // namespace orsa 
00053 
00054 #include <string>
00055 #include <map>
00056 #include <list>
00057 
00058 #include "orsa_units.h"
00059 #include "orsa_coord.h"
00060 // #include "orsa_body.h"
00061 
00062 namespace orsa {
00063   
00064   class Body;
00065   class BodyWithEpoch;
00066   class JPLBody;
00067   class Frame;
00068   class Date;
00069   class UniverseTypeAwareTime;
00070   
00071   inline void convert(JPL_planets & jp, const unsigned int i)  {
00072     switch(i) {
00073     case 0:  jp = NONE;                    break;
00074       //
00075     case 1:  jp = MERCURY;                 break;
00076     case 2:  jp = VENUS;                   break;
00077     case 3:  jp = EARTH;                   break;
00078     case 4:  jp = MARS;                    break;
00079     case 5:  jp = JUPITER;                 break;
00080     case 6:  jp = SATURN;                  break;
00081     case 7:  jp = URANUS;                  break;
00082     case 8:  jp = NEPTUNE;                 break;
00083     case 9:  jp = PLUTO;                   break;
00084     case 10: jp = MOON;                    break;
00085     case 11: jp = SUN;                     break;
00086     case 12: jp = SOLAR_SYSTEM_BARYCENTER; break;
00087     case 13: jp = EARTH_MOON_BARYCENTER;   break;
00088     case 14: jp = NUTATIONS;               break;
00089     case 15: jp = LIBRATIONS;              break;
00090       //
00091     case 1000: jp = EARTH_AND_MOON;        break;
00092       //
00093     default:
00094       ORSA_ERROR("conversion problem: i = %i",i);    
00095       break;
00096     }
00097   }
00098   
00099   //! JPL ephem file  
00100   class JPLFile {
00101   public:
00102     JPLFile(std::string);
00103     ~JPLFile();
00104     
00105   public:
00106     // basic one, just to check if the db is a working JPL ephem file
00107     bool GoodFile() const {
00108       return (jpl_database != 0);
00109     }
00110     
00111   public:
00112     void GetEph(const UniverseTypeAwareTime & date, JPL_planets target, JPL_planets center, Vector & position, Vector & velocity);       
00113     inline void GetEph(const UniverseTypeAwareTime & date, JPL_planets target, Vector & position, Vector & velocity) {
00114       GetEph(date, target, default_ephem_center, position, velocity);       
00115     }
00116     
00117     const UniverseTypeAwareTime & EphemStart();
00118     const UniverseTypeAwareTime & EphemEnd();
00119     
00120     double GetMass(JPL_planets planet);
00121     
00122     double GetAU_MKS();
00123     double GetMSun_MKS();
00124     double GetMJupiter_MKS();
00125     double GetMEarth_MKS();
00126     double GetMMoon_MKS();
00127     double GetC_MKS(); // speed of light
00128     double GetREarth_MKS();
00129     double GetRMoon_MKS();
00130     
00131   public:
00132     double GetTag(std::string);
00133     
00134   private:
00135     std::map <std::string,double> * map_tag;
00136     
00137   private:
00138     bool bool_ephem_start_computed;
00139     bool bool_ephem_end_computed;
00140     void ComputeEphemStart();
00141     void ComputeEphemEnd();
00142     
00143   private:
00144     static const JPL_planets default_ephem_center;
00145     
00146   private:
00147     void * jpl_database;
00148     bool calc_velocity;
00149     // 
00150     UniverseTypeAwareTime ephem_start;
00151     UniverseTypeAwareTime ephem_end;
00152    };  
00153   
00154   // defined in orsa_universe.cc
00155   extern JPLFile * jpl_file;
00156   
00157   class JPLCache {
00158   public:
00159     JPLCache();
00160     ~JPLCache();
00161   public:
00162     const JPLBody & GetJPLBody(const JPL_planets, const UniverseTypeAwareTime &);
00163   public:
00164     void Clear();
00165   private:
00166     typedef std::map <UniverseTypeAwareTime,JPLBody> data_map_type; 
00167     typedef std::map <JPL_planets,data_map_type> big_map_type;
00168     big_map_type big_map;
00169   };
00170   
00171   // defined in orsa_universe.cc
00172   extern JPLCache * jpl_cache;
00173   
00174   // bool is_genuine_planet(const JPL_planets p);
00175   
00176   std::string JPL_planet_name(const JPL_planets p);
00177   
00178   double radius(const JPL_planets p);
00179   
00180   void SetupSolarSystem(Frame &, const std::list<JPL_planets> &, const UniverseTypeAwareTime &);
00181   
00182 } // namespace orsa
00183 
00184 #endif // _ORSA_FILE_JPL_H_

Generated on Wed May 30 13:04:52 2007 for liborsa by  doxygen 1.5.2