Merge lp:~registry/stellarium/socis2015-de430 into lp:stellarium

Proposed by gzotti
Status: Merged
Merged at revision: 8132
Proposed branch: lp:~registry/stellarium/socis2015-de430
Merge into: lp:stellarium
Diff against target: 3100 lines (+2424/-282)
24 files modified
.bzrignore (+4/-1)
data/default_config.ini.cmake (+4/-0)
src/CMakeLists.txt (+12/-2)
src/StelMainView.cpp (+3/-0)
src/core/StelCore.cpp (+80/-0)
src/core/StelCore.hpp (+16/-0)
src/core/modules/SolarSystem.cpp (+1/-1)
src/core/planetsephems/EphemWrapper.cpp (+400/-0)
src/core/planetsephems/EphemWrapper.hpp (+92/-0)
src/core/planetsephems/README.txt (+54/-0)
src/core/planetsephems/de430.cpp (+120/-0)
src/core/planetsephems/de430.hpp (+44/-0)
src/core/planetsephems/de431.cpp (+119/-0)
src/core/planetsephems/de431.hpp (+44/-0)
src/core/planetsephems/jpl_int.h (+106/-0)
src/core/planetsephems/jpleph.cpp (+978/-0)
src/core/planetsephems/jpleph.h (+117/-0)
src/core/planetsephems/pluto.h (+11/-0)
src/core/planetsephems/stellplanet.c (+0/-136)
src/core/planetsephems/stellplanet.h (+0/-77)
src/core/planetsephems/vsop87.h (+0/-9)
src/gui/ConfigurationDialog.cpp (+120/-40)
src/gui/ConfigurationDialog.hpp (+18/-4)
src/gui/configurationDialog.ui (+81/-12)
To merge this branch: bzr merge lp:~registry/stellarium/socis2015-de430
Reviewer Review Type Date Requested Status
Alexander Wolf Approve
Review via email: mp+282847@code.launchpad.net

Description of the change

A nice new feature for (pre)historical sky simulation or people needing extra accuracy. Thanks to support by ESA SoCiS2015 we have now optional access to precomputed planetary positions from NASA/JPL.

DE430&431 currently require manual download of data files. If files are available already, it is possible to use files from configured directory. Downloading should be integrated to the coming download manager.

More info in the branch description.

To post a comment you must log in.
7760. By gzotti

cleanup a bit

Revision history for this message
Alexander Wolf (alexwolf) wrote :

I think GUI for VSOP/DE should be changed - using checkbox and chooser of the file for ephemeris files instead buttons seems better, IMHO.

Revision history for this message
Alexander Wolf (alexwolf) :
review: Approve
Revision history for this message
gzotti (georg-zotti) wrote :

I don't want to add a file chooser here. I describe how to install files in the guide, and with the download manager on its way this will be replaced anyway soon.
Maybe changing to checkbox is more like the rest of GUI, I will do that.

7761. By gzotti

replaced DE43x buttons by checkboxes, some more cleanup

7762. By gzotti

