• 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/de441.cpp
1
/*
2
Copyright (c) 2021 Georg Zotti
3

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

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

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

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

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

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

46
static bool initDone = false;
47

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

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

69
void TerminateDE441()
×
70
{
71
  jpl_close_ephemeris(ephem);
×
72
}
×
73

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

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

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

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

127

128
#ifdef __cplusplus
129
  }
130
#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