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

Stellarium / stellarium / 9545309360

16 Jun 2024 08:38PM UTC coverage: 12.262% (-0.01%) from 12.274%
9545309360

push

github

web-flow
Translate stellarium-remotecontrol.pot in gl

100% translated source file: 'stellarium-remotecontrol.pot'
on 'gl'.

14429 of 117670 relevant lines covered (12.26%)

18515.08 hits per line

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

0.0
/src/core/SolarEclipseComputer.hpp
1
/*
2
 * Stellarium
3
 * 
4
 * Copyright (C) 2022 Worachate Boonplod
5
 * Copyright (C) 2022 Georg Zotti
6
 * Copyright (C) 2024 Ruslan Kabatsayev
7
 * 
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 * 
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
20
*/
21

22
#ifndef SOLARECLIPSE_HPP
23
#define SOLARECLIPSE_HPP
24

25
#include <deque>
26
#include <vector>
27
#include <variant>
28
#include "Planet.hpp"
29

30
class StelCore;
31
class StelLocaleMgr;
32

33
struct EclipseBesselElements
34
{
35
        double x;   //!< x coordinate of the shadow axis in the fundamental plane (in units of equatorial Earth radius)
36
        double y;   //!< y coordinate of the shadow axis in the fundamental plane (in units of equatorial Earth radius)
37
        double d;   //!< declination of the shadow axis direction in the celestial sphere (in radians)
38
        double mu;  //!< Greenwich hour angle of the shadow axis direction in the celestial sphere (in degrees)
39
        double tf1; //!< tangent of the angle of the penumbral shadow cone with the shadow axis
40
        double tf2; //!< tangent of the angle of the umbral shadow cone with the shadow axis
41
        double L1;  //!< radius of the penumbral shadow on the fundamental plane (in units of equatorial Earth radius)
42
        double L2;  //!< radius of the umbral shadow on the fundamental plane (in units of equatorial Earth radius)
43
};
44

45
//! Calculate Besselian elements of solar eclipse
46
EclipseBesselElements calcSolarEclipseBessel();
47

48
struct EclipseBesselParameters
49
{
50
        double xdot;  //!< rate of change of X in Earth radii per second
51
        double ydot;  //!< rate of change of Y in Earth radii per second
52
        double ddot;  //!< rate of change of d in radians per second
53
        double mudot; //!< rate of change of mu in radians per second
54
        double ldot;  //!< rate of change of L1 (for penumbra) or L2 (for umbra) in Earth radii per second
55
        double etadot;
56
        double bdot;
57
        double cdot;
58
        EclipseBesselElements elems;
59
};
60

61
// Compute parameters from Besselian elements
62
EclipseBesselParameters calcBesselParameters(bool penumbra);
63

64
// Calculate solar eclipse data at given time
65
void calcSolarEclipseData(double JD, double &dRatio, double &latDeg, double &lngDeg, double &altitude,
66
                          double &pathWidth, double &duration, double &magnitude);
67