removed unneeded manifest file

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2016-01-10 23:15:27 +0000
+++ .bzrignore 2016-01-16 17:00:50 +0000
@@ -1,20 +1,22 @@
1builds1builds
2build
2installers3installers
3.DS_Store4.DS_Store
4CMakeLists.txt.user5CMakeLists.txt.user
5Stellarium.bat6Stellarium.bat
6stellarium.iss7stellarium.iss
7stellarium-patch.iss8stellarium-patch.iss
9stellarium.exe.manifest
8./doc/qt.tag10./doc/qt.tag
9./locale11./locale
10./util/locations-editor/Makefile12./util/locations-editor/Makefile
11./util/locations-editor/locations-editor13./util/locations-editor/locations-editor
12./util/locations-editor/locations-editor.pro.user14./util/locations-editor/locations-editor.pro.user
13./util/copy-translations.bat15./util/copy-translations.bat
14build
15./plugins/Observability/doc16./plugins/Observability/doc
16default_config.ini17default_config.ini
17updates.json18updates.json
19data/Info.plist
18guide/*.aux20guide/*.aux
19guide/*.log21guide/*.log
20guide/*.idx22guide/*.idx
@@ -24,4 +26,5 @@
24guide/*.xml26guide/*.xml
25guide/*.synctex.gz27guide/*.synctex.gz
26* - Kopie.*28* - Kopie.*
29*.~
2730
2831
=== modified file 'data/default_config.ini.cmake'
--- data/default_config.ini.cmake 2015-12-07 23:46:23 +0000
+++ data/default_config.ini.cmake 2016-01-16 17:00:50 +0000
@@ -264,6 +264,10 @@
264planet_magnitude_limit = 6.5264planet_magnitude_limit = 6.5
265flag_nebula_magnitude_limit = false265flag_nebula_magnitude_limit = false
266nebula_magnitude_limit = 8.5266nebula_magnitude_limit = 8.5
267flag_use_de430 = false
268flag_use_de431 = false
269de430_path = ""
270de431_path = ""
267271
268[init_location]272[init_location]
269location = auto273location = auto
270274
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2016-01-11 16:48:05 +0000
+++ src/CMakeLists.txt 2016-01-16 17:00:50 +0000
@@ -178,12 +178,22 @@
178 core/planetsephems/precession.h178 core/planetsephems/precession.h
179 core/planetsephems/sidereal_time.c179 core/planetsephems/sidereal_time.c
180 core/planetsephems/sidereal_time.h180 core/planetsephems/sidereal_time.h
181 core/planetsephems/stellplanet.c181 #core/planetsephems/stellplanet.c # replaced by EphemWrapper during de430 work
182 core/planetsephems/stellplanet.h182 #core/planetsephems/stellplanet.h
183 core/planetsephems/jpl_int.h
184 core/planetsephems/jpleph.h
185 core/planetsephems/jpleph.cpp
186 core/planetsephems/EphemWrapper.cpp
187 core/planetsephems/EphemWrapper.hpp
188
183 core/planetsephems/tass17.c189 core/planetsephems/tass17.c
184 core/planetsephems/tass17.h190 core/planetsephems/tass17.h
185 core/planetsephems/vsop87.c191 core/planetsephems/vsop87.c
186 core/planetsephems/vsop87.h192 core/planetsephems/vsop87.h
193 core/planetsephems/de430.cpp
194 core/planetsephems/de430.hpp
195 core/planetsephems/de431.cpp
196 core/planetsephems/de431.hpp
187197
188 core/modules/Atmosphere.cpp198 core/modules/Atmosphere.cpp
189 core/modules/Atmosphere.hpp199 core/modules/Atmosphere.hpp
190200
=== modified file 'src/StelMainView.cpp'
--- src/StelMainView.cpp 2015-11-22 00:16:28 +0000
+++ src/StelMainView.cpp 2016-01-16 17:00:50 +0000
@@ -620,6 +620,9 @@
620 // plugins, because the gui create the QActions needed by some plugins.620 // plugins, because the gui create the QActions needed by some plugins.
621 StelApp::getInstance().initPlugIns();621 StelApp::getInstance().initPlugIns();
622622
623 // activate DE430/431
624 StelApp::getInstance().getCore()->initEphemeridesFunctions();
625
623 // The script manager can only be fully initialized after the plugins have loaded.626 // The script manager can only be fully initialized after the plugins have loaded.
624 StelApp::getInstance().initScriptMgr();627 StelApp::getInstance().initScriptMgr();
625628
626629
=== modified file 'src/core/StelCore.cpp'
--- src/core/StelCore.cpp 2016-01-06 15:10:45 +0000
+++ src/core/StelCore.cpp 2016-01-16 17:00:50 +0000
@@ -37,12 +37,17 @@
37#include "LandscapeMgr.hpp"37#include "LandscapeMgr.hpp"
38#include "StelTranslator.hpp"38#include "StelTranslator.hpp"
39#include "StelActionMgr.hpp"39#include "StelActionMgr.hpp"
40#include "StelFileMgr.hpp"
41#include "EphemWrapper.hpp"
40#include "precession.h"42#include "precession.h"
4143
42#include <QSettings>44#include <QSettings>
43#include <QDebug>45#include <QDebug>
44#include <QMetaEnum>46#include <QMetaEnum>
4547
48#include <iostream>
49#include <fstream>
50
46// Init statics transfo matrices51// Init statics transfo matrices
47// See vsop87.doc:52// See vsop87.doc:
48const Mat4d StelCore::matJ2000ToVsop87(Mat4d::xrotation(-23.4392803055555555556*(M_PI/180)) * Mat4d::zrotation(0.0000275*(M_PI/180)));53const Mat4d StelCore::matJ2000ToVsop87(Mat4d::xrotation(-23.4392803055555555556*(M_PI/180)) * Mat4d::zrotation(0.0000275*(M_PI/180)));
@@ -73,6 +78,10 @@
73 , jdOfLastJDUpdate(0.)78 , jdOfLastJDUpdate(0.)
74 , deltaTCustomNDot(-26.0)79 , deltaTCustomNDot(-26.0)
75 , deltaTCustomYear(1820.0)80 , deltaTCustomYear(1820.0)
81 , de430Available(false)
82 , de431Available(false)
83 , de430Active(false)
84 , de431Active(false)
76{85{
77 toneReproducer = new StelToneReproducer();86 toneReproducer = new StelToneReproducer();
7887
@@ -1928,3 +1937,74 @@
1928{1937{
1929 return 2000.0 + (getJD() - 2451545.0)/365.25;1938 return 2000.0 + (getJD() - 2451545.0)/365.25;
1930}1939}
1940
1941// DE430/DE431 handling
1942
1943bool StelCore::de430IsAvailable()
1944{
1945 return de430Available;
1946}
1947
1948bool StelCore::de431IsAvailable()
1949{
1950 return de431Available;
1951}
1952
1953bool StelCore::de430IsActive()
1954{
1955 return de430Active;
1956}
1957
1958bool StelCore::de431IsActive()
1959{
1960 return de431Active;
1961}
1962
1963void StelCore::setDe430Active(bool status)
1964{
1965 de430Active = de430Available && status;
1966}
1967
1968void StelCore::setDe431Active(bool status)
1969{
1970 de431Active = de431Available && status;
1971}
1972
1973void StelCore::initEphemeridesFunctions()
1974{
1975 QSettings* conf = StelApp::getInstance().getSettings();
1976
1977 QString de430ConfigPath = conf->value("astro/de430_path").toString();
1978 QString de431ConfigPath = conf->value("astro/de431_path").toString();
1979
1980 QString de430FilePath;
1981 QString de431FilePath;
1982
1983 //<-- DE430 -->
1984 if(de430ConfigPath.remove(QChar('"')).isEmpty())
1985 de430FilePath = StelFileMgr::findFile("ephem/" + QString(DE430_FILENAME), StelFileMgr::File);
1986 else
1987 de430FilePath = StelFileMgr::findFile(de430ConfigPath, StelFileMgr::File);
1988
1989 de430Available=!de430FilePath.isEmpty();
1990 if(de430Available)
1991 {
1992 qDebug() << "DE430 at: " << de430FilePath;
1993 EphemWrapper::init_de430(de430FilePath.toStdString().c_str());
1994 }
1995 setDe430Active(de430Available && conf->value("astro/flag_use_de430").toBool());
1996
1997 //<-- DE431 -->
1998 if(de431ConfigPath.remove(QChar('"')).isEmpty())
1999 de431FilePath = StelFileMgr::findFile("ephem/" + QString(DE431_FILENAME), StelFileMgr::File);
2000 else
2001 de431FilePath = StelFileMgr::findFile(de431ConfigPath, StelFileMgr::File);
2002
2003 de431Available=!de431FilePath.isEmpty();
2004 if(de431Available)
2005 {
2006 qDebug() << "DE431 at: " << de431FilePath;
2007 EphemWrapper::init_de431(de431FilePath.toStdString().c_str());
2008 }
2009 setDe431Active(de431Available && conf->value("astro/flag_use_de431").toBool());
2010}
19312011
=== modified file 'src/core/StelCore.hpp'
--- src/core/StelCore.hpp 2015-12-29 12:14:13 +0000
+++ src/core/StelCore.hpp 2016-01-16 17:00:50 +0000
@@ -584,6 +584,16 @@
584 //! Get coefficients for custom equation for calculation of Delta-T584 //! Get coefficients for custom equation for calculation of Delta-T
585 Vec3f getDeltaTCustomEquationCoefficients() const { return deltaTCustomEquationCoeff; }585 Vec3f getDeltaTCustomEquationCoefficients() const { return deltaTCustomEquationCoeff; }
586586
587 //! initialize ephemerides calculation functions
588 void initEphemeridesFunctions();
589
590 bool de430IsAvailable(); //!< true if DE430 ephemeris file has been found
591 bool de431IsAvailable(); //!< true if DE431 ephemeris file has been found
592 bool de430IsActive(); //!< true if DE430 ephemeris is in use
593 bool de431IsActive(); //!< true if DE431 ephemeris is in use
594 void setDe430Active(bool status); //!< switch DE430 use to @param status (if de430IsAvailable()) DE430 is only used if date is within range of DE430.
595 void setDe431Active(bool status); //!< switch DE431 use to @param status (if de431IsAvailable()). DE431 is only used if DE430 is not used and the date is within range of DE431.
596
587signals:597signals:
588 //! This signal is emitted when the observer location has changed.598 //! This signal is emitted when the observer location has changed.
589 void locationChanged(StelLocation);599 void locationChanged(StelLocation);
@@ -653,6 +663,12 @@
653 float deltaTCustomNDot;663 float deltaTCustomNDot;
654 float deltaTCustomYear;664 float deltaTCustomYear;
655665
666 // Variables for DE430/431 ephem calculation
667 bool de430Available; // ephem file found
668 bool de431Available; // ephem file found
669 bool de430Active; // available and user-activated.
670 bool de431Active; // available and user-activated.
671
656};672};
657673
658#endif // _STELCORE_HPP_674#endif // _STELCORE_HPP_
659675
=== modified file 'src/core/modules/SolarSystem.cpp'
--- src/core/modules/SolarSystem.cpp 2015-12-09 11:01:21 +0000
+++ src/core/modules/SolarSystem.cpp 2016-01-16 17:00:50 +0000
@@ -21,7 +21,7 @@
2121
22#include "SolarSystem.hpp"22#include "SolarSystem.hpp"
23#include "StelTexture.hpp"23#include "StelTexture.hpp"
24#include "stellplanet.h"24#include "EphemWrapper.hpp"
25#include "Orbit.hpp"25#include "Orbit.hpp"
2626
27#include "StelProjector.hpp"27#include "StelProjector.hpp"
2828
=== added file 'src/core/planetsephems/EphemWrapper.cpp'
--- src/core/planetsephems/EphemWrapper.cpp 1970-01-01 00:00:00 +0000
+++ src/core/planetsephems/EphemWrapper.cpp 2016-01-16 17:00:50 +0000
@@ -0,0 +1,400 @@
1/*
2Copyright (C) 2003 Fabien Chereau
3Copyright (C) 2015 Holger Niessner
4Copyright (C) 2015 Georg Zotti
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU Library General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
19*/
20
21#include "EphemWrapper.hpp"
22#include "StelApp.hpp"
23#include "StelCore.hpp"
24#include "vsop87.h"
25#include "elp82b.h"
26#include "marssat.h"
27#include "l1.h"
28#include "tass17.h"
29#include "gust86.h"
30#include "de431.hpp"
31#include "de430.hpp"
32#include "pluto.h"
33
34#define EPHEM_MERCURY_ID 0
35#define EPHEM_VENUS_ID 1
36#define EPHEM_EMB_ID 2
37#define EPHEM_MARS_ID 3
38#define EPHEM_JUPITER_ID 4
39#define EPHEM_SATURN_ID 5
40#define EPHEM_URANUS_ID 6
41#define EPHEM_NEPTUNE_ID 7
42#define EPHEM_PLUTO_ID 8
43
44// GZ No idea what IMD stands for?
45//#define EPHEM_IMD_EARTH_ID 2
46#define EPHEM_JPL_EARTH_ID 3
47#define EPHEM_JPL_PLUTO_ID 9
48#define EPHEM_JPL_MOON_ID 10
49#define EPHEM_JPL_SUN_ID 11
50
51/** JPL PLANET ID LIST
52** 1 = mercury 8 = neptune **
53** 2 = venus 9 = pluto **
54** 3 = earth 10 = moon **
55** 4 = mars 11 = sun **
56** 5 = jupiter 12 = solar-system barycenter **
57** 6 = saturn 13 = earth-moon barycenter **
58** 7 = uranus
59**/
60
61void EphemWrapper::init_de430(const char* filepath)
62{
63 InitDE430(filepath);
64}
65
66void EphemWrapper::init_de431(const char* filepath)
67{
68 InitDE431(filepath);
69}
70
71bool jd_fits_de431(const double jd)
72{
73 //Correct limits found via jpl_get_double(). Limits hardcoded to avoid calls each time.
74 //return !(jd < -3027215.5 || jd > 7930192.5);
75 //This limits inside those where sun can jump between ecliptic of date and ecliptic2000.
76 // We lose a month in -13000 and a few months in +17000, this should not matter.
77 return ((jd > -3027188.25 ) && (jd < 7930056.87916));
78}
79
80bool jd_fits_de430(const double jd)
81{
82 //return !(jd < 2287184.5 || jd > 2688974.5);
83 //return !(jd < 2287184.5 || jd > 2688976.5);
84 return ((jd > 2287184.5) && (jd < 2688976.5));
85}
86
87bool use_de430(const double jd)
88{
89 return StelApp::getInstance().getCore()->de430IsActive() &&
90 jd_fits_de430(jd);
91}
92
93bool use_de431(const double jd)
94{
95 return StelApp::getInstance().getCore()->de431IsActive() &&
96 jd_fits_de431(jd);
97}
98
99// planet_id is ONLY one of the #defined values 0..8 above.
100void get_planet_helio_coordsv(const double jd, double xyz[3], const int planet_id)
101{
102 bool deOk=false;
103 if(!std::isfinite(jd))
104 {
105 qDebug() << "get_planet_helio_coordsv(): SKIPPED CoordCalc, jd is infinite/nan: " << jd;
106 return;
107 }
108
109 if(use_de430(jd))
110 {
111 deOk=GetDe430Coor(jd, planet_id + 1, xyz);
112 }
113 else if(use_de431(jd))
114 {
115 deOk=GetDe431Coor(jd, planet_id + 1, xyz);
116 }
117 if (!deOk) //VSOP87 as fallback
118 {
119 GetVsop87Coor(jd, planet_id, xyz);
120 }
121}
122
123// Osculating positions for time JDE in elements for JDE0, if possible by the theory used (e.g. VSOP87).
124// For ephemerides like DE4xx, JDE0 is irrelevant.
125void get_planet_helio_osculating_coordsv(double jd0, double jd, double xyz[3], int planet_id)
126{
127 bool deOk=false;
128 if(!(std::isfinite(jd) && std::isfinite(jd0)))
129 {
130 qDebug() << "get_planet_helio_osculating_coordsv(): SKIPPED CoordCalc, jd0 or jd is infinite/nan. jd0:" << jd0 << "jd: "<< jd;
131 return;
132 }
133
134 if(use_de430(jd))
135 {
136 deOk=GetDe430Coor(jd, planet_id + 1, xyz);
137 }
138 else if(use_de431(jd))
139 {
140 deOk=GetDe431Coor(jd, planet_id + 1, xyz);
141 }
142 if (!deOk) //VSOP87 as fallback
143 {
144 GetVsop87OsculatingCoor(jd0, jd, planet_id, xyz);
145 }
146}
147
148/* Chapter 31 Pg 206-207 Equ 31.1 31.2, 31.3 using VSOP 87
149 * Calculate Pluto's rectangular heliocentric ecliptical coordinates
150 * for given Julian Day. Values are in AU.
151 * params : Julian day, rect coords */
152
153void get_pluto_helio_coordsv(double jd,double xyz[3], void* unused)
154{
155 Q_UNUSED(unused);
156 bool deOk=false;
157 if(!std::isfinite(jd))
158 {
159 qDebug() << "get_pluto_helio_coordsv(): SKIPPED PlutoCoordCalc, jd is infinite/nan:" << jd;
160 return;
161 }
162
163 if(use_de430(jd))
164 {
165 deOk=GetDe430Coor(jd, EPHEM_JPL_PLUTO_ID, xyz);
166 }
167 else if(use_de431(jd))
168 {
169 deOk=GetDe431Coor(jd, EPHEM_JPL_PLUTO_ID, xyz);
170 }
171 if (!deOk) // fallback to previous solution
172 {
173 get_pluto_helio_coords(jd, &xyz[0], &xyz[1], &xyz[2]);
174 }
175}
176
177/* Return 0 for the sun */
178void get_sun_helio_coordsv(double jd,double xyz[3], void* unused)
179{
180 xyz[0]=0.; xyz[1]=0.; xyz[2]=0.;
181}
182
183void get_mercury_helio_coordsv(double jd,double xyz[3], void* unused)
184{
185 get_planet_helio_coordsv(jd, xyz, EPHEM_MERCURY_ID);
186}
187void get_venus_helio_coordsv(double jd,double xyz[3], void* unused)
188{
189 get_planet_helio_coordsv(jd, xyz, EPHEM_VENUS_ID);
190}
191
192void get_earth_helio_coordsv(const double jd,double xyz[3], void* unused)
193{
194 bool deOk=false;
195 if(!std::isfinite(jd))
196 {
197 qDebug() << "get_earth_helio_coordsv(): SKIPPED EarthCoordCalc, jd is infinite/nan:" << jd;
198 return;
199 }
200
201 if(use_de430(jd))
202 {
203 deOk=GetDe430Coor(jd, EPHEM_JPL_EARTH_ID, xyz);
204 }
205 else if(use_de431(jd))
206 {
207 deOk=GetDe431Coor(jd, EPHEM_JPL_EARTH_ID, xyz);
208 }
209 if (!deOk) //VSOP87 as fallback
210 {
211 double moon[3];
212 GetVsop87Coor(jd,EPHEM_EMB_ID,xyz);
213 GetElp82bCoor(jd,moon);
214 /* Earth != EMB:
215 0.0121505677733761 = mu_m/(1+mu_m),
216 mu_m = mass(moon)/mass(earth) = 0.01230002 */
217 xyz[0] -= 0.0121505677733761 * moon[0];
218 xyz[1] -= 0.0121505677733761 * moon[1];
219 xyz[2] -= 0.0121505677733761 * moon[2];
220 }
221}
222
223void get_mars_helio_coordsv(double jd,double xyz[3], void* unused)
224{
225 get_planet_helio_coordsv(jd, xyz, EPHEM_MARS_ID);
226}
227
228void get_jupiter_helio_coordsv(double jd,double xyz[3], void* unused)
229{
230 get_planet_helio_coordsv(jd, xyz, EPHEM_JUPITER_ID);
231}
232
233void get_saturn_helio_coordsv(double jd,double xyz[3], void* unused)
234{
235 get_planet_helio_coordsv(jd, xyz, EPHEM_SATURN_ID);
236}
237
238void get_uranus_helio_coordsv(double jd,double xyz[3], void* unused)
239{
240 get_planet_helio_coordsv(jd, xyz, EPHEM_URANUS_ID);
241}
242
243void get_neptune_helio_coordsv(double jd,double xyz[3], void* unused)
244{
245 get_planet_helio_coordsv(jd, xyz, EPHEM_NEPTUNE_ID);
246}
247
248void get_mercury_helio_osculating_coords(double jd0,double jd,double xyz[3])
249{
250 get_planet_helio_osculating_coordsv(jd0, jd, xyz, EPHEM_MERCURY_ID);
251}
252
253void get_venus_helio_osculating_coords(double jd0,double jd,double xyz[3])
254{
255 get_planet_helio_osculating_coordsv(jd0, jd, xyz, EPHEM_VENUS_ID);
256}
257
258void get_earth_helio_osculating_coords(double jd0,double jd,double xyz[3])
259{
260 get_planet_helio_osculating_coordsv(jd0, jd, xyz, EPHEM_EMB_ID);
261}
262
263void get_mars_helio_osculating_coords(double jd0,double jd,double xyz[3])
264{
265 get_planet_helio_osculating_coordsv(jd0, jd, xyz, EPHEM_MARS_ID);
266}
267
268void get_jupiter_helio_osculating_coords(double jd0,double jd,double xyz[3])
269{
270 get_planet_helio_osculating_coordsv(jd0, jd, xyz, EPHEM_JUPITER_ID);
271}
272
273void get_saturn_helio_osculating_coords(double jd0,double jd,double xyz[3])
274{
275 get_planet_helio_osculating_coordsv(jd0, jd, xyz, EPHEM_SATURN_ID);
276}
277
278void get_uranus_helio_osculating_coords(double jd0,double jd,double xyz[3])
279{
280 get_planet_helio_osculating_coordsv(jd0, jd, xyz, EPHEM_URANUS_ID);
281}
282
283void get_neptune_helio_osculating_coords(double jd0,double jd,double xyz[3])
284{
285 get_planet_helio_osculating_coordsv(jd0, jd, xyz, EPHEM_NEPTUNE_ID);
286}
287
288/* Calculate the rectangular geocentric lunar coordinates to the inertial mean
289 * ecliptic and equinox of J2000.
290 * The geocentric coordinates returned are in units of AU.
291 * This function is based upon the Lunar Solution ELP2000-82B by
292 * Michelle Chapront-Touze and Jean Chapront of the Bureau des Longitudes,
293 * Paris. ELP 2000-82B theory
294 * param jd Julian day, rect pos */
295void get_lunar_parent_coordsv(double jde,double xyz[3], void* unused)
296{
297 bool deOk=false;
298 if(use_de430(jde))
299 deOk=GetDe430Coor(jde, EPHEM_JPL_MOON_ID, xyz, EPHEM_JPL_EARTH_ID);
300 else if(use_de431(jde))
301 deOk=GetDe431Coor(jde, EPHEM_JPL_MOON_ID, xyz, EPHEM_JPL_EARTH_ID);
302 if (!deOk) // fallback...
303 GetElp82bCoor(jde,xyz);
304}
305
306void get_phobos_parent_coordsv(double jd,double xyz[3], void* unused)
307{
308 GetMarsSatCoor(jd,MARS_SAT_PHOBOS,xyz);
309}
310
311void get_deimos_parent_coordsv(double jd,double xyz[3], void* unused)
312{
313 GetMarsSatCoor(jd,MARS_SAT_DEIMOS,xyz);
314}
315
316void get_io_parent_coordsv(double jd,double xyz[3], void* unused)
317{
318 GetL1Coor(jd,L1_IO,xyz);
319}
320
321void get_europa_parent_coordsv(double jd,double xyz[3], void* unused)
322{
323 GetL1Coor(jd,L1_EUROPA,xyz);
324}
325
326void get_ganymede_parent_coordsv(double jd,double xyz[3], void* unused)
327{
328 GetL1Coor(jd,L1_GANYMEDE,xyz);
329}
330
331void get_callisto_parent_coordsv(double jd,double xyz[3], void* unused)
332{
333 GetL1Coor(jd,L1_CALLISTO,xyz);
334}
335
336void get_mimas_parent_coordsv(double jd,double xyz[3], void* unused)
337{
338 GetTass17Coor(jd,TASS17_MIMAS,xyz);
339}
340
341void get_enceladus_parent_coordsv(double jd,double xyz[3], void* unused)
342{
343 GetTass17Coor(jd,TASS17_ENCELADUS,xyz);
344}
345
346void get_tethys_parent_coordsv(double jd,double xyz[3], void* unused)
347{
348 GetTass17Coor(jd,TASS17_TETHYS,xyz);
349}
350
351void get_dione_parent_coordsv(double jd,double xyz[3], void* unused)
352{
353 GetTass17Coor(jd,TASS17_DIONE,xyz);
354}
355
356void get_rhea_parent_coordsv(double jd,double xyz[3], void* unused)
357{
358 GetTass17Coor(jd,TASS17_RHEA,xyz);
359}
360
361void get_titan_parent_coordsv(double jd,double xyz[3], void* unused)
362{
363 GetTass17Coor(jd,TASS17_TITAN,xyz);
364}
365
366void get_hyperion_parent_coordsv(double jd,double xyz[3], void* unused)
367{
368 GetTass17Coor(jd,TASS17_HYPERION,xyz);
369}
370
371void get_iapetus_parent_coordsv(double jd,double xyz[3], void* unused)
372{
373 GetTass17Coor(jd,TASS17_IAPETUS,xyz);
374}
375
376void get_miranda_parent_coordsv(double jd,double xyz[3], void* unused)
377{
378 GetGust86Coor(jd,GUST86_MIRANDA,xyz);
379}
380
381void get_ariel_parent_coordsv(double jd,double xyz[3], void* unused)
382{
383 GetGust86Coor(jd,GUST86_ARIEL,xyz);
384}
385
386void get_umbriel_parent_coordsv(double jd,double xyz[3], void* unused)
387{
388 GetGust86Coor(jd,GUST86_UMBRIEL,xyz);
389}
390
391void get_titania_parent_coordsv(double jd,double xyz[3], void* unused)
392{
393 GetGust86Coor(jd,GUST86_TITANIA,xyz);
394}
395
396void get_oberon_parent_coordsv(double jd,double xyz[3], void* unused)
397{
398 GetGust86Coor(jd,GUST86_OBERON,xyz);
399}
400
0401
=== added file 'src/core/planetsephems/EphemWrapper.hpp'
--- src/core/planetsephems/EphemWrapper.hpp 1970-01-01 00:00:00 +0000
+++ src/core/planetsephems/EphemWrapper.hpp 2016-01-16 17:00:50 +0000
@@ -0,0 +1,92 @@
1/*
2Copyright (C) 2003 Fabien Chereau
3Copyright (C) 2015 Holger Niessner
4Copyright (C) 2015 Georg Zotti
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU Library General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
19*/
20
21/*
22 * This class provides a wrapper to multiple methods to calculate ephemerides.
23 * Depending on availability of extra data files, the class uses:
24 * - VSOP87 and ELP82B
25 * - DE430
26 * - DE431
27 *
28 * Extending the old stellplanet-class, this updated version now
29 * includes access to DE430 and DE431 for a more precise, yet storage-space intensive solution.
30 */
31
32#ifndef _EPHEMWRAPPER_HPP_
33#define _EPHEMWRAPPER_HPP_
34
35#define DE430_FILENAME "linux_p1550p2650.430"
36#define DE431_FILENAME "lnxm13000p17000.431"
37
38class EphemWrapper{
39public:
40 static void init_de430(const char* filepath);
41 static void init_de431(const char* filepath);
42};
43
44void get_sun_helio_coordsv(double jd,double xyz[3], void*);
45void get_mercury_helio_coordsv(double jd,double xyz[3], void*);
46void get_venus_helio_coordsv(double jd,double xyz[3], void*);
47void get_earth_helio_coordsv(double jd,double xyz[3], void*);
48void get_mars_helio_coordsv(double jd,double xyz[3], void*);
49void get_jupiter_helio_coordsv(double jd,double xyz[3], void*);
50void get_saturn_helio_coordsv(double jd,double xyz[3], void*);
51void get_uranus_helio_coordsv(double jd,double xyz[3], void*);
52void get_neptune_helio_coordsv(double jd,double xyz[3], void*);
53void get_pluto_helio_coordsv(double jd,double xyz[3], void*);
54
55void get_mercury_helio_osculating_coords(double jd0,double jd,double xyz[3]);
56void get_venus_helio_osculating_coords(double jd0,double jd,double xyz[3]);
57void get_earth_helio_osculating_coords(double jd0,double jd,double xyz[3]);
58void get_mars_helio_osculating_coords(double jd0,double jd,double xyz[3]);
59void get_jupiter_helio_osculating_coords(double jd0,double jd,double xyz[3]);
60void get_saturn_helio_osculating_coords(double jd0,double jd,double xyz[3]);
61void get_uranus_helio_osculating_coords(double jd0,double jd,double xyz[3]);
62void get_neptune_helio_osculating_coords(double jd0,double jd,double xyz[3]);
63void get_pluto_helio_osculating_coords(double jd0,double jd,double xyz[3]);
64
65void get_lunar_parent_coordsv(double jde, double xyz[3], void*);
66
67void get_phobos_parent_coordsv(double jd,double xyz[3], void*);
68void get_deimos_parent_coordsv(double jd,double xyz[3], void*);
69
70void get_io_parent_coordsv(double jd,double xyz[3], void*);
71void get_europa_parent_coordsv(double jd,double xyz[3], void*);
72void get_ganymede_parent_coordsv(double jd,double xyz[3], void*);
73void get_callisto_parent_coordsv(double jd,double xyz[3], void*);
74
75void get_mimas_parent_coordsv(double jd,double xyz[3], void*);
76void get_enceladus_parent_coordsv(double jd,double xyz[3], void*);
77void get_tethys_parent_coordsv(double jd,double xyz[3], void*);
78void get_dione_parent_coordsv(double jd,double xyz[3], void*);
79void get_rhea_parent_coordsv(double jd,double xyz[3], void*);
80void get_titan_parent_coordsv(double jd,double xyz[3], void*);
81void get_hyperion_parent_coordsv(double jd,double xyz[3], void*);
82void get_iapetus_parent_coordsv(double jd,double xyz[3], void*);
83
84void get_miranda_parent_coordsv(double jd,double xyz[3], void*);
85void get_ariel_parent_coordsv(double jd,double xyz[3], void*);
86void get_umbriel_parent_coordsv(double jd,double xyz[3], void*);
87void get_titania_parent_coordsv(double jd,double xyz[3], void*);
88void get_oberon_parent_coordsv(double jd,double xyz[3], void*);
89
90#endif // _EPHEMWRAPPER_HPP_
91
92
093
=== added file 'src/core/planetsephems/README.txt'
--- src/core/planetsephems/README.txt 1970-01-01 00:00:00 +0000
+++ src/core/planetsephems/README.txt 2016-01-16 17:00:50 +0000
@@ -0,0 +1,54 @@
1README
2=======
3This Readme gives instructions on how to enable DE430 and/or DE431 for Stellarium for
4more accurate planetary positions.
5
6DE430 covers the dates from 1.Jan 1550 to 22. Jan 2650 with higher precision, whereas
7DE431 covers a longer period of time, from 13201 BC to AD 17191.
8Both are more precise than the standard VSOP87 algorithm used in Stellarium.
9
10When one or both files are used as described below,
11the algorithm will switch according to the current time displayed in Stellarium and
12calculate the planetary positions using the preferred method.
13
14Instructions
15============
16
17File description
18================
19The following files, which can be obtained from
20ftp://ssd.jpl.nasa.gov/pub/eph/planets/Linux/, have to be used:
21
22DE430: linux_p1550p2650.430 (md5 hash 707c4262533d52d59abaaaa5e69c5738)
23DE431: lnxm13000p17000.431 (md5 hash fad0f432ae18c330f9e14915fbf8960a)
24
25File Placement
26==============
27The above mentioned files have to be placed in a folder named 'ephem' inside the
28'Installation Data Directory' (see http://www.stellarium.org/doc/head/fileStructure.html).
29
30This is directory is different on the supported operating systems:
31 - On Linux / BSD / other POSIX:
32 It depends on the installation prefix used when building Stellarium.
33 If you built from source, and didn't explicitly specify an install prefix,
34 the prefix will be /usr/local. Typically, pre-built packages for distros will use
35 the /usr prefix. The Installation Data Directory is $PREFIX/share/stellarium
36
37 - On Windows:
38 It depends on where Stellarium is installed.
39 The main Stellarium installation directory is the Installation Data Directory.
40 Typically this will be C:\Program Files\Stellarium\
41
42 - On MacOS X:
43 The Installation Data Directory is found inside the application bundle.
44
45Already placed in the 'Installation Data Directory' should be folders such as 'data',
46'landscapes', 'stars', 'textures',...
47
48_ IDD
49 \_ data
50 \_ landscapes
51 \_ stars
52 \_ ephem
53 \_ linux_p1550p2650.430
54 \_ lnxm13000p17000.431
055
=== added file 'src/core/planetsephems/de430.cpp'
--- src/core/planetsephems/de430.cpp 1970-01-01 00:00:00 +0000
+++ src/core/planetsephems/de430.cpp 2016-01-16 17:00:50 +0000
@@ -0,0 +1,120 @@
1/*
2Copyright (c) 2015 Holger Niessner
3Copyright (c) 2016 Georg Zotti
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21THE SOFTWARE.
22*/
23
24#include "de430.hpp"
25#include "StelUtils.hpp"
26#include "StelCore.hpp"
27#include "StelApp.hpp"
28
29#ifdef __cplusplus
30 extern "C" {
31#endif
32
33static void * ephem;
34
35static Vec3d tempECL = Vec3d(0,0,0);
36static Vec3d tempICRF = Vec3d(0,0,0);
37static char nams[JPL_MAX_N_CONSTANTS][6];
38static double vals[JPL_MAX_N_CONSTANTS];
39static double tempXYZ[6];
40
41static bool initDone = false;
42
43void InitDE430(const char* filepath)
44{
45 ephem = jpl_init_ephemeris(filepath, nams, vals);
46
47 if(jpl_init_error_code() != 0)
48 {
49 StelApp::getInstance().getCore()->setDe430Active(false);
50 qDebug() << "Error "<< jpl_init_error_code() << "at DE430 init:" << jpl_init_error_message();
51 }
52 else
53 {
54 initDone = true;
55 double jd1, jd2;
56 jd1=jpl_get_double(ephem, JPL_EPHEM_START_JD);
57 jd2=jpl_get_double(ephem, JPL_EPHEM_END_JD);
58 qDebug() << "DE430 init successful. startJD=" << QString::number(jd1, 'f', 4) << "endJD=" << QString::number(jd2, 'f', 4);
59 }
60}
61
62void TerminateDE430()
63{
64 jpl_close_ephemeris(ephem);
65}
66
67bool GetDe430Coor(const double jde, const int planet_id, double * xyz, const int centralBody_id)
68{
69 if(initDone)
70 {
71 // This may return some error code!
72 int jplresult=jpl_pleph(ephem, jde, planet_id, centralBody_id, tempXYZ, 0);
73
74 switch (jplresult)
75 {
76 case 0: // all OK.
77 break;
78 case JPL_EPH_OUTSIDE_RANGE:
79 qDebug() << "GetDe430Coor: JPL_EPH_OUTSIDE_RANGE at jde" << jde << "for planet" << planet_id;
80 return false;
81 break;
82 case JPL_EPH_READ_ERROR:
83 qDebug() << "GetDe430Coor: JPL_EPH_READ_ERROR at jde" << jde << "for planet" << planet_id;
84 return false;
85 break;
86 case JPL_EPH_QUANTITY_NOT_IN_EPHEMERIS:
87 qDebug() << "GetDe430Coor: JPL_EPH_QUANTITY_NOT_IN_EPHEMERIS at jde" << jde << "for planet" << planet_id;
88 return false;
89 break;
90 case JPL_EPH_INVALID_INDEX:
91 qDebug() << "GetDe430Coor: JPL_EPH_INVALID_INDEX at jde" << jde << "for planet" << planet_id;
92 return false;
93 break;
94 case JPL_EPH_FSEEK_ERROR:
95 qDebug() << "GetDe430Coor: JPL_EPH_FSEEK_ERROR at jde" << jde << "for planet" << planet_id;
96 return false;
97 break;
98 default: // Should never happen...
99 qDebug() << "GetDe430Coor: unknown error" << jplresult << "at jde" << jde << "for planet" << planet_id;
100 return false;
101 break;
102 }
103
104 jpl_pleph(ephem, jde, planet_id, centralBody_id, tempXYZ, 0);
105
106 tempICRF = Vec3d(tempXYZ[0], tempXYZ[1], tempXYZ[2]);
107 tempECL = StelCore::matJ2000ToVsop87 * tempICRF;
108
109 xyz[0] = tempECL[0];
110 xyz[1] = tempECL[1];
111 xyz[2] = tempECL[2];
112 return true;
113 }
114 return false;
115}
116
117
118#ifdef __cplusplus
119 }
120#endif
0121
=== added file 'src/core/planetsephems/de430.hpp'
--- src/core/planetsephems/de430.hpp 1970-01-01 00:00:00 +0000
+++ src/core/planetsephems/de430.hpp 2016-01-16 17:00:50 +0000
@@ -0,0 +1,44 @@
1/*
2Copyright (c) 2015 Holger Niessner
3Copyright (c) 2016 Georg Zotti
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21THE SOFTWARE.
22*/
23
24#ifndef _DE430_HPP_
25#define _DE430_HPP_
26
27#include "jpleph.h"
28
29#ifdef __cplusplus
30 extern "C" {
31#endif
32
33void InitDE430(const char* filepath);
34// most of the time centralBody_id likely is the Sun. However, for Moon, use centralBody_id=EPHEM_JPL_EARTH_ID=3
35// return true if OK, false if something was wrong with the JPL functions. In this case, see log for details.
36bool GetDe430Coor(const double jde, const int planet_id, double * xyz, const int centralBody_id=CENTRAL_PLANET_ID);
37// Not possible for a DE.
38//void GetDe430OsculatingCoor(double jd0, double jd, int planet_id, double *xyz, const int centralBody_id=CENTRAL_PLANET_ID);
39
40#ifdef __cplusplus
41 }
42#endif
43
44#endif
045
=== added file 'src/core/planetsephems/de431.cpp'
--- src/core/planetsephems/de431.cpp 1970-01-01 00:00:00 +0000
+++ src/core/planetsephems/de431.cpp 2016-01-16 17:00:50 +0000
@@ -0,0 +1,119 @@
1/*
2Copyright (c) 2015 Holger Niessner
3Copyright (c) 2016 Georg Zotti
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21THE SOFTWARE.
22*/
23
24#include "de431.hpp"
25#include "jpleph.h"
26#include "StelUtils.hpp"
27#include "StelCore.hpp"
28#include "StelApp.hpp"
29
30#ifdef __cplusplus
31 extern "C" {
32#endif
33
34static void * ephem;
35
36static Vec3d tempECL = Vec3d(0,0,0);
37static Vec3d tempICRF = Vec3d(0,0,0);
38static char nams[JPL_MAX_N_CONSTANTS][6];
39static double vals[JPL_MAX_N_CONSTANTS];
40static double tempXYZ[6];
41
42static bool initDone = false;
43
44void InitDE431(const char* filepath)
45{
46 ephem = jpl_init_ephemeris(filepath, nams, vals);
47
48 if(jpl_init_error_code() != 0)
49 {
50 StelApp::getInstance().getCore()->setDe431Active(false);
51 qDebug() << "Error "<< jpl_init_error_code() << "at DE431 init:" << jpl_init_error_message();
52 }
53 else
54 {
55 initDone = true;
56 double jd1, jd2;
57 jd1=jpl_get_double(ephem, JPL_EPHEM_START_JD);
58 jd2=jpl_get_double(ephem, JPL_EPHEM_END_JD);
59 qDebug() << "DE431 init successful. startJD=" << QString::number(jd1, 'f', 4) << "endJD=" << QString::number(jd2, 'f', 4);
60 }
61}
62
63void TerminateDE431()
64{
65 jpl_close_ephemeris(ephem);
66}
67
68bool GetDe431Coor(const double jde, const int planet_id, double * xyz, const int centralBody_id)
69{
70 if(initDone)
71 {
72 // This may return some error code!
73 int jplresult=jpl_pleph(ephem, jde, planet_id, centralBody_id, tempXYZ, 0);
74
75 switch (jplresult)
76 {
77 case 0: // all OK.
78 break;
79 case JPL_EPH_OUTSIDE_RANGE:
80 qDebug() << "GetDe431Coor: JPL_EPH_OUTSIDE_RANGE at jde" << jde << "for planet" << planet_id;
81 return false;
82 break;
83 case JPL_EPH_READ_ERROR:
84 qDebug() << "GetDe431Coor: JPL_EPH_READ_ERROR at jde" << jde << "for planet" << planet_id;
85 return false;
86 break;
87 case JPL_EPH_QUANTITY_NOT_IN_EPHEMERIS:
88 qDebug() << "GetDe431Coor: JPL_EPH_QUANTITY_NOT_IN_EPHEMERIS at jde" << jde << "for planet" << planet_id;
89 return false;
90 break;
91 case JPL_EPH_INVALID_INDEX:
92 qDebug() << "GetDe431Coor: JPL_EPH_INVALID_INDEX at jde" << jde << "for planet" << planet_id;
93 return false;
94 break;
95 case JPL_EPH_FSEEK_ERROR:
96 qDebug() << "GetDe431Coor: JPL_EPH_FSEEK_ERROR at jde" << jde << "for planet" << planet_id;
97 return false;
98 break;
99 default: // Should never happen...
100 qDebug() << "GetDe431Coor: unknown error" << jplresult << "at jde" << jde << "for planet" << planet_id;
101 return false;
102 break;
103 }
104
105 tempICRF = Vec3d(tempXYZ[0], tempXYZ[1], tempXYZ[2]);
106 tempECL = StelCore::matJ2000ToVsop87 * tempICRF;
107
108 xyz[0] = tempECL[0];
109 xyz[1] = tempECL[1];
110 xyz[2] = tempECL[2];
111 return true;
112 }
113 return false;
114}
115
116
117#ifdef __cplusplus
118 }
119#endif
0120
=== added file 'src/core/planetsephems/de431.hpp'
--- src/core/planetsephems/de431.hpp 1970-01-01 00:00:00 +0000
+++ src/core/planetsephems/de431.hpp 2016-01-16 17:00:50 +0000
@@ -0,0 +1,44 @@
1/*
2Copyright (c) 2015 Holger Niessner
3Copyright (c) 2016 Georg Zotti
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21THE SOFTWARE.
22*/
23
24#ifndef _DE431_HPP_
25#define _DE431_HPP_
26
27#include "jpleph.h"
28
29#ifdef __cplusplus
30 extern "C" {
31#endif
32
33void InitDE431(const char* filepath);
34// most of the time centralBody_id likely is the Sun. However, for Moon, use centralBody_id=EPHEM_JPL_EARTH_ID=3
35// return true if OK, false if something was wrong with the JPL functions. In this case, see log for details.
36bool GetDe431Coor(const double jde, const int planet_id, double * xyz, const int centralBody_id=CENTRAL_PLANET_ID);
37// Not possible for a DE.
38//void GetDe431OsculatingCoor(double jd0, double jd, int planet_id, double *xyz, const int centralBody_id=CENTRAL_PLANET_ID);
39
40#ifdef __cplusplus
41 }
42#endif
43
44#endif
045
=== added file 'src/core/planetsephems/jpl_int.h'
--- src/core/planetsephems/jpl_int.h 1970-01-01 00:00:00 +0000
+++ src/core/planetsephems/jpl_int.h 2016-01-16 17:00:50 +0000
@@ -0,0 +1,106 @@
1/* jpl_int.cpp: internal definitions for JPL ephemeris functions
2
3Copyright (C) 2011, Project Pluto
4
5This program is free software; you can redistribute it and/or
6modify it under the terms of the GNU General Public License
7as published by the Free Software Foundation; either version 2
8of the License, or (at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
1802110-1301, USA. */
19
20 /* A JPL binary ephemeris header contains five doubles and */
21 /* (up to) 41 int32_t integers, so: */
22#define JPL_HEADER_SIZE (5 * sizeof( double) + 41 * sizeof( int32_t))
23 /* ...also known as 5 * 8 + 41 * 4 = 204 bytes. */
24
25
26 /* Thus far, no DE ephems use eighteen terms in the Chebyshev */
27 /* expansion. There's an assert to catch it if this changes.. */
28#define MAX_CHEBY 18
29
30#pragma pack(1)
31
32struct interpolation_info
33 {
34 double posn_coeff[MAX_CHEBY], vel_coeff[MAX_CHEBY], twot;
35 unsigned n_posn_avail, n_vel_avail;
36 };
37
38struct jpl_eph_data {
39 double ephem_start, ephem_end, ephem_step;
40 uint32_t ncon;
41 double au;
42 double emrat;
43 uint32_t ipt[15][3];
44 uint32_t ephemeris_version;
45 /* This is the end of the file header. Following are */
46 /* items computed within my code. */
47 uint32_t kernel_size, recsize, ncoeff;
48 uint32_t swap_bytes;
49 uint32_t curr_cache_loc;
50 double pvsun[9];
51 double pvsun_t;
52 double *cache;
53 struct interpolation_info iinfo;
54 FILE *ifile;
55 };
56#pragma pack()
57
58/* 2014 Mar 25: notes about the file structure :
59
60Bytes 0- 83: first line ("JPL Planetary Ephemeris DExxx/LExxx")
61 84-167: second line ("Start Epoch: JED = ttttttt.t yyyy-MMM-dd 00:00:00")
62 168-251: third line ("Final Epoch: JED = ttttttt.t yyyy-MMM-dd 00:00:00")
63 252-257: first constant name ("DENUM ")
64 252+6n to 257+6n: nth constant name (0 <= n < 399)
65 2646-2651: 400th constant name
66 2652-2659: ephem_start
67 2660-2667: ephem_end
68 2668-2675: ephem_step
69 2676-2679: ncon
70 2680-2687: AU in km: close to 149597870.700000
71 2688-2695: Earth/moon mass ratio: about 81.300569
72 ...followed by 36 32-bit ints for the above 'ipt' array [12][3]...
73 2840-2843: ephemeris version (405, 430, etc.)
74 ...followed by three 32-bit ints for ipt[12][0...2].
75 2844-2855: ipt[12][0], ipt[12][1], ipt[12][2]
76 Note that in the JPL FORTRAN code,
77 ipt[12][0..2] become lpt[0..2] (the lunar libration offsets);
78 ipt[13][0..2] become rpt[0..2] (the lunar euler angle rate offsets);
79 ipt[14][0..2] become tpt[0..2] (the TT-TDB offsets)
80 Further note that ipt[13] and [14] are new to DE-430t. In older
81 versions, they're just zeroes.
82 2856-2861: name of 401th constant
83 2862-2867: name of 402st constant
84 ...and after the last constant, ipt[13][0..2] and ipt[14][0..2].
85 If n_constants <= 400, these will occupy bytes 2856-2879. Otherwise,
86 add (n_constants - 400) * 6 to get the byte offset.
87
88 Notice that _most_ of the data in the jpl_eph_data struct is stored
89 between bytes 2652 to 2839. That gets us up to ipt[11][2]. In a
90 sensible world, this would be followed by ipt[12][0]. However, it
91 used to be that DE just gave eleven variables; librations and
92 TT-TDB are sort of an afterthought. And furthermore, having more
93 than 400 constants was something of an afterthought, too. So you
94 have ipts[0] to [11] stored contiguously; then four bytes for the
95 ephemeris version are stuck in there; then twelve bytes for ipt[12],
96 which may be zero; then any "extra" (past 400) constant names;
97 and _then_ 24 bytes for ipt[13] and ipt[14].
98
99 recsize-recsize+8*ncon: actual values of the constants.
100 recsize = 8 * ncoeff; ncoeff, thus far, has been...
101 ncoeff = 773 for DE-102
102 ncoeff = 826 for DE-200 & 202
103 ncoeff = 1018 for DE-403, 405, 406, 410, 414, 421, 422, 423, 424, 430, 431,
104 ncoeff = 728 for DE-406
105 ncoeff = 982 for DE-432, DE-432t
106*/
0107
=== added file 'src/core/planetsephems/jpleph.cpp'
--- src/core/planetsephems/jpleph.cpp 1970-01-01 00:00:00 +0000
+++ src/core/planetsephems/jpleph.cpp 2016-01-16 17:00:50 +0000
@@ -0,0 +1,978 @@
1/* jpleph.cpp: JPL ephemeris functions
2
3Copyright (C) 2011, Project Pluto
4
5This program is free software; you can redistribute it and/or
6modify it under the terms of the GNU General Public License
7as published by the Free Software Foundation; either version 2
8of the License, or (at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
1802110-1301, USA. */
19
20/*****************************************************************************
21* ***** jpl planetary and lunar ephemerides ***** C ver.1.2 *
22******************************************************************************
23* *
24* This program was written in standard fortran-77 and it was manually *
25* translated to C language by Piotr A. Dybczynski (dybol@phys.amu.edu.pl), *
26* subsequently revised heavily by Bill J Gray (pluto@gwi.net), just short *
27* of a total re-write. *
28* *
29******************************************************************************
30* Last modified: July 23, 1997 by PAD *
31******************************************************************************
3221 Apr 2010: Revised by Bill J. Gray. The code now determines the kernel
33size, then allocates memory accordingly. This should 'future-proof' us in
34case JPL (or someone else) creates kernels that are larger than the previously
35arbitrary MAX_KERNEL_SIZE parameter. 'swap_long' and 'swap_double' have
36been replaced with 'swap_32_bit_val' and 'swap_64_bit_val'. It also works
37on 64-bit compiles now.
38
3916 Mar 2001: Revised by Bill J. Gray. You can now use binary
40ephemerides with either byte order ('big-endian' or 'small-endian');
41the code checks to see if the data is in the "wrong" order for the
42current platform, and swaps bytes on-the-fly if needed. (Yes, this
43can result in a slowdown... sometimes as much as 1%. The function is
44so mathematically intensive that the byte-swapping is the least of our
45troubles.) You can also use DE-200, 403, 404, 405, or 406 without
46recompiling (the constan() function now determines which ephemeris is
47in use and its byte order).
48
49Also, I did some minor optimization of the interp() (Chebyshev
50interpolation) function, resulting in a bit of a speedup.
51
52The code has been modified to be a separately linkable component, with
53details of the implementation encapsulated.
54*****************************************************************************/
55
56#include <stdio.h>
57#include <assert.h>
58#include <math.h>
59#include <string.h>
60#include <stdlib.h>
61#include <stdint.h>
62
63#include "StelUtils.hpp"
64/**** include variable and type definitions, specific for this C version */
65
66#include "jpleph.h"
67#include "jpl_int.h"
68
69#define TRUE 1
70#define FALSE 0
71
72
73// GZ patches for Large File Support for DE431 past AD10100...
74#if defined(Q_OS_WIN)
75#define FSeek(__FILE, __OFFSET, _MODE) _fseeki64(__FILE, __OFFSET, _MODE)
76#else
77#define FSeek(__FILE, __OFFSET, _MODE) fseeko(__FILE, __OFFSET, _MODE)
78#endif
79
80
81double DLL_FUNC jpl_get_double(const void *ephem, const int value)
82{
83 return(*(double *)((char *)ephem + value));
84}
85
86long DLL_FUNC jpl_get_long(const void *ephem, const int value)
87{
88 return(*(int32_t *)((char *)ephem + value));
89}
90
91
92/*****************************************************************************
93** jpl_pleph(ephem,et,ntar,ncent,rrd,calc_velocity) **
94******************************************************************************
95** **
96** This subroutine reads the jpl planetary ephemeris **
97** and gives the position and velocity of the point 'ntarg' **
98** with respect to 'ncent'. **
99** **
100** Calling sequence parameters: **
101** **
102** et = (double) julian ephemeris date at which interpolation **
103** is wanted. **
104** **
105** ntarg = integer number of 'target' point. **
106** **
107** ncent = integer number of center point. **
108** **
109** The numbering convention for 'ntarg' and 'ncent' is: **
110** **
111** 1 = mercury 8 = neptune **
112** 2 = venus 9 = pluto **
113** 3 = earth 10 = moon **
114** 4 = mars 11 = sun **
115** 5 = jupiter 12 = solar-system barycenter **
116** 6 = saturn 13 = earth-moon barycenter **
117** 7 = uranus 14 = nutations (longitude and obliq) **
118** 15 = librations, if on eph. file **
119** 16 = lunar mantle omega_x,omega_y,omega_z**
120** 17 = TT-TDB, if on eph. file **
121** **
122** (If nutations are wanted, set ntarg = 14. **
123** For librations, set ntarg = 15. set ncent= 0. **
124** For TT-TDB, set ntarg = 17. I've not actually **
125** seen an ntarg = 16 case yet.) **
126** **
127** rrd = output 6-element, double array of position and velocity **
128** of point 'ntarg' relative to 'ncent'. The units are au and **
129** au/day. For librations the units are radians and radians **
130** per day. In the case of nutations the first four words of **
131** rrd will be set to nutations and rates, having units of **
132** radians and radians/day. **
133** **
134** The option is available to have the units in km and km/sec. **
135** for this, set km=TRUE at the beginning of the program. **
136** **
137** calc_velocity = integer flag; if nonzero, velocities will be **
138** computed, otherwise not. **
139** **
140*****************************************************************************/
141int DLL_FUNC jpl_pleph(void *ephem, const double et, const int ntarg,
142 const int ncent, double rrd[], const int calc_velocity)
143{
144 struct jpl_eph_data *eph = (struct jpl_eph_data *)ephem;
145 double pv[13][6];/* pv is the position/velocity array
146 NUMBERED FROM ZERO: 0=Mercury,1=Venus,...
147 8=Pluto,9=Moon,10=Sun,11=SSBary,12=EMBary
148 First 10 elements (0-9) are affected by
149 jpl_state(), all are adjusted here. */
150
151
152 int rval = 0;
153 const int list_val = (calc_velocity ? 2 : 1);
154 unsigned i;
155 int list[14]; /* list is a vector denoting, for which "body"
156 ephemeris values should be calculated by
157 jpl_state(): 0=Mercury,1=Venus,2=EMBary,...,
158 8=Pluto, 9=geocentric Moon, 10=nutations in
159 long. & obliq. 11= lunar librations;
160 12 = TT-TDB, 13=lunar mantle omegas */
161
162 for(i = 0; i < 6; ++i) rrd[i] = 0.0;
163
164 if(ntarg == ncent) return(0);
165
166 for(i = 0; i < sizeof(list) / sizeof(list[0]); i++)
167 list[i] = 0;
168
169 /* Because of the whacko indexing in JPL ephemerides, we need */
170 /* to work out way through the following indexing schemes : */
171 /* ntarg ipt list */
172 /* 14 11 10 Nutations */
173 /* 15 12 11 Librations */
174 /* 16 13 12 Lunar mantle angular vel */
175 /* 17 14 13 TT - TDB */
176
177 for(i = 0; i < 4; i++)
178 if(ntarg == (int)i + 14)
179 {
180 if(eph->ipt[i + 11][1] > 0) /* quantity is in ephemeris */
181 {
182 list[i + 10] = list_val;
183 rval = jpl_state(ephem, et, list, pv, rrd, 0);
184 }
185 else /* quantity doesn't exist in the ephemeris file */
186 rval = JPL_EPH_QUANTITY_NOT_IN_EPHEMERIS;
187 return(rval);
188 }
189 if(ntarg > 13 || ncent > 13 || ntarg < 1 || ncent < 1)
190 return(JPL_EPH_INVALID_INDEX);
191
192/* force barycentric output by 'state' */
193
194/* set up proper entries in 'list' array for state call */
195
196 for(i = 0; i < 2; i++) /* list[] IS NUMBERED FROM ZERO ! */
197 {
198 const unsigned k = (i ? ncent : ntarg) - 1;
199
200 if(k <= 9) list[k] = list_val; /* Major planets */
201 if(k == 9) list[2] = list_val; /* for moon, earth state is needed */
202 if(k == 2) list[9] = list_val; /* for earth, moon state is needed */
203 if(k == 12) list[2] = list_val; /* EMBary state additionally */
204 }
205
206 /* make call to state */
207 rval = jpl_state(eph, et, list, pv, rrd, 1);
208 /* Solar System barycentric Sun state goes to pv[10][] */
209 if(ntarg == 11 || ncent == 11)
210 for(i = 0; i < 6; i++)
211 pv[10][i] = eph->pvsun[i];
212
213 /* Solar System Barycenter coordinates & velocities equal to zero */
214 if(ntarg == 12 || ncent == 12)
215 for(i = 0; i < 6; i++)
216 pv[11][i] = 0.0;
217
218 /* Solar System barycentric EMBary state: */
219 if(ntarg == 13 || ncent == 13)
220 for(i = 0; i < 6; i++)
221 pv[12][i] = pv[2][i];
222
223 /* if moon from earth or earth from moon ..... */
224 if((ntarg*ncent) == 30 && (ntarg+ncent) == 13)
225 for(i = 0; i < 6; ++i) pv[2][i]=0.0;
226 else
227 {
228 if(list[2]) /* calculate earth state from EMBary */
229 for(i = 0; i < list[2] * 3u; ++i)
230 pv[2][i] -= pv[9][i]/(1.0+eph->emrat);
231
232 if(list[9]) /* calculate Solar System barycentric moon state */
233 for(i = 0; i < list[9] * 3u; ++i)
234 pv[9][i] += pv[2][i];
235 }
236
237 for(i = 0; i < list_val * 3u; ++i)
238 rrd[i] = pv[ntarg-1][i] - pv[ncent-1][i];
239
240 return(rval);
241}
242
243/* Some notes about the information stored in 'iinfo': the posn_coeff[]
244array contains the Chebyshev polynomials for tc,
245
246posn_coeff[i]=T (tc).
247 i
248
249The vel_coeff[] array contains the derivatives of the same polynomials,
250
251vel_coeff[i]=T'(tc).
252 i
253
254 Evaluating these polynomials is a little expensive, and we don't want
255to evaluate any more than we have to. (Some planets require many more
256Chebyshev polynomials than others.) So if 'tc' is unchanged, we can
257rest assured that 'n_posn_avail' Chebyshev polynomials, and 'n_vel_avail'
258derivatives of Chebyshev polynomials, have already been evaluated, and
259we start from there, using the recurrence formulae
260
261T (x) = 1 T (x) = x T (x) = 2xT (x) - T (x)
262 0 1 n+1 n n-1
263
264T'(x) = 0 T'(x) = 1 T' (x) = 2xT'(x) + 2T (x) - T' (x)
265 0 1 n+1 n n n-1
266
267 (the second set being just the derivatives of the first). To get the
268_acceleration_ of an object, we just keep going and get the second
269derivatives as
270
271T"(x) = 0 T"(x) = 1 T" (x) = 2xT"(x) + 4T'(x) - T" (x)
272 0 1 n+1 n n n-1
273
274 At present, i can range from 0 to 17. If future JPL ephems require
275Chebyshev polynomials beyond T , those arrays may need to be expanded.
276 17 */
277
278/*****************************************************************************
279** interp(buf,t,ncf,ncm,na,ifl,pv) **
280******************************************************************************
281** **
282** this subroutine differentiates and interpolates a **
283** set of chebyshev coefficients to give position and velocity **
284** **
285** calling sequence parameters: **
286** **
287** input: **
288** **
289** iinfo stores certain chunks of interpolation info, in hopes **
290** that if you call again with similar parameters, the **
291** function won't have to re-compute all coefficients/data. **
292** **
293** coef 1st location of array of d.p. chebyshev coefficients **
294** of position **
295** **
296** t t[0] is double fractional time in interval covered by **
297** coefficients at which interpolation is wanted **
298** (0 <= t[0] <= 1). t[1] is dp length of whole **
299** interval in input time units. **
300** **
301** ncf # of coefficients per component **
302** **
303** ncm # of components per set of coefficients **
304** **
305** na # of sets of coefficients in full array **
306** (i.e., # of sub-intervals in full interval) **
307** **
308** ifl integer flag: =1 for positions only **
309** =2 for pos and vel **
310** =3 for pos, vel, accel (currently used for **
311** pvsun only) **
312** **
313** output: **
314** **
315** posvel interpolated quantities requested. dimension **
316** expected is posvel[ncm*ifl], double precision. **
317** **
318*****************************************************************************/
319static void interp(struct interpolation_info *iinfo,
320 const double coef[], const double t[2], const unsigned ncf, const unsigned ncm,
321 const unsigned na, const int velocity_flag, double posvel[])
322{
323 const double dna = (double)na;
324 const double temp = dna * t[0];
325 unsigned l = (unsigned)temp;
326 double vfac, unused_temp1;
327 double tc = 2.0 * modf(temp, &unused_temp1) - 1.0;
328 unsigned i, j;
329
330 assert(ncf < MAX_CHEBY);
331 if(l == na)
332 {
333 l--;
334 tc = 1.;
335 }
336 assert(tc >= -1.);
337 assert(tc <= 1.);
338
339/* check to see whether chebyshev time has changed, and compute new
340 polynomial values if it has.
341 (the element iinfo->posn_coeff[1] is the value of t1[tc] and hence
342 contains the value of tc on the previous call.) */
343
344
345 if(tc != iinfo->posn_coeff[1])
346 {
347 iinfo->n_posn_avail = 2;
348 iinfo->n_vel_avail = 2;
349 iinfo->posn_coeff[1] = tc;
350 iinfo->twot = tc+tc;
351 }
352
353/* be sure that at least 'ncf' polynomials have been evaluated and are
354 stored in the array 'iinfo->posn_coeff'. Note that we start out with
355 posn_coeff[0] = 1. and posn_coeff[1] = tc (see 'jpl_init_ephemeris'
356 below), and vel_coeff[0] and [1] are similarly preset. We do that
357 because you need the first two coeffs of those series to start the
358 Chebyshev recurrence; see the comments above this function. */
359
360 if(iinfo->n_posn_avail < ncf)
361 {
362 double *pc_ptr = iinfo->posn_coeff + iinfo->n_posn_avail;
363
364 for(i=ncf - iinfo->n_posn_avail; i; i--, pc_ptr++)
365 *pc_ptr = iinfo->twot * pc_ptr[-1] - pc_ptr[-2];
366 iinfo->n_posn_avail=ncf;
367 }
368
369/* interpolate to get position for each component */
370
371 for(i = 0; i < ncm; ++i) /* ncm is a number of coordinates */
372 {
373 const double *coeff_ptr = coef + ncf * (i + l * ncm + 1);
374 const double *pc_ptr = iinfo->posn_coeff + ncf;
375
376 *posvel = 0.0;
377 for(j = ncf; j; j--)
378 *posvel += (*--pc_ptr) * (*--coeff_ptr);
379 posvel++;
380 }
381
382 if(velocity_flag <= 1) return;
383
384/* if velocity interpolation is wanted, be sure enough
385 derivative polynomials have been generated and stored. */
386
387 if(iinfo->n_vel_avail < ncf)
388 {
389 double *vc_ptr = iinfo->vel_coeff + iinfo->n_vel_avail;
390 const double *pc_ptr = iinfo->posn_coeff + iinfo->n_vel_avail - 1;
391
392 for(i = ncf - iinfo->n_vel_avail; i; i--, vc_ptr++, pc_ptr++)
393 *vc_ptr = iinfo->twot * vc_ptr[-1] + *pc_ptr + *pc_ptr - vc_ptr[-2];
394 iinfo->n_vel_avail = ncf;
395 }
396
397/* interpolate to get velocity for each component */
398
399 vfac = (dna + dna) / t[1];
400 for(i = 0; i < ncm; ++i)
401 {
402 double tval = 0.;
403 const double *coeff_ptr = coef + ncf * (i + l * ncm + 1);
404 const double *vc_ptr = iinfo->vel_coeff + ncf;
405
406 for(j = ncf - 1; j; j--)
407 tval += (*--vc_ptr) * (*--coeff_ptr);
408 *posvel++ = tval * vfac;
409 }
410
411 /* Accelerations are rarely computed -- at present, only */
412 /* for pvsun -- so we don't get so tricky in optimizing. */
413 /* The accel_coeffs (the second derivative of the Chebyshev */
414 /* polynomials) are not stored for repeated use, for example. */
415 if(velocity_flag == 3)
416 {
417
418 double accel_coeffs[MAX_CHEBY];
419
420 accel_coeffs[0] = accel_coeffs[1] = 0.;
421 for(i = 2; i < ncf; i++) /* recurrence for T"(x) */
422 accel_coeffs[i] = 4. * iinfo->vel_coeff[i - 1]
423 + iinfo->twot * accel_coeffs[i - 1]
424 - accel_coeffs[i - 2];
425
426 for(i = 0; i < ncm; ++i) /* ncm is a number of coordinates */
427 {
428 double tval = 0.;
429 const double *coeff_ptr = coef + ncf * (i + l * ncm + 1);
430 const double *ac_ptr = accel_coeffs + ncf;
431
432 for(j = ncf; j; j--)
433 tval += (*--ac_ptr) * (*--coeff_ptr);
434 *posvel++ = tval * vfac * vfac;
435 }
436 }
437
438 return;
439}
440
441/* swap_32_bit_val() and swap_64_bit_val() are used when reading a binary
442ephemeris that was created on a machine with 'opposite' byte order to
443the currently-used machine (signalled by the 'swap_bytes' flag in the
444jpl_eph_data structure). In such cases, every double and integer
445value read from the ephemeris must be byte-swapped by these two functions. */
446
447#define SWAP_MACRO(A, B, TEMP) { TEMP = A; A = B; B = TEMP; }
448
449static void swap_32_bit_val(void *ptr)
450{
451 char *tptr = (char *)ptr, tchar;
452
453 SWAP_MACRO(tptr[0], tptr[3], tchar);
454 SWAP_MACRO(tptr[1], tptr[2], tchar);
455}
456
457static void swap_64_bit_val(void *ptr, long count)
458{
459 char *tptr = (char *)ptr, tchar;
460
461 while(count--)
462 {
463 SWAP_MACRO(tptr[0], tptr[7], tchar);
464 SWAP_MACRO(tptr[1], tptr[6], tchar);
465 SWAP_MACRO(tptr[2], tptr[5], tchar);
466 SWAP_MACRO(tptr[3], tptr[4], tchar);
467
468 tptr += 8;
469 }
470}
471
472/* Most ephemeris quantities have a dimension of three. Planet positions
473have an x, y, and z; librations and lunar mantle angles have three Euler
474angles. But TDT-TT is a single quantity, and nutation is expressed as
475two angles. */
476
477static int dimension(const int idx)
478{
479 int rval;
480
481 if(idx == 11) /* Nutations */
482 rval = 2;
483 else if(idx == 14) /* TDT - TT */
484 rval = 1;
485 else /* planets, lunar mantle angles, librations */
486 rval = 3;
487 return(rval);
488}
489
490/*****************************************************************************
491** jpl_state(ephem,et2,list,pv,nut,bary) **
492******************************************************************************
493** This subroutine reads and interpolates the jpl planetary ephemeris file **
494** **
495** Calling sequence parameters: **
496** **
497** Input: **
498** **
499** et2[] double, 2-element JED epoch at which interpolation **
500** is wanted. Any combination of et2[0]+et2[1] which falls **
501** within the time span on the file is a permissible epoch. **
502** **
503** a. for ease in programming, the user may put the **
504** entire epoch in et2[0] and set et2[1]=0.0 **
505** **
506** b. for maximum interpolation accuracy, set et2[0] = **
507** the most recent midnight at or before interpolation **
508** epoch and set et2[1] = fractional part of a day **
509** elapsed between et2[0] and epoch. **
510** **
511** c. as an alternative, it may prove convenient to set **
512** et2[0] = some fixed epoch, such as start of integration,**
513** and et2[1] = elapsed interval between then and epoch. **
514** **
515** list 13-element integer array specifying what interpolation **
516** is wanted for each of the "bodies" on the file. **
517** **
518** list[i]=0, no interpolation for body i **
519** =1, position only **
520** =2, position and velocity **
521** **
522** the designation of the astronomical bodies by i is: **
523** **
524** i = 0: mercury **
525** = 1: venus **
526** = 2: earth-moon barycenter **
527** = 3: mars **
528** = 4: jupiter **
529** = 5: saturn **
530** = 6: uranus **
531** = 7: neptune **
532** = 8: pluto **
533** = 9: geocentric moon **
534** =10: nutations in lon & obliq (if on file) **
535** =11: lunar librations (if on file) **
536** =12: lunar mantle omegas **
537** =13: TT-TDB (if on file) **
538** **
539** Note that I've not actually seen case 12 yet. It probably doesn't work. **
540** **
541** output: **
542** **
543** pv[][6] double array that will contain requested interpolated **
544** quantities. The body specified by list[i] will have its **
545** state in the array starting at pv[i][0] (on any given **
546** call, only those words in 'pv' which are affected by the **
547** first 10 'list' entries (and by list(11) if librations are **
548** on the file) are set. The rest of the 'pv' array **
549** is untouched.) The order of components in pv[][] is: **
550** pv[][0]=x,....pv[][5]=dz. **
551** **
552** All output vectors are referenced to the earth mean **
553** equator and equinox of epoch. The moon state is always **
554** geocentric; the other nine states are either heliocentric **
555** or solar-system barycentric, depending on the setting of **
556** global variables (see below). **
557** **
558** Lunar librations, if on file, are put into pv[10][k] if **
559** list[11] is 1 or 2. **
560** **
561** nut dp 4-word array that will contain nutations and rates, **
562** depending on the setting of list[10]. the order of **
563** quantities in nut is: **
564** **
565** d psi (nutation in longitude) **
566** d epsilon (nutation in obliquity) **
567** d psi dot **
568** d epsilon dot **
569** **
570*****************************************************************************/
571int DLL_FUNC jpl_state(void *ephem, const double et, const int list[14],
572 double pv[][6], double nut[4], const int bary)
573{
574 struct jpl_eph_data *eph = (struct jpl_eph_data *)ephem;
575 unsigned i, j, n_intervals;
576 uint32_t nr;
577 double *buf = eph->cache;
578 double t[2];
579 const double block_loc = (et - eph->ephem_start) / eph->ephem_step;
580 bool recompute_pvsun;
581 const double aufac = 1.0 / eph->au;
582
583/* error return for epoch out of range */
584 if(et < eph->ephem_start || et > eph->ephem_end)
585 return(JPL_EPH_OUTSIDE_RANGE);
586
587/* calculate record # and relative time in interval */
588
589 nr = (uint32_t)block_loc;
590 t[0] = block_loc - (double)nr;
591 if(!t[0] && nr)
592 {
593 t[0] = 1.;
594 nr--;
595 }
596
597/* read correct record if not in core (static vector buf[]) */
598 if(nr != eph->curr_cache_loc)
599 {
600 eph->curr_cache_loc = nr;
601 /* Read two blocks ahead to account for header: */
602 if(FSeek(eph->ifile, (nr + 2) * eph->recsize, SEEK_SET))
603 {
604 // GZ: Make sure we will try again on next call...
605 eph->curr_cache_loc=0;
606 return(JPL_EPH_FSEEK_ERROR);
607 }
608 if(fread(buf, sizeof(double), (size_t)eph->ncoeff, eph->ifile)
609 != (size_t)eph->ncoeff)
610 return(JPL_EPH_READ_ERROR);
611
612 if(eph->swap_bytes)
613 swap_64_bit_val(buf, eph->ncoeff);
614 }
615 t[1] = eph->ephem_step;
616
617 if(eph->pvsun_t != et) /* If several calls are made for the same et, */
618 { /* don't recompute pvsun each time... only on */
619 recompute_pvsun = true; /* the first run through. */
620 eph->pvsun_t = et;
621 }
622 else
623 recompute_pvsun = false;
624
625 /* Here, i loops through the "traditional" 14 listed items -- 10
626 solar system objects, nutations, librations, lunar mantle angles,
627 and TT-TDT -- plus a fifteenth: the solar system barycenter. That
628 last is quite different: it's computed 'as needed', rather than
629 from list[]; the output goes to pvsun rather than the pv array;
630 and three quantities (position, velocity, acceleration) are
631 computed (nobody else gets accelerations at present.) */
632 for(n_intervals = 1; n_intervals <= 8; n_intervals *= 2)
633 for(i = 0; i < 15; i++)
634 {
635 unsigned quantities;
636 uint32_t *iptr = &eph->ipt[i + 1][0];
637
638 if(i == 14)
639 {
640 quantities = (recompute_pvsun ? 3 : 0);
641 iptr = &eph->ipt[10][0];
642 }
643 else
644 {
645 quantities = list[i];
646 iptr = &eph->ipt[i < 10 ? i : i + 1][0];
647 }
648 if(n_intervals == iptr[2] && quantities)
649 {
650 double *dest = ((i == 10) ? eph->pvsun : pv[i]);
651
652 if(i < 10)
653 dest = pv[i];
654 else if(i == 14)
655 dest = eph->pvsun;
656 else
657 dest = nut;
658 interp(&eph->iinfo, &buf[iptr[0]-1], t, (int)iptr[1],
659 dimension(i + 1),
660 n_intervals, quantities, dest);
661
662 if(i < 10 || i == 14) /* convert km to AU */
663 for(j = 0; j < quantities * 3; j++)
664 dest[j] *= aufac;
665 }
666 }
667 if(!bary) /* gotta correct everybody for */
668 for(i = 0; i < 9; i++) /* the solar system barycenter */
669 for(j = 0; j < (unsigned)list[i] * 3; j++)
670 pv[i][j] -= eph->pvsun[j];
671 return(0);
672}
673
674static int init_err_code = JPL_INIT_NOT_CALLED;
675
676int DLL_FUNC jpl_init_error_code(void)
677{
678 return(init_err_code);
679}
680
681const char * jpl_init_error_message(void)
682{
683 switch(init_err_code)
684 {
685 case 0:
686 return (const char *)("JPL_INIT_NO_ERROR");
687 case -1:
688 return (const char *)("JPL_INIT_FILE_NOT_FOUND");
689 case -2:
690 return (const char *)("JPL_INIT_FSEEK_FAILED");
691 case -3:
692 return (const char *)("JPL_INIT_FREAD_FAILED");
693 case -4:
694 return (const char *)("JPL_INIT_FREAD2_FAILED");
695 case -5:
696 return (const char *)("JPL_INIT_FILE_CORRUPT");
697 case -6:
698 return (const char *)("JPL_INIT_MEMORY_FAILURE");
699 case -7:
700 return (const char *)("JPL_INIT_FREAD3_FAILED");
701 case -8:
702 return (const char *)("JPL_INIT_FREAD4_FAILED");
703 case -9:
704 return (const char *)("JPL_INIT_NOT_CALLED");
705 case -10:
706 return (const char *)("JPL_INIT_FREAD5_FAILED");
707 default:
708 return (const char *)("ERROR_NOT_RECOGNIZED");
709 }
710}
711
712 /* DE-430 has 572 constants. That's more than the 400 constants */
713 /* originally expected. The remaining 172 are stored after the */
714 /* other header data : */
715
716#define START_400TH_CONSTANT_NAME (84 * 3 + 400 * 6 + 5 * sizeof(double) \
717 + 41 * sizeof(int32_t))
718
719 /* ...which comes out to 2856. See comments in 'jpl_int.h'. */
720
721/****************************************************************************
722** jpl_init_ephemeris(ephemeris_filename, nam, val, n_constants) **
723*****************************************************************************
724** **
725** this function does the initial prep work for use of binary JPL **
726** ephemerides. **
727** const char *ephemeris_filename = full path/filename of the binary **
728** ephemeris (on the Willmann-Bell CDs, this is UNIX.200, 405, **
729** or 406) **
730** char nam[][6] = array of constant names (max 6 characters each) **
731** You can pass nam=NULL if you don't care about the names **
732** double *val = array of values of constants **
733** You can pass val=NULL if you don't care about the constants **
734** Return value is a pointer to the jpl_eph_data structure **
735** NULL is returned if the file isn't opened or memory isn't alloced **
736** Errors can be determined with the above jpl_init_error_code() **
737****************************************************************************/
738
739void * DLL_FUNC jpl_init_ephemeris(const char *ephemeris_filename,
740 char nam[][6], double *val)
741{
742 unsigned i, j;
743 long de_version;
744 char title[84];
745 FILE *ifile = fopen(ephemeris_filename, "rb");
746
747 struct jpl_eph_data *rval;
748 struct jpl_eph_data temp_data;
749
750 init_err_code = 0;
751 temp_data.ifile = ifile;
752 if(!ifile)
753 init_err_code = JPL_INIT_FILE_NOT_FOUND;
754 else if(fread(title, 84, 1, ifile) != 1)
755 init_err_code = JPL_INIT_FREAD_FAILED;
756 else if(FSeek(ifile, 2652L, SEEK_SET))
757 init_err_code = JPL_INIT_FSEEK_FAILED;
758 else if(fread(&temp_data, JPL_HEADER_SIZE, 1, ifile) != 1)
759 init_err_code = JPL_INIT_FREAD2_FAILED;
760
761 if(init_err_code)
762 {
763 if(ifile)
764 fclose(ifile);
765 return(NULL);
766 }
767
768 de_version = atoi(title + 26);
769
770 /* A small piece of trickery: in the binary file, data is stored */
771 /* for ipt[0...11], then the ephemeris version, then the */
772 /* remaining ipt[12] data. A little switching is required to get */
773 /* the correct order. */
774 temp_data.ipt[12][0] = temp_data.ipt[12][1];
775 temp_data.ipt[12][1] = temp_data.ipt[12][2];
776 temp_data.ipt[12][2] = temp_data.ipt[13][0];
777 temp_data.ephemeris_version = de_version;
778
779 //qDebug() << "DE_Version: " << de_version;
780
781
782 temp_data.swap_bytes = (temp_data.ncon > 65536L);
783 if(temp_data.swap_bytes) /* byte order is wrong for current platform */
784 {
785 qDebug() << "Byte order is wrong for current platform";
786
787 swap_64_bit_val(&temp_data.ephem_start, 1);
788 swap_64_bit_val(&temp_data.ephem_end, 1);
789 swap_64_bit_val(&temp_data.ephem_step, 1);
790 swap_32_bit_val(&temp_data.ncon);
791 swap_64_bit_val(&temp_data.au, 1);
792 swap_64_bit_val(&temp_data.emrat, 1);
793 }
794
795 /* It's a little tricky to tell if an ephemeris really has */
796 /* TT-TDB data (with offsets in ipt[13][] and ipt[14][]). */
797 /* Essentially, we read the data and sanity-check it, and */
798 /* zero it if it "doesn't add up" correctly. */
799 /* Also: certain ephems I've generated with ncon capped */
800 /* at 400 have no TT-TDB data. So if ncon == 400, don't */
801 /* try to read such data; you may get garbage. */
802 if(de_version >= 430 && temp_data.ncon != 400)
803 {
804 /* If there are 400 or fewer constants, data for ipt[13][0...2] */
805 /* immediately follows that for ipt[12][0..2]; i.e., we don't */
806 /* need to fseek(). Otherwise, we gotta skip 6*(n_constants-400) */
807 /* bytes. */
808 if(temp_data.ncon > 400)
809 FSeek(ifile, (size_t)(temp_data.ncon - 400) * 6, SEEK_CUR);
810 if(fread(&temp_data.ipt[13][0], sizeof(int32_t), 6, ifile) != 6)
811 init_err_code = JPL_INIT_FREAD5_FAILED;
812 }
813 else /* mark header data as invalid */
814 temp_data.ipt[13][0] = (uint32_t)-1;
815
816 if(temp_data.swap_bytes) /* byte order is wrong for current platform */
817 {
818 for(j = 0; j < 3; j++)
819 {
820 for(i = 0; i < 15; i++)
821 {
822 swap_32_bit_val(&temp_data.ipt[i][j]);
823 }
824 }
825 }
826
827 if(temp_data.ipt[13][0] != /* if these don't add up correctly, */
828 temp_data.ipt[12][0] + temp_data.ipt[12][1] * temp_data.ipt[12][2] * 3
829 || temp_data.ipt[14][0] != /* zero them out (they've garbage data) */
830 temp_data.ipt[13][0] + temp_data.ipt[13][1] * temp_data.ipt[13][2] * 3)
831 { /* not valid pointers to TT-TDB data */
832 memset(&temp_data.ipt[13][0], 0, 6 * sizeof(int32_t));
833 }
834
835 /* A sanity check: if the earth-moon ratio is outside reasonable */
836 /* bounds, we must be looking at a wrong or corrupted file. */
837 /* In DE-102, emrat = 81.3007; in DE-405/406, emrat = 81.30056. */
838 /* Those are the low and high ranges. We'll allow some slop in */
839 /* case the earth/moon mass ratio changes: */
840 if(temp_data.emrat > 81.3008 || temp_data.emrat < 81.30055)
841 {
842 init_err_code = JPL_INIT_FILE_CORRUPT;
843 qWarning() << "temp_data: " << temp_data.emrat << "(should have been =~81). JPL_INIT_FILE_CORRUPT!";
844 }
845
846 if(init_err_code)
847 {
848 fclose(ifile);
849 return(NULL);
850 }
851
852 /* Once upon a time, the kernel size was determined from the */
853 /* DE version. This was not a terrible idea, except that it */
854 /* meant that when the code faced a new version, it broke. */
855 /* Now we use some logic to compute the kernel size. */
856 temp_data.kernel_size = 4;
857 for(i = 0; i < 15; i++)
858 temp_data.kernel_size +=
859 2 * temp_data.ipt[i][1] * temp_data.ipt[i][2] * dimension(i);
860// for(i = 0; i < 13; i++)
861// temp_data.kernel_size +=
862// temp_data.ipt[i][1] * temp_data.ipt[i][2] * ((i == 11) ? 4 : 6);
863// /* ...and then add in space required for the TT-TDB data : */
864// temp_data.kernel_size += temp_data.ipt[14][1] * temp_data.ipt[14][2] * 2;
865 temp_data.recsize = temp_data.kernel_size * 4L;
866 temp_data.ncoeff = temp_data.kernel_size / 2L;
867
868 /* Rather than do two separate allocations, everything */
869 /* we need is allocated in _one_ chunk, then parceled out. */
870 /* This looks a little weird, but it simplifies error */
871 /* handling and cleanup. */
872 rval = (struct jpl_eph_data *)calloc(sizeof(struct jpl_eph_data)
873 + temp_data.recsize, 1);
874 if(!rval)
875 {
876 init_err_code = JPL_INIT_MEMORY_FAILURE;
877 fclose(ifile);
878 return(NULL);
879 }
880 memcpy(rval, &temp_data, sizeof(struct jpl_eph_data));
881 rval->iinfo.posn_coeff[0] = 1.0;
882 /* Seed a bogus value here. The first and subsequent calls to */
883 /* 'interp' will correct it to a value between -1 and +1. */
884 rval->iinfo.posn_coeff[1] = -2.0;
885 rval->iinfo.vel_coeff[0] = 0.0;
886 rval->iinfo.vel_coeff[1] = 1.0;
887 rval->curr_cache_loc = (uint32_t)-1;
888
889 /* The 'cache' data is right after the 'jpl_eph_data' struct: */
890 rval->cache = (double *)(rval + 1);
891 /* If there are more than 400 constants, the names of */
892 /* the extra constants are stored in what would normally */
893 /* be zero-padding after the header record. However, */
894 /* older ephemeris-reading software won't know about that. */
895 /* So we store ncon=400, then actually check the names to */
896 /* see how many constants there _really_ are. Older readers */
897 /* will just see 400 names and won't know about the others. */
898 /* But on the upside, they won't crash. */
899
900 if(rval->ncon == 400)
901 {
902 char buff[7];
903
904 buff[6] = '\0';
905 FSeek(ifile, START_400TH_CONSTANT_NAME, SEEK_SET);
906 while(fread(buff, 6, 1, ifile) && strlen(buff) == 6)
907 {
908 rval->ncon++;
909 }
910 }
911
912 if(val)
913 {
914 FSeek(ifile, rval->recsize, SEEK_SET);
915 if(fread(val, sizeof(double), (size_t)rval->ncon, ifile)
916 != (size_t)rval->ncon)
917 init_err_code = JPL_INIT_FREAD3_FAILED;
918 else if(rval->swap_bytes) /* gotta swap the constants, too */
919 swap_64_bit_val(val, rval->ncon);
920 }
921
922 if(!init_err_code && nam)
923 {
924 FSeek(ifile, 84L * 3L, SEEK_SET); /* just after the 3 'title' lines */
925 for(i = 0; i < rval->ncon && !init_err_code; i++)
926 {
927 if(i == 400)
928 FSeek(ifile, START_400TH_CONSTANT_NAME, SEEK_SET);
929 if(fread(nam[i], 6, 1, ifile) != 1)
930 init_err_code = JPL_INIT_FREAD4_FAILED;
931 }
932 }
933 return(rval);
934}
935
936/****************************************************************************
937** jpl_close_ephemeris(ephem) **
938*****************************************************************************
939** **
940** this function closes files and frees up memory allocated by the **
941** jpl_init_ephemeris() function. **
942****************************************************************************/
943void DLL_FUNC jpl_close_ephemeris(void *ephem)
944{
945 struct jpl_eph_data *eph = (struct jpl_eph_data *)ephem;
946
947 fclose(eph->ifile);
948 free(ephem);
949}
950
951/* Added 2011 Jan 18: random access to any desired JPL constant */
952
953
954double DLL_FUNC jpl_get_constant(const int idx, void *ephem, char *constant_name)
955{
956 struct jpl_eph_data *eph = (struct jpl_eph_data *)ephem;
957 double rval = 0.;
958
959 *constant_name = '\0';
960 if(idx >= 0 && idx < (int)eph->ncon)
961 {
962 // GZ extended from const long to const long long
963 const long long seek_loc = (idx < 400 ? 84L * 3L + (long)idx * 6 :
964 START_400TH_CONSTANT_NAME + (idx - 400) * 6);
965
966 FSeek(eph->ifile, seek_loc, SEEK_SET);
967 if(fread(constant_name, 1, 6, eph->ifile))
968 {
969 constant_name[6] = '\0';
970 FSeek(eph->ifile, eph->recsize + (long)idx * sizeof(double), SEEK_SET);
971 if(fread(&rval, 1, sizeof(double), eph->ifile))
972 if(eph->swap_bytes) /* gotta swap the constants, too */
973 swap_64_bit_val(&rval, 1);
974 }
975 }
976 return(rval);
977}
978/*************************** THE END ***************************************/
0979
=== added file 'src/core/planetsephems/jpleph.h'
--- src/core/planetsephems/jpleph.h 1970-01-01 00:00:00 +0000
+++ src/core/planetsephems/jpleph.h 2016-01-16 17:00:50 +0000
@@ -0,0 +1,117 @@
1/* jpleph.h: header for JPL ephemeris functions
2
3Copyright (C) 2011, Project Pluto
4
5This program is free software; you can redistribute it and/or
6modify it under the terms of the GNU General Public License
7as published by the Free Software Foundation; either version 2
8of the License, or (at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
1802110-1301, USA. */
19
20/***************************************************************************
21******* JPLEPH.H *********
22****************************************************************************
23** This header file is used both by ASC2EPH and TESTEPH programs. **
24****************************************************************************
25** Written: May 28, 1997 by PAD ** Last modified: June 23,1997 by PAD **
26** Modified further by Bill Gray, Jun-Aug 2001 **
27****************************************************************************
28** PAD: dr. Piotr A. Dybczynski, e-mail: dybol@phys.amu.edu.pl **
29** Astronomical Observatory of the A.Mickiewicz Univ., Poznan, Poland **
30***************************************************************************/
31
32/* By default, in Windoze 32, the JPL ephemeris functions are compiled
33 into a DLL. This is not really all that helpful at present, but may
34 be useful to people who want to use the functions from languages other
35 than C. */
36
37#ifdef _WIN32
38#define DLL_FUNC __stdcall
39#else
40#define DLL_FUNC
41#endif
42
43#ifdef __WATCOMC__
44 #include <stdbool.h>
45#endif
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51void * DLL_FUNC jpl_init_ephemeris( const char *ephemeris_filename,
52 char nam[][6], double *val);
53void DLL_FUNC jpl_close_ephemeris( void *ephem);
54int DLL_FUNC jpl_state( void *ephem, const double et, const int list[14],
55 double pv[][6], double nut[4], const int bary);
56int DLL_FUNC jpl_pleph( void *ephem, const double et, const int ntarg,
57 const int ncent, double rrd[], const int calc_velocity);
58double DLL_FUNC jpl_get_double( const void *ephem, const int value);
59long DLL_FUNC jpl_get_long( const void *ephem, const int value);
60int DLL_FUNC make_sub_ephem( void *ephem, const char *sub_filename,
61 const double start_jd, const double end_jd);
62double DLL_FUNC jpl_get_constant( const int idx, void *ephem, char *constant_name);
63
64#ifdef __cplusplus
65}
66#endif
67
68 /* Following are constants used in */
69 /* jpl_get_double( ) and jpl_get_long( ): */
70
71#define JPL_EPHEM_START_JD 0
72#define JPL_EPHEM_END_JD 8
73#define JPL_EPHEM_STEP 16
74#define JPL_EPHEM_N_CONSTANTS 24
75#define JPL_EPHEM_AU_IN_KM 28
76#define JPL_EPHEM_EARTH_MOON_RATIO 36
77#define JPL_EPHEM_IPT_ARRAY 44
78#define JPL_EPHEM_EPHEMERIS_VERSION 224
79#define JPL_EPHEM_KERNEL_SIZE 228
80#define JPL_EPHEM_KERNEL_RECORD_SIZE 232
81#define JPL_EPHEM_KERNEL_NCOEFF 236
82#define JPL_EPHEM_KERNEL_SWAP_BYTES 240
83
84 /* The following error codes may be returned by */
85 /* jpl_state() and jpl_pleph(): */
86#define JPL_EPH_OUTSIDE_RANGE (-1)
87#define JPL_EPH_READ_ERROR (-2)
88#define JPL_EPH_QUANTITY_NOT_IN_EPHEMERIS (-3)
89#define JPL_EPH_INVALID_INDEX (-5)
90#define JPL_EPH_FSEEK_ERROR (-6)
91
92int DLL_FUNC jpl_init_error_code( void);
93
94 /* The following error codes may be returned by */
95 /* jpl_init_error_code( ) after jpl_init_ephemeris( ) */
96 /* has been called: */
97
98#define JPL_INIT_NO_ERROR 0
99#define JPL_INIT_FILE_NOT_FOUND -1
100#define JPL_INIT_FSEEK_FAILED -2
101#define JPL_INIT_FREAD_FAILED -3
102#define JPL_INIT_FREAD2_FAILED -4
103#define JPL_INIT_FREAD5_FAILED -10
104#define JPL_INIT_FILE_CORRUPT -5
105#define JPL_INIT_MEMORY_FAILURE -6
106#define JPL_INIT_FREAD3_FAILED -7
107#define JPL_INIT_FREAD4_FAILED -8
108#define JPL_INIT_NOT_CALLED -9
109
110#define jpl_get_pvsun( ephem) ((double *)((char *)ephem + 248))
111
112/* addition for use in stellarium */
113#define JPL_MAX_N_CONSTANTS 1018
114#define CALC_VELOCITY 0
115#define CENTRAL_PLANET_ID 11 //ID of sun in JPL enumeration
116
117const char * jpl_init_error_message(void);
0118
=== modified file 'src/core/planetsephems/pluto.h'
--- src/core/planetsephems/pluto.h 2013-08-04 14:59:29 +0000
+++ src/core/planetsephems/pluto.h 2016-01-16 17:00:50 +0000
@@ -20,6 +20,11 @@
20#ifndef LN_PLUTO_H20#ifndef LN_PLUTO_H
21#define LN_PLUTO_H21#define LN_PLUTO_H
2222
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27
23struct pluto_argument28struct pluto_argument
24{29{
25 double J, S, P;30 double J, S, P;
@@ -40,5 +45,11 @@
40 double A,B;45 double A,B;
41};46};
4247
48void get_pluto_helio_coords (double JD, double * X, double * Y, double * Z);
49
50#ifdef __cplusplus
51}
52#endif
53
4354
44#endif55#endif
4556
=== removed file 'src/core/planetsephems/stellplanet.c'
--- src/core/planetsephems/stellplanet.c 2013-08-04 14:59:29 +0000
+++ src/core/planetsephems/stellplanet.c 1970-01-01 00:00:00 +0000
@@ -1,136 +0,0 @@
1/*
2Copyright (C) 2003 Fabien Chereau
3
4This program is free software; you can redistribute it and/or modify
5it under the terms of the GNU Library General Public License as published by
6the Free Software Foundation; either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
17*/
18
19#include "vsop87.h"
20#include "elp82b.h"
21#include "marssat.h"
22#include "l1.h"
23#include "tass17.h"
24#include "gust86.h"
25
26/* Chapter 31 Pg 206-207 Equ 31.1 31.2 , 31.3 using VSOP 87
27 * Calculate planets rectangular heliocentric ecliptical coordinates
28 * for given julian day. Values are in AU.
29 * params : Julian day, rect coords */
30void get_pluto_helio_coords(double jd, double * X, double * Y, double * Z);
31
32void get_pluto_helio_coordsv(double jd,double xyz[3], void* unused)
33 {get_pluto_helio_coords(jd, &xyz[0], &xyz[1], &xyz[2]);}
34
35
36/* Return 0 of course... */
37void get_sun_helio_coordsv(double jd,double xyz[3], void* unused)
38 {xyz[0]=0.; xyz[1]=0.; xyz[2]=0.;}
39
40void get_mercury_helio_coordsv(double jd,double xyz[3], void* unused)
41 {GetVsop87Coor(jd,VSOP87_MERCURY,xyz);}
42void get_venus_helio_coordsv(double jd,double xyz[3], void* unused)
43 {GetVsop87Coor(jd,VSOP87_VENUS,xyz);}
44
45void get_earth_helio_coordsv(const double jd,double xyz[3]) {
46 double moon[3];
47 GetVsop87Coor(jd,VSOP87_EMB,xyz);
48 GetElp82bCoor(jd,moon);
49 /* Earth != EMB:
50 0.0121505677733761 = mu_m/(1+mu_m),
51 mu_m = mass(moon)/mass(earth) = 0.01230002 */
52 xyz[0] -= 0.0121505677733761 * moon[0];
53 xyz[1] -= 0.0121505677733761 * moon[1];
54 xyz[2] -= 0.0121505677733761 * moon[2];
55}
56
57void get_mars_helio_coordsv(double jd,double xyz[3], void* unused)
58 {GetVsop87Coor(jd,VSOP87_MARS,xyz);}
59void get_jupiter_helio_coordsv(double jd,double xyz[3], void* unused)
60 {GetVsop87Coor(jd,VSOP87_JUPITER,xyz);}
61void get_saturn_helio_coordsv(double jd,double xyz[3], void* unused)
62 {GetVsop87Coor(jd,VSOP87_SATURN,xyz);}
63void get_uranus_helio_coordsv(double jd,double xyz[3], void* unused)
64 {GetVsop87Coor(jd,VSOP87_URANUS,xyz);}
65void get_neptune_helio_coordsv(double jd,double xyz[3], void* unused)
66 {GetVsop87Coor(jd,VSOP87_NEPTUNE,xyz);}
67
68void get_mercury_helio_osculating_coords(double jd0,double jd,double xyz[3])
69 {GetVsop87OsculatingCoor(jd0,jd,VSOP87_MERCURY,xyz);}
70void get_venus_helio_osculating_coords(double jd0,double jd,double xyz[3])
71 {GetVsop87OsculatingCoor(jd0,jd,VSOP87_VENUS,xyz);}
72void get_earth_helio_osculating_coords(double jd0,double jd,double xyz[3])
73 {GetVsop87OsculatingCoor(jd0,jd,VSOP87_EMB,xyz);}
74void get_mars_helio_osculating_coords(double jd0,double jd,double xyz[3])
75 {GetVsop87OsculatingCoor(jd0,jd,VSOP87_MARS,xyz);}
76void get_jupiter_helio_osculating_coords(double jd0,double jd,double xyz[3])
77 {GetVsop87OsculatingCoor(jd0,jd,VSOP87_JUPITER,xyz);}
78void get_saturn_helio_osculating_coords(double jd0,double jd,double xyz[3])
79 {GetVsop87OsculatingCoor(jd0,jd,VSOP87_SATURN,xyz);}
80void get_uranus_helio_osculating_coords(double jd0,double jd,double xyz[3])
81 {GetVsop87OsculatingCoor(jd0,jd,VSOP87_URANUS,xyz);}
82void get_neptune_helio_osculating_coords(double jd0,double jd,double xyz[3])
83 {GetVsop87OsculatingCoor(jd0,jd,VSOP87_NEPTUNE,xyz);}
84
85/* Calculate the rectangular geocentric lunar coordinates to the inertial mean
86 * ecliptic and equinox of J2000.
87 * The geocentric coordinates returned are in units of AU.
88 * This function is based upon the Lunar Solution ELP2000-82B by
89 * Michelle Chapront-Touze and Jean Chapront of the Bureau des Longitudes,
90 * Paris. ELP 2000-82B theory
91 * param jd Julian day, rect pos */
92void get_lunar_parent_coordsv(double jd,double xyz[3], void* unused)
93 {GetElp82bCoor(jd,xyz);}
94
95void get_phobos_parent_coordsv(double jd,double xyz[3], void* unused)
96 {GetMarsSatCoor(jd,MARS_SAT_PHOBOS,xyz);}
97void get_deimos_parent_coordsv(double jd,double xyz[3], void* unused)
98 {GetMarsSatCoor(jd,MARS_SAT_DEIMOS,xyz);}
99
100void get_io_parent_coordsv(double jd,double xyz[3], void* unused)
101 {GetL1Coor(jd,L1_IO,xyz);}
102void get_europa_parent_coordsv(double jd,double xyz[3], void* unused)
103 {GetL1Coor(jd,L1_EUROPA,xyz);}
104void get_ganymede_parent_coordsv(double jd,double xyz[3], void* unused)
105 {GetL1Coor(jd,L1_GANYMEDE,xyz);}
106void get_callisto_parent_coordsv(double jd,double xyz[3], void* unused)
107 {GetL1Coor(jd,L1_CALLISTO,xyz);}
108
109void get_mimas_parent_coordsv(double jd,double xyz[3], void* unused)
110 {GetTass17Coor(jd,TASS17_MIMAS,xyz);}
111void get_enceladus_parent_coordsv(double jd,double xyz[3], void* unused)
112 {GetTass17Coor(jd,TASS17_ENCELADUS,xyz);}
113void get_tethys_parent_coordsv(double jd,double xyz[3], void* unused)
114 {GetTass17Coor(jd,TASS17_TETHYS,xyz);}
115void get_dione_parent_coordsv(double jd,double xyz[3], void* unused)
116 {GetTass17Coor(jd,TASS17_DIONE,xyz);}
117void get_rhea_parent_coordsv(double jd,double xyz[3], void* unused)
118 {GetTass17Coor(jd,TASS17_RHEA,xyz);}
119void get_titan_parent_coordsv(double jd,double xyz[3], void* unused)
120 {GetTass17Coor(jd,TASS17_TITAN,xyz);}
121void get_hyperion_parent_coordsv(double jd,double xyz[3], void* unused)
122 {GetTass17Coor(jd,TASS17_HYPERION,xyz);}
123void get_iapetus_parent_coordsv(double jd,double xyz[3], void* unused)
124 {GetTass17Coor(jd,TASS17_IAPETUS,xyz);}
125
126void get_miranda_parent_coordsv(double jd,double xyz[3], void* unused)
127 {GetGust86Coor(jd,GUST86_MIRANDA,xyz);}
128void get_ariel_parent_coordsv(double jd,double xyz[3], void* unused)
129 {GetGust86Coor(jd,GUST86_ARIEL,xyz);}
130void get_umbriel_parent_coordsv(double jd,double xyz[3], void* unused)
131 {GetGust86Coor(jd,GUST86_UMBRIEL,xyz);}
132void get_titania_parent_coordsv(double jd,double xyz[3], void* unused)
133 {GetGust86Coor(jd,GUST86_TITANIA,xyz);}
134void get_oberon_parent_coordsv(double jd,double xyz[3], void* unused)
135 {GetGust86Coor(jd,GUST86_OBERON,xyz);}
136
1370
=== removed file 'src/core/planetsephems/stellplanet.h'
--- src/core/planetsephems/stellplanet.h 2013-08-04 14:59:29 +0000
+++ src/core/planetsephems/stellplanet.h 1970-01-01 00:00:00 +0000
@@ -1,77 +0,0 @@
1/*
2Copyright (C) 2003 Fabien Chereau
3
4This program is free software; you can redistribute it and/or modify
5it under the terms of the GNU Library General Public License as published by
6the Free Software Foundation; either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
17*/
18
19#ifndef _STELLPLANET_H_
20#define _STELLPLANET_H_
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26void get_sun_helio_coordsv(double jd,double xyz[3], void*);
27void get_mercury_helio_coordsv(double jd,double xyz[3], void*);
28void get_venus_helio_coordsv(double jd,double xyz[3], void*);
29void get_earth_helio_coordsv(double jd,double xyz[3], void*);
30void get_mars_helio_coordsv(double jd,double xyz[3], void*);
31void get_jupiter_helio_coordsv(double jd,double xyz[3], void*);
32void get_saturn_helio_coordsv(double jd,double xyz[3], void*);
33void get_uranus_helio_coordsv(double jd,double xyz[3], void*);
34void get_neptune_helio_coordsv(double jd,double xyz[3], void*);
35void get_pluto_helio_coordsv(double jd,double xyz[3], void*);
36
37void get_mercury_helio_osculating_coords(double jd0,double jd,double xyz[3]);
38void get_venus_helio_osculating_coords(double jd0,double jd,double xyz[3]);
39void get_earth_helio_osculating_coords(double jd0,double jd,double xyz[3]);
40void get_mars_helio_osculating_coords(double jd0,double jd,double xyz[3]);
41void get_jupiter_helio_osculating_coords(double jd0,double jd,double xyz[3]);
42void get_saturn_helio_osculating_coords(double jd0,double jd,double xyz[3]);
43void get_uranus_helio_osculating_coords(double jd0,double jd,double xyz[3]);
44void get_neptune_helio_osculating_coords(double jd0,double jd,double xyz[3]);
45void get_pluto_helio_osculating_coords(double jd0,double jd,double xyz[3]);
46
47void get_lunar_parent_coordsv(double jd,double xyz[3], void*);
48
49void get_phobos_parent_coordsv(double jd,double xyz[3], void*);
50void get_deimos_parent_coordsv(double jd,double xyz[3], void*);
51
52void get_io_parent_coordsv(double jd,double xyz[3], void*);
53void get_europa_parent_coordsv(double jd,double xyz[3], void*);
54void get_ganymede_parent_coordsv(double jd,double xyz[3], void*);
55void get_callisto_parent_coordsv(double jd,double xyz[3], void*);
56
57void get_mimas_parent_coordsv(double jd,double xyz[3], void*);
58void get_enceladus_parent_coordsv(double jd,double xyz[3], void*);
59void get_tethys_parent_coordsv(double jd,double xyz[3], void*);
60void get_dione_parent_coordsv(double jd,double xyz[3], void*);
61void get_rhea_parent_coordsv(double jd,double xyz[3], void*);
62void get_titan_parent_coordsv(double jd,double xyz[3], void*);
63void get_hyperion_parent_coordsv(double jd,double xyz[3], void*);
64void get_iapetus_parent_coordsv(double jd,double xyz[3], void*);
65
66void get_miranda_parent_coordsv(double jd,double xyz[3], void*);
67void get_ariel_parent_coordsv(double jd,double xyz[3], void*);
68void get_umbriel_parent_coordsv(double jd,double xyz[3], void*);
69void get_titania_parent_coordsv(double jd,double xyz[3], void*);
70void get_oberon_parent_coordsv(double jd,double xyz[3], void*);
71
72#ifdef __cplusplus
73}
74#endif
75
76
77#endif /* _STELLPLANET_H_ */
780
=== modified file 'src/core/planetsephems/vsop87.h'
--- src/core/planetsephems/vsop87.h 2015-07-20 15:56:19 +0000
+++ src/core/planetsephems/vsop87.h 2016-01-16 17:00:50 +0000
@@ -51,15 +51,6 @@
51extern "C" {51extern "C" {
52#endif52#endif
5353
54#define VSOP87_MERCURY 0
55#define VSOP87_VENUS 1
56#define VSOP87_EMB 2
57#define VSOP87_MARS 3
58#define VSOP87_JUPITER 4
59#define VSOP87_SATURN 5
60#define VSOP87_URANUS 6
61#define VSOP87_NEPTUNE 7
62
63void GetVsop87Coor(double jd,int body,double *xyz);54void GetVsop87Coor(double jd,int body,double *xyz);
64 /* Return the rectangular coordinates of the given planet55 /* Return the rectangular coordinates of the given planet
65 and the given julian date jd expressed in dynamical time (TAI+32.184s).56 and the given julian date jd expressed in dynamical time (TAI+32.184s).
6657
=== modified file 'src/gui/ConfigurationDialog.cpp'
--- src/gui/ConfigurationDialog.cpp 2015-11-29 14:05:01 +0000
+++ src/gui/ConfigurationDialog.cpp 2016-01-16 17:00:50 +0000
@@ -59,6 +59,7 @@
59#include "SkyGui.hpp"59#include "SkyGui.hpp"
60#include "StelJsonParser.hpp"60#include "StelJsonParser.hpp"
61#include "StelTranslator.hpp"61#include "StelTranslator.hpp"
62#include "EphemWrapper.hpp"
6263
63#include <QSettings>64#include <QSettings>
64#include <QDebug>65#include <QDebug>
@@ -72,15 +73,17 @@
72 : StelDialog(parent)73 : StelDialog(parent)
73 , nextStarCatalogToDownloadIndex(0)74 , nextStarCatalogToDownloadIndex(0)
74 , starCatalogsCount(0)75 , starCatalogsCount(0)
75 , starCatalogDownloadReply(NULL)76 , downloadReply(NULL)
76 , currentDownloadFile(NULL)77 , currentDownloadFile(NULL)
77 , progressBar(NULL)78 , progressBar(NULL)
78 , gui(agui)79 , gui(agui)
80 , hasDownloadedStarCatalog(false)
81 , isDownloadingStarCatalog(false)
82 , isDownloadingEphemData(false)
83 , customDeltaTEquationDialog(NULL)
79{84{
80 ui = new Ui_configurationDialogForm;85 ui = new Ui_configurationDialogForm;
81 customDeltaTEquationDialog = NULL;86
82 hasDownloadedStarCatalog = false;
83 isDownloadingStarCatalog = false;
84 savedProjectionType = StelApp::getInstance().getCore()->getCurrentProjectionType();87 savedProjectionType = StelApp::getInstance().getCore()->getCurrentProjectionType();
85 // Get info about operating system88 // Get info about operating system
86 QString platform = StelUtils::getOperatingSystemInfo();89 QString platform = StelUtils::getOperatingSystemInfo();
@@ -170,11 +173,18 @@
170 connect(ui->getStarsButton, SIGNAL(clicked()), this, SLOT(downloadStars()));173 connect(ui->getStarsButton, SIGNAL(clicked()), this, SLOT(downloadStars()));
171 connect(ui->downloadCancelButton, SIGNAL(clicked()), this, SLOT(cancelDownload()));174 connect(ui->downloadCancelButton, SIGNAL(clicked()), this, SLOT(cancelDownload()));
172 connect(ui->downloadRetryButton, SIGNAL(clicked()), this, SLOT(downloadStars()));175 connect(ui->downloadRetryButton, SIGNAL(clicked()), this, SLOT(downloadStars()));
173 resetStarCatalogControls();176
174 ui->nutationCheckBox->setChecked(core->getUseNutation());177 ui->nutationCheckBox->setChecked(core->getUseNutation());
175 connect(ui->nutationCheckBox, SIGNAL(toggled(bool)), core, SLOT(setUseNutation(bool)));178 connect(ui->nutationCheckBox, SIGNAL(toggled(bool)), core, SLOT(setUseNutation(bool)));
176 ui->topocentricCheckBox->setChecked(core->getUseTopocentricCoordinates());179 ui->topocentricCheckBox->setChecked(core->getUseTopocentricCoordinates());
177 connect(ui->topocentricCheckBox, SIGNAL(toggled(bool)), core, SLOT(setUseTopocentricCoordinates(bool)));180 connect(ui->topocentricCheckBox, SIGNAL(toggled(bool)), core, SLOT(setUseTopocentricCoordinates(bool)));
181
182 connect(ui->de430checkBox, SIGNAL(clicked()), this, SLOT(de430ButtonClicked()));
183 connect(ui->de431checkBox, SIGNAL(clicked()), this, SLOT(de431ButtonClicked()));
184
185 resetStarCatalogControls();
186 resetEphemControls();
187
178#ifdef Q_OS_WIN188#ifdef Q_OS_WIN
179 //Kinetic scrolling for tablet pc and pc189 //Kinetic scrolling for tablet pc and pc
180 QList<QWidget *> addscroll;190 QList<QWidget *> addscroll;
@@ -1077,27 +1087,27 @@
1077void ConfigurationDialog::cancelDownload(void)1087void ConfigurationDialog::cancelDownload(void)
1078{1088{
1079 Q_ASSERT(currentDownloadFile);1089 Q_ASSERT(currentDownloadFile);
1080 Q_ASSERT(starCatalogDownloadReply);1090 Q_ASSERT(downloadReply);
1081 qWarning() << "Aborting download";1091 qWarning() << "Aborting download";
1082 starCatalogDownloadReply->abort();1092 downloadReply->abort();
1083}1093}
10841094
1085void ConfigurationDialog::newStarCatalogData()1095void ConfigurationDialog::newStarCatalogData()
1086{1096{
1087 Q_ASSERT(currentDownloadFile);1097 Q_ASSERT(currentDownloadFile);
1088 Q_ASSERT(starCatalogDownloadReply);1098 Q_ASSERT(downloadReply);
1089 Q_ASSERT(progressBar);1099 Q_ASSERT(progressBar);
10901100
1091 int size = starCatalogDownloadReply->bytesAvailable();1101 int size = downloadReply->bytesAvailable();
1092 progressBar->setValue((float)progressBar->getValue()+(float)size/1024);1102 progressBar->setValue((float)progressBar->getValue()+(float)size/1024);
1093 currentDownloadFile->write(starCatalogDownloadReply->read(size));1103 currentDownloadFile->write(downloadReply->read(size));
1094}1104}
10951105
1096void ConfigurationDialog::downloadStars()1106void ConfigurationDialog::downloadStars()
1097{1107{
1098 Q_ASSERT(!nextStarCatalogToDownload.isEmpty());1108 Q_ASSERT(!nextStarCatalogToDownload.isEmpty());
1099 Q_ASSERT(!isDownloadingStarCatalog);1109 Q_ASSERT(!isDownloadingStarCatalog);
1100 Q_ASSERT(starCatalogDownloadReply==NULL);1110 Q_ASSERT(downloadReply==NULL);
1101 Q_ASSERT(currentDownloadFile==NULL);1111 Q_ASSERT(currentDownloadFile==NULL);
1102 Q_ASSERT(progressBar==NULL);1112 Q_ASSERT(progressBar==NULL);
11031113
@@ -1112,7 +1122,7 @@
1112 ui->downloadRetryButton->setVisible(true);1122 ui->downloadRetryButton->setVisible(true);
1113 return;1123 return;
1114 }1124 }
11151125 isDownloading = true;
1116 isDownloadingStarCatalog = true;1126 isDownloadingStarCatalog = true;
1117 updateStarCatalogControlsText();1127 updateStarCatalogControlsText();
1118 ui->downloadCancelButton->setVisible(true);1128 ui->downloadCancelButton->setVisible(true);
@@ -1124,10 +1134,10 @@
1124 req.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);1134 req.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);
1125 req.setAttribute(QNetworkRequest::RedirectionTargetAttribute, false);1135 req.setAttribute(QNetworkRequest::RedirectionTargetAttribute, false);
1126 req.setRawHeader("User-Agent", userAgent.toLatin1());1136 req.setRawHeader("User-Agent", userAgent.toLatin1());
1127 starCatalogDownloadReply = StelApp::getInstance().getNetworkAccessManager()->get(req);1137 downloadReply = StelApp::getInstance().getNetworkAccessManager()->get(req);
1128 starCatalogDownloadReply->setReadBufferSize(1024*1024*2); 1138 downloadReply->setReadBufferSize(1024*1024*2);
1129 connect(starCatalogDownloadReply, SIGNAL(finished()), this, SLOT(downloadFinished()));1139 connect(downloadReply, SIGNAL(finished()), this, SLOT(starsDownloadFinished()));
1130 connect(starCatalogDownloadReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));1140 connect(downloadReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
11311141
1132 progressBar = StelApp::getInstance().addProgressBar();1142 progressBar = StelApp::getInstance().addProgressBar();
1133 progressBar->setValue(0);1143 progressBar->setValue(0);
@@ -1137,30 +1147,97 @@
1137 qDebug() << "Downloading file" << nextStarCatalogToDownload.value("url").toString();1147 qDebug() << "Downloading file" << nextStarCatalogToDownload.value("url").toString();
1138}1148}
11391149
1150void ConfigurationDialog::de430ButtonClicked()
1151{
1152 QSettings* conf = StelApp::getInstance().getSettings();
1153 Q_ASSERT(conf);
1154
1155 StelApp::getInstance().getCore()->setDe430Active(!StelApp::getInstance().getCore()->de430IsActive());
1156 conf->setValue("astro/flag_use_de430", StelApp::getInstance().getCore()->de430IsActive());
1157
1158 resetEphemControls(); //refresh labels
1159}
1160
1161void ConfigurationDialog::de431ButtonClicked()
1162{
1163 QSettings* conf = StelApp::getInstance().getSettings();
1164 Q_ASSERT(conf);
1165
1166 StelApp::getInstance().getCore()->setDe431Active(!StelApp::getInstance().getCore()->de431IsActive());
1167 conf->setValue("astro/flag_use_de431", StelApp::getInstance().getCore()->de431IsActive());
1168
1169 resetEphemControls(); //refresh labels
1170}
1171
1172void ConfigurationDialog::resetEphemControls()
1173{
1174 ui->de430checkBox->setEnabled(StelApp::getInstance().getCore()->de430IsAvailable());
1175 ui->de431checkBox->setEnabled(StelApp::getInstance().getCore()->de431IsAvailable());
1176 ui->de430checkBox->setChecked(StelApp::getInstance().getCore()->de430IsActive());
1177 ui->de431checkBox->setChecked(StelApp::getInstance().getCore()->de431IsActive());
1178
1179 if(StelApp::getInstance().getCore()->de430IsActive())
1180 ui->de430label->setText(q_("1550...2650"));
1181 else
1182 {
1183 if (StelApp::getInstance().getCore()->de430IsAvailable())
1184 ui->de430label->setText(q_("Available"));
1185 else
1186 ui->de430label->setText(q_("Not Available"));
1187 }
1188 if(StelApp::getInstance().getCore()->de431IsActive())
1189 ui->de431label->setText(q_("-13.000...17.000"));
1190 else
1191 {
1192 if (StelApp::getInstance().getCore()->de431IsAvailable())
1193 ui->de431label->setText(q_("Available"));
1194 else
1195 ui->de431label->setText(q_("Not Available"));
1196 }
1197}
1198
1199void ConfigurationDialog::downloadEphemData()
1200{
1201 // TODO in connection with the download manager!
1202 resetEphemControls();
1203}
1204
1140void ConfigurationDialog::downloadError(QNetworkReply::NetworkError)1205void ConfigurationDialog::downloadError(QNetworkReply::NetworkError)
1141{1206{
1142 Q_ASSERT(currentDownloadFile);1207 Q_ASSERT(currentDownloadFile);
1143 Q_ASSERT(starCatalogDownloadReply);1208 Q_ASSERT(downloadReply);
11441209
1145 isDownloadingStarCatalog = false;1210 isDownloading = false;
1146 qWarning() << "Error downloading file" << starCatalogDownloadReply->url() << ": " << starCatalogDownloadReply->errorString();1211 if(isDownloadingStarCatalog)
1147 ui->downloadLabel->setText(q_("Error downloading %1:\n%2").arg(nextStarCatalogToDownload.value("id").toString()).arg(starCatalogDownloadReply->errorString()));1212 {
1213 isDownloadingStarCatalog = false;
1214 ui->getStarsButton->setVisible(false);
1215 ui->getStarsButton->setEnabled(true);
1216 }
1217
1218 qWarning() << "Error downloading file" << downloadReply->url() << ": " << downloadReply->errorString();
1219 ui->downloadLabel->setText(q_("Error downloading %1:\n%2").arg(nextStarCatalogToDownload.value("id").toString()).arg(downloadReply->errorString()));
1148 ui->downloadCancelButton->setVisible(false);1220 ui->downloadCancelButton->setVisible(false);
1149 ui->downloadRetryButton->setVisible(true);1221 ui->downloadRetryButton->setVisible(true);
1150 ui->getStarsButton->setVisible(false);1222
1151 ui->getStarsButton->setEnabled(true);1223}
1152}1224
11531225void ConfigurationDialog::ephemDataDownloadFinished()
1154void ConfigurationDialog::downloadFinished()1226{
1227 // TODO in connection with the download manager!
1228
1229}
1230
1231void ConfigurationDialog::starsDownloadFinished()
1155{1232{
1156 Q_ASSERT(currentDownloadFile);1233 Q_ASSERT(currentDownloadFile);
1157 Q_ASSERT(starCatalogDownloadReply);1234 Q_ASSERT(downloadReply);
1158 Q_ASSERT(progressBar);1235 Q_ASSERT(progressBar);
11591236
1160 if (starCatalogDownloadReply->error()!=QNetworkReply::NoError)1237 if (downloadReply->error()!=QNetworkReply::NoError)
1161 {1238 {
1162 starCatalogDownloadReply->deleteLater();1239 downloadReply->deleteLater();
1163 starCatalogDownloadReply = NULL;1240 downloadReply = NULL;
1164 currentDownloadFile->close();1241 currentDownloadFile->close();
1165 currentDownloadFile->deleteLater();1242 currentDownloadFile->deleteLater();
1166 currentDownloadFile = NULL;1243 currentDownloadFile = NULL;
@@ -1169,31 +1246,34 @@
1169 return;1246 return;
1170 }1247 }
11711248
1172 const QVariant& redirect = starCatalogDownloadReply->attribute(QNetworkRequest::RedirectionTargetAttribute);1249 Q_ASSERT(downloadReply->bytesAvailable()==0);
1250
1251 const QVariant& redirect = downloadReply->attribute(QNetworkRequest::RedirectionTargetAttribute);
1173 if (!redirect.isNull())1252 if (!redirect.isNull())
1174 {1253 {
1175 // We got a redirection, we need to follow1254 // We got a redirection, we need to follow
1176 starCatalogDownloadReply->deleteLater();1255 downloadReply->deleteLater();
1177 QNetworkRequest req(redirect.toUrl());1256 QNetworkRequest req(redirect.toUrl());
1178 req.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);1257 req.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);
1179 req.setAttribute(QNetworkRequest::RedirectionTargetAttribute, false);1258 req.setAttribute(QNetworkRequest::RedirectionTargetAttribute, false);
1180 req.setRawHeader("User-Agent", userAgent.toLatin1());1259 req.setRawHeader("User-Agent", userAgent.toLatin1());
1181 starCatalogDownloadReply = StelApp::getInstance().getNetworkAccessManager()->get(req);1260 downloadReply = StelApp::getInstance().getNetworkAccessManager()->get(req);
1182 starCatalogDownloadReply->setReadBufferSize(1024*1024*2);1261 downloadReply->setReadBufferSize(1024*1024*2);
1183 connect(starCatalogDownloadReply, SIGNAL(readyRead()), this, SLOT(newStarCatalogData()));1262 connect(downloadReply, SIGNAL(readyRead()), this, SLOT(newStarCatalogData()));
1184 connect(starCatalogDownloadReply, SIGNAL(finished()), this, SLOT(downloadFinished()));1263 connect(downloadReply, SIGNAL(finished()), this, SLOT(starsDownloadFinished()));
1185 connect(starCatalogDownloadReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));1264 connect(downloadReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
1186 return;1265 return;
1187 }1266 }
11881267
1189 Q_ASSERT(starCatalogDownloadReply->bytesAvailable()==0);1268 Q_ASSERT(downloadReply->bytesAvailable()==0);
11901269
1191 isDownloadingStarCatalog = false;1270 isDownloadingStarCatalog = false;
1271 isDownloading = false;
1192 currentDownloadFile->close();1272 currentDownloadFile->close();
1193 currentDownloadFile->deleteLater();1273 currentDownloadFile->deleteLater();
1194 currentDownloadFile = NULL;1274 currentDownloadFile = NULL;
1195 starCatalogDownloadReply->deleteLater();1275 downloadReply->deleteLater();
1196 starCatalogDownloadReply = NULL;1276 downloadReply = NULL;
1197 StelApp::getInstance().removeProgressBar(progressBar);1277 StelApp::getInstance().removeProgressBar(progressBar);
1198 progressBar=NULL;1278 progressBar=NULL;
11991279
12001280
=== modified file 'src/gui/ConfigurationDialog.hpp'
--- src/gui/ConfigurationDialog.hpp 2015-08-19 11:23:26 +0000
+++ src/gui/ConfigurationDialog.hpp 2016-01-16 17:00:50 +0000
@@ -60,20 +60,26 @@
60 //! Re-translate the contents of the "Star calalogs" box.60 //! Re-translate the contents of the "Star calalogs" box.
61 //! Update the strings according to the state.61 //! Update the strings according to the state.
62 void updateStarCatalogControlsText();62 void updateStarCatalogControlsText();
63 //! True if a star catalog download is in progress.
64 bool isDownloadingStarCatalog;
65 //! Value set by resetStarCatalogControls().63 //! Value set by resetStarCatalogControls().
66 int nextStarCatalogToDownloadIndex;64 int nextStarCatalogToDownloadIndex;
67 //! Value set by resetStarCatalogControls().65 //! Value set by resetStarCatalogControls().
68 int starCatalogsCount;66 int starCatalogsCount;
69 //! True when at least one star catalog has been downloaded successfully this session67 //! True when at least one star catalog has been downloaded successfully this session
70 bool hasDownloadedStarCatalog;68 bool hasDownloadedStarCatalog;
71 QNetworkReply* starCatalogDownloadReply;69 QNetworkReply* downloadReply;
72 QFile* currentDownloadFile;70 QFile* currentDownloadFile;
73 class StelProgressController* progressBar;71 class StelProgressController* progressBar;
7472
75 QString userAgent;73 QString userAgent;
7674
75 //! True if a star catalog download is in progress.
76 bool isDownloadingStarCatalog;
77 //! True if a ephemData download is in progress.
78 bool isDownloadingEphemData;
79 //! True if any download is in progress
80 bool isDownloading;
81
82
77private slots:83private slots:
78 void setNoSelectedInfo();84 void setNoSelectedInfo();
79 void setAllSelectedInfo();85 void setAllSelectedInfo();
@@ -100,7 +106,9 @@
100 void newStarCatalogData();106 void newStarCatalogData();
101 void downloadStars();107 void downloadStars();
102 void cancelDownload();108 void cancelDownload();
103 void downloadFinished();109 void starsDownloadFinished();
110 void ephemDataDownloadFinished();
111 void resetEphemControls();
104 void downloadError(QNetworkReply::NetworkError);112 void downloadError(QNetworkReply::NetworkError);
105113
106 //! Update the labels displaying the current default state114 //! Update the labels displaying the current default state
@@ -148,6 +156,12 @@
148 #endif156 #endif
149 void setFixedDateTimeToCurrent();157 void setFixedDateTimeToCurrent();
150158
159 //! downloads DE430/DE431 ephemData from SourceForge
160 void downloadEphemData();
161
162 void de430ButtonClicked();
163 void de431ButtonClicked();
164
151private:165private:
152 StelGui* gui;166 StelGui* gui;
153167
154168
=== modified file 'src/gui/configurationDialog.ui'
--- src/gui/configurationDialog.ui 2015-11-08 09:52:30 +0000
+++ src/gui/configurationDialog.ui 2016-01-16 17:00:50 +0000
@@ -6,7 +6,7 @@
6 <rect>6 <rect>
7 <x>0</x>7 <x>0</x>
8 <y>0</y>8 <y>0</y>
9 <width>497</width>9 <width>509</width>
10 <height>538</height>10 <height>538</height>
11 </rect>11 </rect>
12 </property>12 </property>
@@ -168,7 +168,7 @@
168 <number>0</number>168 <number>0</number>
169 </property>169 </property>
170 <item>170 <item>
171 <widget class="QGroupBox" name="groupBox_2">171 <widget class="QGroupBox" name="groupBox_LanguageSettings">
172 <property name="title">172 <property name="title">
173 <string>Language settings</string>173 <string>Language settings</string>
174 </property>174 </property>
@@ -269,6 +269,75 @@
269 </widget>269 </widget>
270 </item>270 </item>
271 <item>271 <item>
272 <widget class="QGroupBox" name="groupBox_EphemerisSettings">
273 <property name="title">
274 <string>Ephemeris settings</string>
275 </property>
276 <layout class="QGridLayout" name="gridLayout_ephemeris">
277 <property name="leftMargin">
278 <number>0</number>
279 </property>
280 <property name="topMargin">
281 <number>0</number>
282 </property>
283 <property name="rightMargin">
284 <number>0</number>
285 </property>
286 <property name="bottomMargin">
287 <number>0</number>
288 </property>
289 <item row="0" column="0">
290 <layout class="QGridLayout" name="EphemerisGridLayout">
291 <item row="1" column="1">
292 <widget class="QLabel" name="de431label">
293 <property name="text">
294 <string>Not installed</string>
295 </property>
296 </widget>
297 </item>
298 <item row="0" column="1">
299 <widget class="QLabel" name="de430label">
300 <property name="text">
301 <string>Not installed</string>
302 </property>
303 </widget>
304 </item>
305 <item row="1" column="0">
306 <widget class="QCheckBox" name="de431checkBox">
307 <property name="toolTip">
308 <string>DE431 provides position data for years -13000...+17000. For special applications only.</string>
309 </property>
310 <property name="text">
311 <string>Use DE431 (long-time data)</string>
312 </property>
313 </widget>
314 </item>
315 <item row="0" column="0">
316 <widget class="QCheckBox" name="de430checkBox">
317 <property name="toolTip">
318 <string>DE430 provides highest accuracy, only for years 1550...2650.</string>
319 </property>
320 <property name="text">
321 <string>Use DE430 (high accuracy)</string>
322 </property>
323 </widget>
324 </item>
325 <item row="2" column="0" colspan="2">
326 <widget class="QLabel" name="label_VSOP87used">
327 <property name="toolTip">
328 <string>Using VSOP87 is recommended for years -4000...+8000 only, but delivers useful positions outside this range.</string>
329 </property>
330 <property name="text">
331 <string>VSOP87/ELP2000-82B is used when these are not installed or not activated.</string>
332 </property>
333 </widget>
334 </item>
335 </layout>
336 </item>
337 </layout>
338 </widget>
339 </item>
340 <item>
272 <widget class="QGroupBox" name="groupBox_6">341 <widget class="QGroupBox" name="groupBox_6">
273 <property name="title">342 <property name="title">
274 <string>Default options</string>343 <string>Default options</string>
@@ -1143,16 +1212,6 @@
1143 </property>1212 </property>
1144 </widget>1213 </widget>
1145 </item>1214 </item>
1146 <item row="7" column="0" colspan="2">
1147 <widget class="QCheckBox" name="autoZoomResetsDirectionCheckbox">
1148 <property name="toolTip">
1149 <string>When enabled, the &quot;auto zoom out&quot; key will also set the initial viewing direction</string>
1150 </property>
1151 <property name="text">
1152 <string>Auto zoom out returns to initial direction of view</string>
1153 </property>
1154 </widget>
1155 </item>
1156 <item row="3" column="1">1215 <item row="3" column="1">
1157 <widget class="QCheckBox" name="decimalDegreeCheckBox">1216 <widget class="QCheckBox" name="decimalDegreeCheckBox">
1158 <property name="toolTip">1217 <property name="toolTip">
@@ -1193,6 +1252,16 @@
1193 </property>1252 </property>
1194 </widget>1253 </widget>
1195 </item>1254 </item>
1255 <item row="6" column="0" colspan="2">
1256 <widget class="QCheckBox" name="autoZoomResetsDirectionCheckbox">
1257 <property name="toolTip">
1258 <string>When enabled, the &quot;auto zoom out&quot; key will also set the initial viewing direction</string>
1259 </property>
1260 <property name="text">
1261 <string>Auto zoom out returns to initial direction of view</string>
1262 </property>
1263 </widget>
1264 </item>
1196 </layout>1265 </layout>
1197 </widget>1266 </widget>
1198 </item>1267 </item>