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

KDE's Doxygen guidelines are available online.