68
class SolarEclipseComputer
69
{
70
public:
71
        struct EclipseMapData
72
        {
73
                enum class EclipseType
74
                {
75
                        Undefined,
76
                        Total,
77
                        Annular,
78
                        Hybrid,
79
                };
80
                struct GeoPoint
81
                {
82
                        double longitude;
83
                        double latitude;
84

85
                        GeoPoint() = default;
86
                        GeoPoint(double lon, double lat)
×
87
                                : longitude(lon), latitude(lat)
×
88
                        {
89
                        }
×
90
                };
91
                struct GeoTimePoint
92
                {
93
                        double JD = -1;
94
                        double longitude;
95
                        double latitude;
96

97
                        GeoTimePoint() = default;
×
98
                        GeoTimePoint(double JD, double lon, double lat)
×
99
                                : JD(JD), longitude(lon), latitude(lat)
×
100
                        {
101
                        }
×
102
                };
103
                struct UmbraOutline
104
                {
105
                        std::vector<GeoPoint> curve;
106
                        double JD;
107
                        EclipseType eclipseType = EclipseType::Undefined;
108
                };
109
                GeoTimePoint greatestEclipse;
110
                GeoTimePoint firstContactWithEarth; // AKA P1
111
                GeoTimePoint lastContactWithEarth;  // AKA P4
112
                GeoTimePoint centralEclipseStart;   // AKA C1
113
                GeoTimePoint centralEclipseEnd;     // AKA C2
114

115
                // Generally these lines are supposed to represent the north and south limits of
116
                // penumbra. But in practice they are computed in smaller segments, so there'll
117
                // usually be more than two.
118
                std::vector<std::vector<GeoTimePoint>> penumbraLimits;
119

120
                // The curves in arrays are split into two lines by the computation algorithm
121
                struct TwoLimits
122
                {
123
                        std::vector<GeoPoint> p12curve;
124
                        std::vector<GeoPoint> p34curve;
125
                };
126
                struct SingleLimit
127
                {
128
                        std::vector<GeoPoint> curve;
129
                };
130
                std::variant<SingleLimit,TwoLimits> riseSetLimits[2];
131

132
                // These curves appear to be split generally in multiple sections
133
                std::vector<std::deque<GeoTimePoint>> maxEclipseAtRiseSet;
134

135
                std::vector<GeoPoint> centerLine;
136
                std::vector<UmbraOutline> umbraOutlines;
137
                std::vector<std::vector<GeoTimePoint>> umbraLimits;
138

139
                EclipseType eclipseType;
140
        };
141

142
        struct GeoPoint
143
        {
144
                double latitude;
145
                double longitude;
146
                GeoPoint() = default;
147
                GeoPoint(double latitude, double longitude)
×
148
                        : latitude(latitude), longitude(longitude)
×
149
                {
150
                }
×
151
        };
152

153
        SolarEclipseComputer(StelCore* core, StelLocaleMgr* localeMgr);
154
        EclipseMapData generateEclipseMap(const double JDMid) const;
155

156
        //! Geographic coordinates of extreme contact
157
        GeoPoint getContactCoordinates(double x, double y, double d, double mu) const;
158
        //! Geographic coordinates where solar eclipse begins/ends at sunrise/sunset
159
        GeoPoint getRiseSetLineCoordinates(bool first, double x, double y, double d, double L, double mu) const;
160
        //! Geographic coordinates where maximum solar eclipse occurs at sunrise/sunset
161
        GeoPoint getMaximumEclipseAtRiseSet(bool first, double JD) const;
162
        //! Geographic coordinates of shadow outline
163
        GeoPoint getShadowOutlineCoordinates(double angle, double x, double y, double d, double L, double tf,double mu) const;
164
        //! Iteration to calculate minimum distance from Besselian elements
165
        double getJDofMinimumDistance(double JD) const;
166
        //! Iteration to calculate JD of solar eclipse contacts
167
        double getJDofContact(double JD, bool beginning, bool penumbral, bool external, bool outerContact) const;
168
        //! Iteration to calculate contact times of solar eclipse
169
        double getDeltaTimeOfContact(double JD, bool beginning, bool penumbra, bool external, bool outerContact) const;
170

171
        void generateKML(const EclipseMapData& data, const QString& dateString, QTextStream& stream) const;
172
        bool generatePNGMap(const EclipseMapData& data, const QString& filePath) const;
173

174
private:
175
        //! Check whether both northern and southern penumbra limits exist for a given eclipsee
176
        //! @param JDMid time of greatest eclipse
177
        bool bothPenumbraLimitsPresent(double JDMid) const;
178

179
        void computeNSLimitsOfShadow(double JDP1, double JDP4, bool penumbra,
180
                                     std::vector<std::vector<EclipseMapData::GeoTimePoint>>& limits) const;
181

182
private:
183
        StelCore* core = nullptr;
184
        StelLocaleMgr* localeMgr = nullptr;
185
};
186

187
#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