• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Stellarium / stellarium / 10124913218

27 Jul 2024 04:27PM UTC coverage: 12.208%. First build
10124913218

Pull #3794

github

gzotti
Reduced to max.4 additional threads
Pull Request #3794: Parallelize ephemeris computation with C++ parallelism.

208 of 369 new or added lines in 24 files covered. (56.37%)

14439 of 118271 relevant lines covered (12.21%)

19314.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/core/planetsephems/de431.cpp
1
/*
2
Copyright (c) 2015 Holger Niessner
3
Copyright (c) 2016 Georg Zotti
4

5
Permission is hereby granted, free of charge, to any person obtaining a copy
6
of this software and associated documentation files (the "Software"), to deal
7
in the Software without restriction, including without limitation the rights
8
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
copies of the Software, and to permit persons to whom the Software is
10
furnished to do so, subject to the following conditions:
11

12
The above copyright notice and this permission notice shall be included in
13
all copies or substantial portions of the Software.
14

15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
THE SOFTWARE.
22
*/
23

24
#include "de431.hpp"
25
#include "jpleph.h"
26
#include "StelUtils.hpp"
27
#ifndef UNIT_TEST
28
#include "StelCore.hpp"
29
#include "StelApp.hpp"
30
#else
31
#include "VecMath.hpp"
32
#endif
33

34
#ifdef __cplusplus
35
  extern "C" {
36
#endif
37

38
static void * ephem;
39
   
40
static char nams[JPL_MAX_N_CONSTANTS][6];
41
static double vals[JPL_MAX_N_CONSTANTS];
42
#ifdef UNIT_TEST
43
// NOTE: Added hook for unit testing
44
static const Mat4d matJ2000ToVsop87(Mat4d::xrotation(-23.4392803055555555556*(M_PI/180)) * Mat4d::zrotation(0.0000275*(M_PI/180)));
45
#endif
46

47
static bool initDone = false;
48

49
void InitDE431(const char* filepath)
×
50
{
51
        ephem = jpl_init_ephemeris(filepath, nams, vals);
×
52

53
        if(jpl_init_error_code() != 0)
×
54
        {
55
                #ifndef UNIT_TEST
56
                StelApp::getInstance().getCore()->setDe431Active(false);
×
57
                #endif
58
                qDebug().noquote() << "Error"<< jpl_init_error_code() << "at DE431 init:" << jpl_init_error_message();
×
59
        }
60
        else
61
        {
62
                initDone = true;
×
63
                double jd1, jd2;
64
                jd1=jpl_get_double(ephem, JPL_EPHEM_START_JD);
×
65
                jd2=jpl_get_double(ephem, JPL_EPHEM_END_JD);
×
66
                qDebug().noquote().nospace() << "DE431 init successful. JD range " << QString::number(jd1, 'f', 4) << ".." << QString::number(jd2, 'f', 4);
×
67
        }
68
}
×
69

70
void TerminateDE431()
×
71
{
72
  jpl_close_ephemeris(ephem);
×
73
}
×
74

75
bool GetDe431Coor(const double jde, const int planet_id, double * xyz, const int centralBody_id)
×
76
{
77
    if(initDone)
×
78
    {
79
        double tempXYZ[6];
80
        // This may return some error code!
81
        int jplresult=jpl_pleph(ephem, jde, planet_id, centralBody_id, tempXYZ, 1);
×
82

83
        switch (jplresult)
×
84
        {
85
                case 0: // all OK.
×
86
                        break;
×
87
                case JPL_EPH_OUTSIDE_RANGE:
×
88
                        qDebug().noquote() << "GetDe431Coor: JPL_EPH_OUTSIDE_RANGE at jde" << jde << "for planet" << planet_id;
×
89
                        return false;
×
90
                case JPL_EPH_READ_ERROR:
×
91
                        qDebug().noquote() << "GetDe431Coor: JPL_EPH_READ_ERROR at jde" << jde << "for planet" << planet_id;
×
92
                        return false;
×
93
                case JPL_EPH_QUANTITY_NOT_IN_EPHEMERIS:
×
94
                        qDebug().noquote() << "GetDe431Coor: JPL_EPH_QUANTITY_NOT_IN_EPHEMERIS at jde" << jde << "for planet" << planet_id;
×
95
                        return false;
×
96
                case JPL_EPH_INVALID_INDEX:
×
97
                        qDebug().noquote() << "GetDe431Coor: JPL_EPH_INVALID_INDEX at jde" << jde << "for planet" << planet_id;
×
98
                        return false;
×
99
                case JPL_EPH_FSEEK_ERROR:
×
100
                        qDebug().noquote() << "GetDe431Coor: JPL_EPH_FSEEK_ERROR at jde" << jde << "for planet" << planet_id;
×
101
                        return false;
×
102
                default: // Should never happen...
×
103
                        qDebug().noquote() << "GetDe431Coor: unknown error" << jplresult << "at jde" << jde << "for planet" << planet_id;
×
104
                        return false;
×
105
        }
106

NEW
107
        const Vec3d tempICRFpos = Vec3d(tempXYZ[0], tempXYZ[1], tempXYZ[2]);
×
NEW
108
        const Vec3d tempICRFspd = Vec3d(tempXYZ[3], tempXYZ[4], tempXYZ[5]);
×
109
        #ifdef UNIT_TEST
110
        Vec3d tempECLpos = matJ2000ToVsop87 * tempICRFpos;
111
        Vec3d tempECLspd = matJ2000ToVsop87 * tempICRFspd;
112
        #else
NEW
113
        Vec3d tempECLpos = StelCore::matJ2000ToVsop87 * tempICRFpos;
×
NEW
114
        Vec3d tempECLspd = StelCore::matJ2000ToVsop87 * tempICRFspd;
×
115
        #endif
116

117
        xyz[0] = tempECLpos[0];
×
118
        xyz[1] = tempECLpos[1];
×
119
        xyz[2] = tempECLpos[2];
×
120
        xyz[3] = tempECLspd[0];
×
121
        xyz[4] = tempECLspd[1];
×
122
        xyz[5] = tempECLspd[2];
×
123
        return true;
×
124
    }
125
    return false;
×
126
}
127

128

129
#ifdef __cplusplus
130
  }
131
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc