Marble

PlanetFactory.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2009 Henry de Valence <hdevalence@gmail.com>
4// SPDX-FileCopyrightText: 2009 David Roberts <dvdr18@gmail.com>
5// SPDX-FileCopyrightText: 2012 Mohammed Nafees <nafees.technocool@gmail.com>
6// SPDX-FileCopyrightText: 2014 Dennis Nienhüser <nienhueser@kde.org>
7
8#include "PlanetFactory.h"
9#include "MarbleColors.h"
10#include "MarbleDebug.h"
11#include "MarbleGlobal.h"
12#include "Planet.h"
13
14namespace Marble
15{
16
18{
19 QStringList planets;
20
21 planets << QStringLiteral("mercury") << QStringLiteral("venus") << QStringLiteral("earth") << QStringLiteral("mars") << QStringLiteral("jupiter")
22 << QStringLiteral("saturn") << QStringLiteral("uranus") << QStringLiteral("neptune") << QStringLiteral("pluto") << QStringLiteral("sun")
23 << QStringLiteral("moon") << QStringLiteral("sky");
24
25 return planets;
26}
27
29{
30 Planet planet;
31 planet.setId(id);
32
33 // constants taken from https://aa.quae.nl/en/reken/zonpositie.html
34
35 if (id == QLatin1StringView("mercury")) {
36 planet.setM_0(174.7948 * DEG2RAD);
37 planet.setM_1(4.09233445 * DEG2RAD);
38 planet.setC_1(23.4400 * DEG2RAD);
39 planet.setC_2(2.9818 * DEG2RAD);
40 planet.setC_3(0.5255 * DEG2RAD);
41 planet.setC_4(0.1058 * DEG2RAD);
42 planet.setC_5(0.0241 * DEG2RAD);
43 planet.setC_6(0.0055 * DEG2RAD);
44 planet.setPi(111.5943 * DEG2RAD);
45 planet.setEpsilon(0.02 * DEG2RAD);
46 planet.setTheta_0(13.5964 * DEG2RAD);
47 planet.setTheta_1(6.1385025 * DEG2RAD);
48 planet.setRadius(2440000.0);
49 planet.setName(QStringLiteral("Mercury"));
50 planet.setHasAtmosphere(false);
51 } else if (id == QLatin1StringView("venus")) {
52 planet.setM_0(50.4161 * DEG2RAD);
53 planet.setM_1(1.60213034 * DEG2RAD);
54 planet.setC_1(0.7758 * DEG2RAD);
55 planet.setC_2(0.0033 * DEG2RAD);
56 planet.setC_3(0);
57 planet.setC_4(0);
58 planet.setC_5(0);
59 planet.setC_6(0);
60 planet.setPi(73.9519 * DEG2RAD);
61 planet.setEpsilon(2.64 * DEG2RAD);
62 planet.setTheta_0(215.2995 * DEG2RAD);
63 planet.setTheta_1(-1.4813688 * DEG2RAD);
64 planet.setRadius(6051800.0);
65 planet.setTwilightZone(18 * DEG2RAD);
66 planet.setName(QStringLiteral("Venus"));
67 planet.setHasAtmosphere(true);
68 planet.setAtmosphereColor(Oxygen::sunYellow4);
69 } else if (id == QLatin1StringView("earth")) {
70 planet.setM_0(357.5291 * DEG2RAD);
71 planet.setM_1(0.98560028 * DEG2RAD);
72 planet.setC_1(1.9148 * DEG2RAD);
73 planet.setC_2(0.0200 * DEG2RAD);
74 planet.setC_3(0.0003 * DEG2RAD);
75 planet.setC_4(0);
76 planet.setC_5(0);
77 planet.setC_6(0);
78 planet.setPi(102.9372 * DEG2RAD);
79 planet.setEpsilon(23.43686 * DEG2RAD);
80 planet.setTheta_0(280.1600 * DEG2RAD);
81 planet.setTheta_1(360.9856235 * DEG2RAD);
82 planet.setRadius(6378137.0);
83 planet.setTwilightZone(18 * DEG2RAD);
84 planet.setName(QStringLiteral("Earth"));
85 planet.setHasAtmosphere(true);
86 planet.setAtmosphereColor(Qt::white);
87 } else if (id == QLatin1StringView("mars")) {
88 planet.setM_0(19.3730 * DEG2RAD);
89 planet.setM_1(0.52402068 * DEG2RAD);
90 planet.setC_1(10.6912 * DEG2RAD);
91 planet.setC_2(0.6228 * DEG2RAD);
92 planet.setC_3(0.0503 * DEG2RAD);
93 planet.setC_4(0.0046 * DEG2RAD);
94 planet.setC_5(0.0005 * DEG2RAD);
95 planet.setC_6(0);
96 planet.setPi(70.9812 * DEG2RAD);
97 planet.setEpsilon(25.19 * DEG2RAD);
98 planet.setTheta_0(313.4803 * DEG2RAD);
99 planet.setTheta_1(350.89198226 * DEG2RAD);
100 planet.setRadius(3397000.0);
101 planet.setTwilightZone(9.0 * DEG2RAD);
102 planet.setName(QStringLiteral("Mars"));
103 planet.setHasAtmosphere(true);
104 planet.setAtmosphereColor(Oxygen::hotOrange2);
105 } else if (id == QLatin1StringView("jupiter")) {
106 planet.setM_0(20.0202 * DEG2RAD);
107 planet.setM_1(0.08308529 * DEG2RAD);
108 planet.setC_1(5.5549 * DEG2RAD);
109 planet.setC_2(0.1683 * DEG2RAD);
110 planet.setC_3(0.0071 * DEG2RAD);
111 planet.setC_4(0.0003 * DEG2RAD);
112 planet.setC_5(0);
113 planet.setC_6(0);
114 planet.setPi(237.2074 * DEG2RAD);
115 planet.setEpsilon(3.12 * DEG2RAD);
116 planet.setTheta_0(146.0727 * DEG2RAD);
117 planet.setTheta_1(870.5366420 * DEG2RAD);
118 planet.setRadius(71492000.0);
119 planet.setName(QStringLiteral("Jupiter"));
120 planet.setHasAtmosphere(true);
121 planet.setAtmosphereColor(Oxygen::sunYellow2);
122 } else if (id == QLatin1StringView("saturn")) {
123 planet.setM_0(317.0207 * DEG2RAD);
124 planet.setM_1(0.03344414 * DEG2RAD);
125 planet.setC_1(6.3585 * DEG2RAD);
126 planet.setC_2(0.2204 * DEG2RAD);
127 planet.setC_3(0.0106 * DEG2RAD);
128 planet.setC_4(0.0006 * DEG2RAD);
129 planet.setC_5(0);
130 planet.setC_6(0);
131 planet.setPi(99.4571 * DEG2RAD);
132 planet.setEpsilon(26.74 * DEG2RAD);
133 planet.setTheta_0(174.3479 * DEG2RAD);
134 planet.setTheta_1(810.7939024 * DEG2RAD);
135 planet.setRadius(60268000.0);
136 planet.setName(QStringLiteral("Saturn"));
137 planet.setHasAtmosphere(true);
138 planet.setAtmosphereColor(Oxygen::sunYellow2);
139 } else if (id == QLatin1StringView("uranus")) {
140 planet.setM_0(141.0498 * DEG2RAD);
141 planet.setM_1(0.01172834 * DEG2RAD);
142 planet.setC_1(5.3042 * DEG2RAD);
143 planet.setC_2(0.1534 * DEG2RAD);
144 planet.setC_3(0.0062 * DEG2RAD);
145 planet.setC_4(0.0003 * DEG2RAD);
146 planet.setC_5(0);
147 planet.setC_6(0);
148 planet.setPi(5.4639 * DEG2RAD);
149 planet.setEpsilon(82.22 * DEG2RAD);
150 planet.setTheta_0(17.9705 * DEG2RAD);
151 planet.setTheta_1(-501.1600928 * DEG2RAD);
152 planet.setRadius(25559000.0);
153 planet.setName(QStringLiteral("Uranus"));
154 planet.setHasAtmosphere(true);
155 planet.setAtmosphereColor(Oxygen::seaBlue4);
156 } else if (id == QLatin1StringView("neptune")) {
157 planet.setM_0(256.2250 * DEG2RAD);
158 planet.setM_1(0.00598103 * DEG2RAD);
159 planet.setC_1(1.0302 * DEG2RAD);
160 planet.setC_2(0.0058 * DEG2RAD);
161 planet.setC_3(0);
162 planet.setC_4(0);
163 planet.setC_5(0);
164 planet.setC_6(0);
165 planet.setPi(182.1957 * DEG2RAD);
166 planet.setEpsilon(27.84 * DEG2RAD);
167 planet.setTheta_0(52.3996 * DEG2RAD);
168 planet.setTheta_1(536.3128492 * DEG2RAD);
169 planet.setRadius(24766000.0);
170 planet.setName(QStringLiteral("Neptune"));
171 planet.setHasAtmosphere(true);
172 planet.setAtmosphereColor(Oxygen::skyBlue2);
173 } else if (id == QLatin1StringView("pluto")) {
174 // dwarf planets ... (everybody likes pluto)
175 planet.setM_0(14.882 * DEG2RAD);
176 planet.setM_1(0.00396 * DEG2RAD);
177 planet.setC_1(28.3150 * DEG2RAD);
178 planet.setC_2(4.3408 * DEG2RAD);
179 planet.setC_3(0.9214 * DEG2RAD);
180 planet.setC_4(0.2235 * DEG2RAD);
181 planet.setC_5(0.0627 * DEG2RAD);
182 planet.setC_6(0.0174 * DEG2RAD);
183 planet.setPi(4.5433 * DEG2RAD);
184 planet.setEpsilon(57.46 * DEG2RAD);
185 planet.setTheta_0(56.3183 * DEG2RAD);
186 planet.setTheta_1(-56.3623195 * DEG2RAD);
187 planet.setRadius(1151000.0);
188 planet.setName(QStringLiteral("Pluto"));
189 planet.setHasAtmosphere(false);
190 } else if (id == QLatin1StringView("sun")) {
191 mDebug() << "WARNING: Creating Planet instance" << id << "with invalid orbital elements";
192 planet.setRadius(695000000.0);
193 // FIXME: fill in with valid data
194 planet.setName(QStringLiteral("Sun"));
195 planet.setHasAtmosphere(true);
196 planet.setAtmosphereColor(Qt::white);
197 } else if (id == QLatin1StringView("moon")) {
198 mDebug() << "WARNING: Creating Planet instance" << id << "with invalid orbital elements";
199 planet.setRadius(1738000.0);
200 // FIXME: fill in with valid data
201 planet.setName(QStringLiteral("Moon"));
202 planet.setHasAtmosphere(false);
203 } else if (id == QLatin1StringView("sky")) {
204 mDebug() << "WARNING: Creating Planet instance" << id << "with invalid orbital elements";
205 planet.setRadius(10000000.0);
206 planet.setName(QStringLiteral("Sky"));
207 planet.setHasAtmosphere(false);
208 } else {
209 mDebug() << "WARNING: Creating Planet instance" << id << "with invalid orbital elements";
210 planet.setRadius(10000000.0);
211 planet.setName(QStringLiteral("Unknown"));
212 planet.setHasAtmosphere(false);
213 }
214
215 return planet;
216}
217
219{
220 if (id == QLatin1StringView("mercury")) {
221 return QObject::tr("Mercury", "the planet");
222 } else if (id == QLatin1StringView("venus")) {
223 return QObject::tr("Venus", "the planet");
224 } else if (id == QLatin1StringView("earth")) {
225 return QObject::tr("Earth", "the planet");
226 } else if (id == QLatin1StringView("mars")) {
227 return QObject::tr("Mars", "the planet");
228 } else if (id == QLatin1StringView("jupiter")) {
229 return QObject::tr("Jupiter", "the planet");
230 } else if (id == QLatin1StringView("saturn")) {
231 return QObject::tr("Saturn", "the planet");
232 } else if (id == QLatin1StringView("uranus")) {
233 return QObject::tr("Uranus", "the planet");
234 } else if (id == QLatin1StringView("neptune")) {
235 return QObject::tr("Neptune", "the planet");
236 // dwarf planets ... (everybody likes pluto)
237 } else if (id == QLatin1StringView("pluto")) {
238 return QObject::tr("Pluto", "the planet");
239 // sun, moon and sky
240 } else if (id == QLatin1StringView("sun")) {
241 return QObject::tr("Sun", "the earth's star");
242 } else if (id == QLatin1StringView("moon")) {
243 return QObject::tr("Moon", "the earth's moon");
244 } else if (id == QLatin1StringView("sky")) {
245 return QObject::tr("Sky");
246 } else if (id.isEmpty()) {
247 mDebug() << "Warning: empty id";
248 return QObject::tr("Unknown Planet", "a planet without data");
249 }
250
251 return id;
252}
253
254}
static Planet construct(const QString &id)
Creates the planet with the given ID, or one with default values if ID is not among planetList()
static QList< QString > planetList()
Provides a list of known planet IDs.
static QString localizedName(const QString &id)
Returns a localized name of the planet with the given ID.
Binds a QML item to a specific geodetic location in screen coordinates.
QString tr(const char *sourceText, const char *disambiguation, int n)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.