File indexing completed on 2025-01-05 03:58:42
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2009 Henry de Valence <hdevalence@gmail.com> 0004 // SPDX-FileCopyrightText: 2009 David Roberts <dvdr18@gmail.com> 0005 // SPDX-FileCopyrightText: 2012 Mohammed Nafees <nafees.technocool@gmail.com> 0006 // SPDX-FileCopyrightText: 2014 Dennis Nienhüser <nienhueser@kde.org> 0007 0008 #include "PlanetFactory.h" 0009 0010 #include <klocalizedstring.h> 0011 0012 #include "Planet.h" 0013 #include "MarbleColors.h" 0014 #include "MarbleGlobal.h" 0015 0016 #include "digikam_debug.h" 0017 0018 namespace Marble { 0019 0020 QList<QString> PlanetFactory::planetList() 0021 { 0022 QStringList planets; 0023 0024 planets << QString::fromUtf8("mercury") 0025 << QString::fromUtf8("venus") 0026 << QString::fromUtf8("earth") 0027 << QString::fromUtf8("mars") 0028 << QString::fromUtf8("jupiter") 0029 << QString::fromUtf8("saturn") 0030 << QString::fromUtf8("uranus") 0031 << QString::fromUtf8("neptune") 0032 << QString::fromUtf8("pluto") 0033 << QString::fromUtf8("sun") 0034 << QString::fromUtf8("moon") 0035 << QString::fromUtf8("sky"); 0036 0037 return planets; 0038 } 0039 0040 Planet PlanetFactory::construct( const QString &id ) 0041 { 0042 Planet planet; 0043 planet.setId( id ); 0044 0045 // constants taken from https://aa.quae.nl/en/reken/zonpositie.html 0046 0047 if (id == QLatin1String("mercury")) { 0048 planet.setM_0( 174.7948*DEG2RAD ); 0049 planet.setM_1( 4.09233445*DEG2RAD ); 0050 planet.setC_1( 23.4400*DEG2RAD ); 0051 planet.setC_2( 2.9818*DEG2RAD ); 0052 planet.setC_3( 0.5255*DEG2RAD ); 0053 planet.setC_4( 0.1058*DEG2RAD ); 0054 planet.setC_5( 0.0241*DEG2RAD ); 0055 planet.setC_6( 0.0055*DEG2RAD ); 0056 planet.setPi( 111.5943*DEG2RAD ); 0057 planet.setEpsilon( 0.02*DEG2RAD ); 0058 planet.setTheta_0( 13.5964*DEG2RAD ); 0059 planet.setTheta_1( 6.1385025*DEG2RAD ); 0060 planet.setRadius( 2440000.0 ); 0061 planet.setName(QStringLiteral("Mercury")); 0062 planet.setHasAtmosphere( false ); 0063 } else if (id == QLatin1String("venus")) { 0064 planet.setM_0( 50.4161*DEG2RAD ); 0065 planet.setM_1( 1.60213034*DEG2RAD ); 0066 planet.setC_1( 0.7758*DEG2RAD ); 0067 planet.setC_2( 0.0033*DEG2RAD ); 0068 planet.setC_3( 0 ); 0069 planet.setC_4( 0 ); 0070 planet.setC_5( 0 ); 0071 planet.setC_6( 0 ); 0072 planet.setPi( 73.9519*DEG2RAD ); 0073 planet.setEpsilon( 2.64*DEG2RAD ); 0074 planet.setTheta_0( 215.2995*DEG2RAD ); 0075 planet.setTheta_1( -1.4813688*DEG2RAD ); 0076 planet.setRadius( 6051800.0 ); 0077 planet.setTwilightZone(18*DEG2RAD); 0078 planet.setName(QStringLiteral("Venus")); 0079 planet.setHasAtmosphere( true ); 0080 planet.setAtmosphereColor( Oxygen::sunYellow4 ); 0081 } else if (id == QLatin1String("earth")) { 0082 planet.setM_0( 357.5291*DEG2RAD ); 0083 planet.setM_1( 0.98560028*DEG2RAD ); 0084 planet.setC_1( 1.9148*DEG2RAD ); 0085 planet.setC_2( 0.0200*DEG2RAD ); 0086 planet.setC_3( 0.0003*DEG2RAD ); 0087 planet.setC_4( 0 ); 0088 planet.setC_5( 0 ); 0089 planet.setC_6( 0 ); 0090 planet.setPi( 102.9372*DEG2RAD ); 0091 planet.setEpsilon( 23.43686*DEG2RAD ); 0092 planet.setTheta_0( 280.1600*DEG2RAD ); 0093 planet.setTheta_1( 360.9856235*DEG2RAD ); 0094 planet.setRadius( 6378137.0 ); 0095 planet.setTwilightZone(18*DEG2RAD); 0096 planet.setName(QStringLiteral("Earth")); 0097 planet.setHasAtmosphere( true ); 0098 planet.setAtmosphereColor( Qt::white ); 0099 } else if (id == QLatin1String("mars")) { 0100 planet.setM_0( 19.3730*DEG2RAD ); 0101 planet.setM_1( 0.52402068*DEG2RAD ); 0102 planet.setC_1( 10.6912*DEG2RAD ); 0103 planet.setC_2( 0.6228*DEG2RAD ); 0104 planet.setC_3( 0.0503*DEG2RAD ); 0105 planet.setC_4( 0.0046*DEG2RAD ); 0106 planet.setC_5( 0.0005*DEG2RAD ); 0107 planet.setC_6( 0 ); 0108 planet.setPi( 70.9812*DEG2RAD ); 0109 planet.setEpsilon( 25.19*DEG2RAD ); 0110 planet.setTheta_0( 313.4803*DEG2RAD ); 0111 planet.setTheta_1( 350.89198226*DEG2RAD ); 0112 planet.setRadius( 3397000.0 ); 0113 planet.setTwilightZone(9.0*DEG2RAD); 0114 planet.setName(QStringLiteral("Mars")); 0115 planet.setHasAtmosphere( true ); 0116 planet.setAtmosphereColor( Oxygen::hotOrange2 ); 0117 } else if (id == QLatin1String("jupiter")) { 0118 planet.setM_0( 20.0202*DEG2RAD ); 0119 planet.setM_1( 0.08308529*DEG2RAD ); 0120 planet.setC_1( 5.5549*DEG2RAD ); 0121 planet.setC_2( 0.1683*DEG2RAD ); 0122 planet.setC_3( 0.0071*DEG2RAD ); 0123 planet.setC_4( 0.0003*DEG2RAD ); 0124 planet.setC_5( 0 ); 0125 planet.setC_6( 0 ); 0126 planet.setPi( 237.2074*DEG2RAD ); 0127 planet.setEpsilon( 3.12*DEG2RAD ); 0128 planet.setTheta_0( 146.0727*DEG2RAD ); 0129 planet.setTheta_1( 870.5366420*DEG2RAD ); 0130 planet.setRadius( 71492000.0 ); 0131 planet.setName(QStringLiteral("Jupiter")); 0132 planet.setHasAtmosphere( true ); 0133 planet.setAtmosphereColor( Oxygen::sunYellow2 ); 0134 } else if (id == QLatin1String("saturn")) { 0135 planet.setM_0( 317.0207*DEG2RAD ); 0136 planet.setM_1( 0.03344414*DEG2RAD ); 0137 planet.setC_1( 6.3585*DEG2RAD ); 0138 planet.setC_2( 0.2204*DEG2RAD ); 0139 planet.setC_3( 0.0106*DEG2RAD ); 0140 planet.setC_4( 0.0006*DEG2RAD ); 0141 planet.setC_5( 0 ); 0142 planet.setC_6( 0 ); 0143 planet.setPi( 99.4571*DEG2RAD ); 0144 planet.setEpsilon( 26.74*DEG2RAD ); 0145 planet.setTheta_0( 174.3479*DEG2RAD ); 0146 planet.setTheta_1( 810.7939024*DEG2RAD ); 0147 planet.setRadius( 60268000.0 ); 0148 planet.setName(QStringLiteral("Saturn")); 0149 planet.setHasAtmosphere( true ); 0150 planet.setAtmosphereColor( Oxygen::sunYellow2 ); 0151 } else if (id == QLatin1String("uranus")) { 0152 planet.setM_0( 141.0498*DEG2RAD ); 0153 planet.setM_1( 0.01172834*DEG2RAD ); 0154 planet.setC_1( 5.3042*DEG2RAD ); 0155 planet.setC_2( 0.1534*DEG2RAD ); 0156 planet.setC_3( 0.0062*DEG2RAD ); 0157 planet.setC_4( 0.0003*DEG2RAD ); 0158 planet.setC_5( 0 ); 0159 planet.setC_6( 0 ); 0160 planet.setPi( 5.4639*DEG2RAD ); 0161 planet.setEpsilon( 82.22*DEG2RAD ); 0162 planet.setTheta_0( 17.9705*DEG2RAD ); 0163 planet.setTheta_1( -501.1600928*DEG2RAD ); 0164 planet.setRadius( 25559000.0 ); 0165 planet.setName(QStringLiteral("Uranus")); 0166 planet.setHasAtmosphere( true ); 0167 planet.setAtmosphereColor( Oxygen::seaBlue4 ); 0168 } else if (id == QLatin1String("neptune")) { 0169 planet.setM_0( 256.2250*DEG2RAD ); 0170 planet.setM_1( 0.00598103*DEG2RAD ); 0171 planet.setC_1( 1.0302*DEG2RAD ); 0172 planet.setC_2( 0.0058*DEG2RAD ); 0173 planet.setC_3( 0 ); 0174 planet.setC_4( 0 ); 0175 planet.setC_5( 0 ); 0176 planet.setC_6( 0 ); 0177 planet.setPi( 182.1957*DEG2RAD ); 0178 planet.setEpsilon( 27.84*DEG2RAD ); 0179 planet.setTheta_0( 52.3996*DEG2RAD ); 0180 planet.setTheta_1( 536.3128492*DEG2RAD ); 0181 planet.setRadius( 24766000.0 ); 0182 planet.setName(QStringLiteral("Neptune")); 0183 planet.setHasAtmosphere( true ); 0184 planet.setAtmosphereColor( Oxygen::skyBlue2 ); 0185 } else if (id == QLatin1String("pluto")) { 0186 // dwarf planets ... (everybody likes pluto) 0187 planet.setM_0( 14.882*DEG2RAD ); 0188 planet.setM_1( 0.00396*DEG2RAD ); 0189 planet.setC_1( 28.3150*DEG2RAD ); 0190 planet.setC_2( 4.3408*DEG2RAD ); 0191 planet.setC_3( 0.9214*DEG2RAD ); 0192 planet.setC_4( 0.2235*DEG2RAD ); 0193 planet.setC_5( 0.0627*DEG2RAD ); 0194 planet.setC_6( 0.0174*DEG2RAD ); 0195 planet.setPi( 4.5433*DEG2RAD ); 0196 planet.setEpsilon( 57.46*DEG2RAD ); 0197 planet.setTheta_0( 56.3183*DEG2RAD ); 0198 planet.setTheta_1( -56.3623195*DEG2RAD ); 0199 planet.setRadius( 1151000.0 ); 0200 planet.setName(QStringLiteral("Pluto")); 0201 planet.setHasAtmosphere( false ); 0202 } else if (id == QLatin1String("sun")) { 0203 qCDebug(DIGIKAM_MARBLE_LOG) << "WARNING: Creating Planet instance" << id << "with invalid orbital elements"; 0204 planet.setRadius( 695000000.0 ); 0205 //FIXME: fill in with valid data 0206 planet.setName(QStringLiteral("Sun")); 0207 planet.setHasAtmosphere( true ); 0208 planet.setAtmosphereColor( Qt::white ); 0209 } else if (id == QLatin1String("moon")) { 0210 qCDebug(DIGIKAM_MARBLE_LOG) << "WARNING: Creating Planet instance" << id << "with invalid orbital elements"; 0211 planet.setRadius( 1738000.0 ); 0212 //FIXME: fill in with valid data 0213 planet.setName(QStringLiteral("Moon")); 0214 planet.setHasAtmosphere( false ); 0215 } else if (id == QLatin1String("sky")) { 0216 qCDebug(DIGIKAM_MARBLE_LOG) << "WARNING: Creating Planet instance" << id << "with invalid orbital elements"; 0217 planet.setRadius( 10000000.0 ); 0218 planet.setName(QStringLiteral("Sky")); 0219 planet.setHasAtmosphere( false ); 0220 } else { 0221 qCDebug(DIGIKAM_MARBLE_LOG) << "WARNING: Creating Planet instance" << id << "with invalid orbital elements"; 0222 planet.setRadius( 10000000.0 ); 0223 planet.setName(QStringLiteral("Unknown")); 0224 planet.setHasAtmosphere( false ); 0225 } 0226 0227 return planet; 0228 } 0229 0230 QString PlanetFactory::localizedName( const QString &id ) 0231 { 0232 if (id == QLatin1String("mercury")) { 0233 return i18nc("the planet", "Mercury"); 0234 } else if (id == QLatin1String("venus")) { 0235 return i18nc("the planet", "Venus"); 0236 } else if (id == QLatin1String("earth")) { 0237 return i18nc("the planet", "Earth"); 0238 } else if (id == QLatin1String("mars")) { 0239 return i18nc("the planet", "Mars"); 0240 } else if (id == QLatin1String("jupiter")) { 0241 return i18nc("the planet", "Jupiter"); 0242 } else if (id == QLatin1String("saturn")) { 0243 return i18nc("the planet", "Saturn"); 0244 } else if (id == QLatin1String("uranus")) { 0245 return i18nc("the planet", "Uranus"); 0246 } else if (id == QLatin1String("neptune")) { 0247 return i18nc("the planet", "Neptune"); 0248 // dwarf planets ... (everybody likes pluto) 0249 } else if (id == QLatin1String("pluto")) { 0250 return i18nc("the planet", "Pluto"); 0251 // sun, moon and sky 0252 } else if (id == QLatin1String("sun")) { 0253 return i18nc("the earth's star", "Sun"); 0254 } else if (id == QLatin1String("moon")) { 0255 return i18nc("the earth's moon", "Moon"); 0256 } else if (id == QLatin1String("sky")) { 0257 return i18n("Sky"); 0258 } else if ( id.isEmpty() ) { 0259 qCDebug(DIGIKAM_MARBLE_LOG) << "Warning: empty id"; 0260 return i18nc("a planet without data", "Unknown Planet"); 0261 } 0262 0263 return id; 0264 } 0265 0266 }