1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332 | /* ============================================================
*
* This file is a part of digiKam project
* https://www.digikam.org
*
* Date : 2023-05-15
* Description : geolocation engine based on Marble.
* (c) 2007-2022 Marble Team
* https://invent.kde.org/education/marble/-/raw/master/data/credits_authors.html
*
* SPDX-FileCopyrightText: 2023-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* ============================================================ */
#include "Planet.h"
// Qt includes
#include <QString>
// Local includes
#include "PlanetFactory.h"
#include "MarbleGlobal.h"
#include "MarbleColors.h"
#include "solarsystem.h"
#include "digikam_debug.h"
namespace Marble
{
class Q_DECL_HIDDEN PlanetPrivate
{
public:
qreal M_0, M_1; // for calculating mean anomaly
qreal C_1, C_2, C_3, C_4, C_5, C_6; // for calculating equation of center
qreal Pi; // ecliptic longitude of the perihelion
qreal epsilon; // obliquity of the ecliptic plane
qreal theta_0, theta_1; // for calculating sidereal time
qreal radius; // in metres
qreal twilightZone;
QString name, id; // localized and nonlocalized names
bool atmosphere;
QColor atmosphereColor;
PlanetPrivate()
: M_0(0.0),
M_1(0.0),
C_1(0.0),
C_2(0.0),
C_3(0.0),
C_4(0.0),
C_5(0.0),
C_6(0.0),
Pi(0.0),
epsilon(0.0),
theta_0(0.0),
theta_1(0.0),
radius(10000000.0),
twilightZone(0),
name(),
id(),
atmosphere(false)
{
// nothing to do
}
};
//Constructor
Planet::Planet()
: d(new PlanetPrivate)
{
// nothing to do
}
Planet::Planet(const QString& id)
: d(new PlanetPrivate)
{
*this = PlanetFactory::construct(id);
}
//Copy Constructor
Planet::Planet(const Planet& other)
: d(new PlanetPrivate)
{
// PlanetPrivate does not have pointer members, so we can just
// use its (compiler generated) assignment operator.
*d = *other.d;
}
//Destructor
Planet::~Planet()
{
delete d;
}
/* Getter functions */
// for calculating mean anomaly
qreal Planet::M_0() const
{
return d->M_0;
}
qreal Planet::M_1() const
{
return d->M_1;
}
// for calculating equation of center
qreal Planet::C_1() const
{
return d->C_1;
}
qreal Planet::C_2() const
{
return d->C_2;
}
qreal Planet::C_3() const
{
return d->C_3;
}
qreal Planet::C_4() const
{
return d->C_4;
}
qreal Planet::C_5() const
{
return d->C_5;
}
qreal Planet::C_6() const
{
return d->C_6;
}
// ecliptic longitude of the perihelion
qreal Planet::Pi() const
{
return d->Pi;
}
// obliquity of the ecliptic plane
qreal Planet::epsilon() const
{
return d->epsilon;
}
// for calculating sidereal time
qreal Planet::theta_0() const
{
return d->theta_0;
}
qreal Planet::theta_1() const
{
return d->theta_1;
}
// the radius of the planet, in metres
qreal Planet::radius() const
{
return d->radius;
}
qreal Planet::twilightZone() const
{
return d->twilightZone;
}
QString Planet::name() const
{
return d->name;
}
QString Planet::id() const
{
return d->id;
}
void Planet::sunPosition(qreal& lon, qreal& lat, const QDateTime& dateTime) const
{
SolarSystem sys;
sys.setCurrentMJD(
dateTime.date().year(), dateTime.date().month(), dateTime.date().day(),
dateTime.time().hour(), dateTime.time().minute(),
(double)dateTime.time().second());
const QString pname = d->id.at(0).toUpper() + d->id.right(d->id.size() - 1);
QByteArray name = pname.toLatin1();<--- Shadow local variable
sys.setCentralBody(name.data());
double ra = 0.0;
double decl = 0.0;
sys.getSun(ra, decl);
double _lon = 0.0;
double _lat = 0.0;
sys.getPlanetographic(ra, decl, _lon, _lat);
lon = _lon * DEG2RAD;
lat = _lat * DEG2RAD;
}
/* Setter functions */
void Planet::setM_0(qreal M_0)<--- Shadow argument
{
d->M_0 = M_0;
}
void Planet::setM_1(qreal M_1)<--- Shadow argument
{
d->M_1 = M_1;
}
void Planet::setC_1(qreal C_1)<--- Shadow argument
{
d->C_1 = C_1;
}
void Planet::setC_2(qreal C_2)<--- Shadow argument
{
d->C_2 = C_2;
}
void Planet::setC_3(qreal C_3)<--- Shadow argument
{
d->C_3 = C_3;
}
void Planet::setC_4(qreal C_4)<--- Shadow argument
{
d->C_4 = C_4;
}
void Planet::setC_5(qreal C_5)<--- Shadow argument
{
d->C_5 = C_5;
}
void Planet::setC_6(qreal C_6)<--- Shadow argument
{
d->C_6 = C_6;
}
void Planet::setPi(qreal Pi)<--- Shadow argument
{
d->Pi = Pi;
}
void Planet::setEpsilon(qreal epsilon)<--- Shadow argument
{
d->epsilon = epsilon;
}
void Planet::setTheta_0(qreal theta_0)<--- Shadow argument
{
d->theta_0 = theta_0;
}
void Planet::setTheta_1(qreal theta_1)<--- Shadow argument
{
d->theta_1 = theta_1;
}
void Planet::setRadius(qreal radius)<--- Shadow argument
{
d->radius = radius;
}
void Planet::setTwilightZone(qreal twilightZone)<--- Shadow argument
{
d->twilightZone = twilightZone;
}
void Planet::setName(const QString& name)<--- Shadow argument
{
d->name = name;
}
void Planet::setId(const QString& id)<--- Shadow argument
{
d->id = id;
}
QString Planet::name(const QString& id)<--- Shadow argument
{
return PlanetFactory::localizedName(id);
}
QStringList Planet::planetList()
{
return PlanetFactory::planetList();
}
Planet& Planet::operator=(const Planet& rhs)
{
// PlanetPrivate does not have pointer members, so we can just
// use its (compiler generated) assignment operator.
*d = *rhs.d;
return *this;
}
bool Planet::hasAtmosphere() const
{
return d->atmosphere;
}
void Planet::setHasAtmosphere(bool enabled)
{
d->atmosphere = enabled;
}
QColor Planet::atmosphereColor() const
{
return d->atmosphereColor;
}
void Planet::setAtmosphereColor(const QColor& color)
{
d->atmosphereColor = color;
}
} // namespace Marble
|