Merge lp:~alexwolf/stellarium/MeteorShowers-patches into lp:~cardinot/stellarium/MeteorShowers

Proposed by Alexander Wolf
Status: Merged
Merged at revision: 6411
Proposed branch: lp:~alexwolf/stellarium/MeteorShowers-patches
Merge into: lp:~cardinot/stellarium/MeteorShowers
Diff against target: 488 lines (+106/-74)
5 files modified
plugins/MeteorShowers/CMakeLists.txt (+1/-1)
plugins/MeteorShowers/resources/showers.json (+58/-58)
plugins/MeteorShowers/src/MeteorShower.cpp (+6/-0)
plugins/MeteorShowers/src/MeteorShowers.cpp (+32/-10)
plugins/MeteorShowers/src/MeteorShowers.hpp (+9/-5)
To merge this branch: bzr merge lp:~alexwolf/stellarium/MeteorShowers-patches
Reviewer Review Type Date Requested Status
Marcos Cardinot Approve
Review via email: mp+199038@code.launchpad.net

Description of the change

Updated plugin version;
Updated formatting of the catalog and its version;
Updated getter for the version of catalog;
Added checker for catalog format;
Restored and updated informational block for radiant's drift;

To post a comment you must log in.
Revision history for this message
Marcos Cardinot (cardinot) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/MeteorShowers/CMakeLists.txt'
2--- plugins/MeteorShowers/CMakeLists.txt 2013-12-14 11:50:16 +0000
3+++ plugins/MeteorShowers/CMakeLists.txt 2013-12-15 06:39:41 +0000
4@@ -1,6 +1,6 @@
5 SET(METEORSHOWERS_MAJOR "0")
6 SET(METEORSHOWERS_MINOR "2")
7-SET(METEORSHOWERS_PATCH "1")
8+SET(METEORSHOWERS_PATCH "2")
9 SET(METEORSHOWERS_VERSION "${METEORSHOWERS_MAJOR}.${METEORSHOWERS_MINOR}.${METEORSHOWERS_PATCH}")
10
11 IF(APPLE)
12
13=== modified file 'plugins/MeteorShowers/resources/showers.json'
14--- plugins/MeteorShowers/resources/showers.json 2013-12-15 01:30:36 +0000
15+++ plugins/MeteorShowers/resources/showers.json 2013-12-15 06:39:41 +0000
16@@ -1,6 +1,6 @@
17 {
18 "shortName": "meteor showers data",
19- "version": "0.2.2",
20+ "version": 1,
21 "showers":
22 {
23 "QUA":
24@@ -39,8 +39,8 @@
25 "speed": 41,
26 "radiantAlpha": "230",
27 "radiantDelta": "49",
28- "driftAlpha": "3",
29- "driftDelta": "-1",
30+ "driftAlpha": "3",
31+ "driftDelta": "-1",
32 "parentObj": "Asteroid 2003 EH1",
33 "pidx": 2.1
34 },
35@@ -73,8 +73,8 @@
36 "speed": 56,
37 "radiantAlpha": "210",
38 "radiantDelta": "-59",
39- "driftAlpha": "6.25",
40- "driftDelta": "-1.5",
41+ "driftAlpha": "6.25",
42+ "driftDelta": "-1.5",
43 "pidx": 2.0
44 },
45 "GNO":
46@@ -105,8 +105,8 @@
47 "speed": 56,
48 "radiantAlpha": "239",
49 "radiantDelta": "-50",
50- "driftAlpha": "5",
51- "driftDelta": "-0.3",
52+ "driftAlpha": "5",
53+ "driftDelta": "-0.3",
54 "pidx": 2.4
55 },
56 "ETA":
57@@ -138,8 +138,8 @@
58 "speed": 66,
59 "radiantAlpha": "338",
60 "radiantDelta": "-1",
61- "driftAlpha": "5",
62- "driftDelta": "2",
63+ "driftAlpha": "5",
64+ "driftDelta": "2",
65 "parentObj": "Comet 1P/Halley",
66 "pidx": 2.4
67 },
68@@ -167,8 +167,8 @@
69 "speed": 35,
70 "radiantAlpha": "341",
71 "radiantDelta": "-30",
72- "driftAlpha": "4",
73- "driftDelta": "1",
74+ "driftAlpha": "4",
75+ "driftDelta": "1",
76 "pidx": 3.2
77 },
78 "LYR":
79@@ -220,7 +220,7 @@
80 "speed": 49,
81 "radiantAlpha": "271",
82 "radiantDelta": "34",
83- "driftAlpha": "3",
84+ "driftAlpha": "3",
85 "driftDelta": "0",
86 "parentObj": "Comet Thatcher (1861 I)",
87 "pidx": 2.1
88@@ -242,8 +242,8 @@
89 "speed": 18,
90 "radiantAlpha": "224",
91 "radiantDelta": "48",
92- "driftAlpha": "2",
93- "driftDelta": "-1",
94+ "driftAlpha": "2",
95+ "driftDelta": "-1",
96 "parentObj": "Comet 7P/Pons-Winnecke",
97 "pidx": 2.2
98 },
99@@ -284,8 +284,8 @@
100 "speed": 41,
101 "radiantAlpha": "339",
102 "radiantDelta": "-16",
103- "driftAlpha": "4",
104- "driftDelta": "0.5",
105+ "driftAlpha": "4",
106+ "driftDelta": "0.5",
107 "parentObj": "Comet 96P/Machholz",
108 "pidx": 3.2
109 },
110@@ -317,8 +317,8 @@
111 "speed": 23,
112 "radiantAlpha": "307",
113 "radiantDelta": "-10",
114- "driftAlpha": "5",
115- "driftDelta": "1",
116+ "driftAlpha": "5",
117+ "driftDelta": "1",
118 "pidx": 2.5
119 },
120 "AUR":
121@@ -341,8 +341,8 @@
122 "speed": 66,
123 "radiantAlpha": "91",
124 "radiantDelta": "+39",
125- "driftAlpha": "5",
126- "driftDelta": "0.7",
127+ "driftAlpha": "5",
128+ "driftDelta": "0.7",
129 "pidx": 2.6
130 },
131 "SPE":
132@@ -361,8 +361,8 @@
133 "speed": 64,
134 "radiantAlpha": "47",
135 "radiantDelta": "+40",
136- "driftAlpha": "5",
137- "driftDelta": "0.1",
138+ "driftAlpha": "5",
139+ "driftDelta": "0.1",
140 "pidx": 3.0
141 },
142 "DRA":
143@@ -500,8 +500,8 @@
144 "speed": 71,
145 "radiantAlpha": "152",
146 "radiantDelta": "+22",
147- "driftAlpha": "3",
148- "driftDelta": "-1.25",
149+ "driftAlpha": "3",
150+ "driftDelta": "-1.25",
151 "parentObj": "Comet 55P/Tempel-Tuttle",
152 "pidx": 2.5
153 },
154@@ -522,8 +522,8 @@
155 "speed": 18,
156 "radiantAlpha": "18",
157 "radiantDelta": "-53",
158- "driftAlpha": "4",
159- "driftDelta": "-0.5",
160+ "driftAlpha": "4",
161+ "driftDelta": "-0.5",
162 "pidx": 2.8
163 },
164 "PUP":
165@@ -542,8 +542,8 @@
166 "speed": 40,
167 "radiantAlpha": "123",
168 "radiantDelta": "-45",
169- "driftAlpha": "3",
170- "driftDelta": "0",
171+ "driftAlpha": "3",
172+ "driftDelta": "0",
173 "pidx": 2.9
174 },
175 "URS":
176@@ -564,7 +564,7 @@
177 "radiantAlpha": "217",
178 "radiantDelta": "+76",
179 "driftAlpha": "0",
180- "driftDelta": "-2",
181+ "driftDelta": "-2",
182 "pidx": 3.0
183 },
184 "PER":
185@@ -615,8 +615,8 @@
186 "speed": 59,
187 "radiantAlpha": "48",
188 "radiantDelta": "+58",
189- "driftAlpha": "6",
190- "driftDelta": "1",
191+ "driftAlpha": "6",
192+ "driftDelta": "1",
193 "parentObj": "Comet 109P/Swift-Tuttle",
194 "pidx": 2.2
195 },
196@@ -658,8 +658,8 @@
197 "speed": 18,
198 "radiantAlpha": "110",
199 "radiantDelta": "-45",
200- "driftAlpha": "2.5",
201- "driftDelta": "-0.5",
202+ "driftAlpha": "2.5",
203+ "driftDelta": "-0.5",
204 "parentObj": "Comet 26P/Grigg-Skjellerup",
205 "pidx": 2.0
206 },
207@@ -680,7 +680,7 @@
208 "speed": 31,
209 "radiantAlpha": "277",
210 "radiantDelta": "+35",
211- "driftAlpha": "4",
212+ "driftAlpha": "4",
213 "driftDelta": "0",
214 "pidx": 3.0
215 },
216@@ -700,8 +700,8 @@
217 "speed": 25,
218 "radiantAlpha": "286",
219 "radiantDelta": "+59",
220- "driftAlpha": "1",
221- "driftDelta": "0.5",
222+ "driftAlpha": "1",
223+ "driftDelta": "0.5",
224 "pidx": 3.0
225 },
226 "ELY":
227@@ -720,8 +720,8 @@
228 "speed": 44,
229 "radiantAlpha": "287",
230 "radiantDelta": "+44",
231- "driftAlpha": "5",
232- "driftDelta": "0.5",
233+ "driftAlpha": "5",
234+ "driftDelta": "0.5",
235 "pidx": 3.0
236 },
237 "DAU":
238@@ -740,8 +740,8 @@
239 "speed": 64,
240 "radiantAlpha": "82",
241 "radiantDelta": "+49",
242- "driftAlpha": "5",
243- "driftDelta": "-2",
244+ "driftAlpha": "5",
245+ "driftDelta": "-2",
246 "pidx": 2.9
247 },
248 "EGE":
249@@ -760,7 +760,7 @@
250 "speed": 70,
251 "radiantAlpha": "102",
252 "radiantDelta": "+27",
253- "driftAlpha": "5",
254+ "driftAlpha": "5",
255 "driftDelta": "0",
256 "pidx": 3.0
257 },
258@@ -780,8 +780,8 @@
259 "speed": 27,
260 "radiantAlpha": "52",
261 "radiantDelta": "+15",
262- "driftAlpha": "3",
263- "driftDelta": "1",
264+ "driftAlpha": "3",
265+ "driftDelta": "1",
266 "pidx": 2.3
267 },
268 "NTA":
269@@ -800,8 +800,8 @@
270 "speed": 29,
271 "radiantAlpha": "58",
272 "radiantDelta": "+22",
273- "driftAlpha": "5",
274- "driftDelta": "1",
275+ "driftAlpha": "5",
276+ "driftDelta": "1",
277 "pidx": 2.3
278 },
279 "MON":
280@@ -820,7 +820,7 @@
281 "speed": 42,
282 "radiantAlpha": "100",
283 "radiantDelta": "+8",
284- "driftAlpha": "4",
285+ "driftAlpha": "4",
286 "driftDelta": "0",
287 "pidx": 3.0
288 },
289@@ -840,8 +840,8 @@
290 "speed": 58,
291 "radiantAlpha": "127",
292 "radiantDelta": "+2",
293- "driftAlpha": "4",
294- "driftDelta": "-1",
295+ "driftAlpha": "4",
296+ "driftDelta": "-1",
297 "pidx": 3.0
298 },
299 "GEM":
300@@ -888,8 +888,8 @@
301 "speed": 35,
302 "radiantAlpha": "112",
303 "radiantDelta": "+33",
304- "driftAlpha": "5",
305- "driftDelta": "-0.1",
306+ "driftAlpha": "5",
307+ "driftDelta": "-0.1",
308 "pidx": 2.6
309 },
310 "LMI":
311@@ -908,8 +908,8 @@
312 "speed": 62,
313 "radiantAlpha": "162",
314 "radiantDelta": "+37",
315- "driftAlpha": "5",
316- "driftDelta": "-2",
317+ "driftAlpha": "5",
318+ "driftDelta": "-2",
319 "pidx": 3.0
320 },
321 "DLM":
322@@ -928,8 +928,8 @@
323 "speed": 64,
324 "radiantAlpha": "161",
325 "radiantDelta": "+30",
326- "driftAlpha": "5",
327- "driftDelta": "-2",
328+ "driftAlpha": "5",
329+ "driftDelta": "-2",
330 "pidx": 3.0
331 },
332 "COM":
333@@ -948,8 +948,8 @@
334 "speed": 65,
335 "radiantAlpha": "175",
336 "radiantDelta": "+18",
337- "driftAlpha": "2.5",
338- "driftDelta": "-1.5",
339+ "driftAlpha": "2.5",
340+ "driftDelta": "-1.5",
341 "pidx": 3.0
342 },
343 "ORI":
344@@ -968,8 +968,8 @@
345 "speed": 66,
346 "radiantAlpha": "95",
347 "radiantDelta": "+16",
348- "driftAlpha": "3",
349- "driftDelta": "0.5",
350+ "driftAlpha": "3",
351+ "driftDelta": "0.5",
352 "pidx": 2.5
353 }
354 }
355
356=== modified file 'plugins/MeteorShowers/src/MeteorShower.cpp'
357--- plugins/MeteorShowers/src/MeteorShower.cpp 2013-12-15 00:04:48 +0000
358+++ plugins/MeteorShowers/src/MeteorShower.cpp 2013-12-15 06:39:41 +0000
359@@ -298,6 +298,12 @@
360
361 if(flags&Extra)
362 {
363+ oss << QString("%1: %2/%3")
364+ .arg(q_("Radiant drift (per day)"))
365+ .arg(StelUtils::radToHmsStr(driftAlpha/5))
366+ .arg(StelUtils::radToDmsStr(driftDelta/5));
367+ oss << "<br />";
368+
369 oss << q_("Geocentric meteoric velocity: %1 km/s").arg(speed) << "<br />";
370 if(pidx>0)
371 {
372
373=== modified file 'plugins/MeteorShowers/src/MeteorShowers.cpp'
374--- plugins/MeteorShowers/src/MeteorShowers.cpp 2013-12-14 20:37:18 +0000
375+++ plugins/MeteorShowers/src/MeteorShowers.cpp 2013-12-15 06:39:41 +0000
376@@ -56,6 +56,8 @@
377 #include <QStringList>
378 #include <QDir>
379
380+#define CATALOG_FORMAT_VERSION 1 /* Version of format of catalog */
381+
382 /*
383 This method is the one called automatically by the StelModuleMgr just
384 after loading the dynamic library
385@@ -174,7 +176,7 @@
386 // If the json file does not already exist, create it from the resource in the QT resource
387 if(!QFileInfo(showersJsonPath).exists())
388 {
389- if(getJsonFileVersion() != METEORSHOWERS_PLUGIN_VERSION)
390+ if(!checkJsonFileFormat() || getJsonFileFormatVersion()<CATALOG_FORMAT_VERSION)
391 {
392 displayMessage(q_("The old showers.json file is no longer compatible - using default file"), "#bb0000");
393 restoreDefaultJsonFile();
394@@ -821,9 +823,9 @@
395 return true;
396 }
397
398-const QString MeteorShowers::getJsonFileVersion(void)
399+int MeteorShowers::getJsonFileFormatVersion(void)
400 {
401- QString jsonVersion("unknown");
402+ int jsonVersion = -1;
403 QFile showersJsonFile(showersJsonPath);
404 if(!showersJsonFile.open(QIODevice::ReadOnly))
405 {
406@@ -835,19 +837,39 @@
407 map = StelJsonParser::parse(&showersJsonFile).toMap();
408 if(map.contains("version"))
409 {
410- QString version = map.value("version").toString();
411- QRegExp vRx(".*(\\d+\\.\\d+\\.\\d+).*");
412- if(vRx.exactMatch(version))
413- {
414- jsonVersion = vRx.capturedTexts().at(1);
415- }
416+ jsonVersion = map.value("version").toInt();
417 }
418
419 showersJsonFile.close();
420- qDebug() << "MeteorShowers::getJsonFileVersion() version from file:" << jsonVersion;
421+ qDebug() << "MeteorShowers::getJsonFileFormatVersion() version from file:" << jsonVersion;
422 return jsonVersion;
423 }
424
425+bool MeteorShowers::checkJsonFileFormat()
426+{
427+ QFile showersJsonFile(showersJsonPath);
428+ if(!showersJsonFile.open(QIODevice::ReadOnly))
429+ {
430+ qWarning() << "MeteorShowers::init cannot open " << QDir::toNativeSeparators(showersJsonPath);
431+ return false;
432+ }
433+
434+ QVariantMap map;
435+ try
436+ {
437+ map = StelJsonParser::parse(&showersJsonFile).toMap();
438+ showersJsonFile.close();
439+ }
440+ catch(std::runtime_error& e)
441+ {
442+ qDebug() << "MeteorShowers::checkJsonFileFormat(): file format is wrong!";
443+ qDebug() << "MeteorShowers::checkJsonFileFormat() error:" << e.what();
444+ return false;
445+ }
446+
447+ return true;
448+}
449+
450 void MeteorShowers::readSettingsFromConfig(void)
451 {
452 conf->beginGroup("MeteorShowers");
453
454=== modified file 'plugins/MeteorShowers/src/MeteorShowers.hpp'
455--- plugins/MeteorShowers/src/MeteorShowers.hpp 2013-12-14 20:37:18 +0000
456+++ plugins/MeteorShowers/src/MeteorShowers.hpp 2013-12-15 06:39:41 +0000
457@@ -114,7 +114,7 @@
458
459 //! Set up the plugin with default values. This means clearing out the MeteorShower section in the
460 //! main config.ini (if one already exists), and populating it with default values. It also
461- //! creates the default meteors.json file from the resource embedded in the plugin lib/dll file.
462+ //! creates the default showers.json file from the resource embedded in the plugin lib/dll file.
463 void restoreDefaults(void);
464
465 //! Read (or re-read) settings from the main config file. This will be called from init and also
466@@ -224,14 +224,18 @@
467 //! read the json file and create the meteor Showers.
468 void readJsonFile(void);
469
470- //! Creates a backup of the showers.json file called meteors.json.old
471+ //! Creates a backup of the showers.json file called showers.json.old
472 //! @param deleteOriginal if true, the original file is removed, else not
473 //! @return true on OK, false on failure
474 bool backupJsonFile(bool deleteOriginal=false);
475
476- //! Get the version from the "version" value in the meteors.json file
477- //! @return version string, e.g. "0.1.0"
478- const QString getJsonFileVersion(void);
479+ //! Get the version from the "version of format" value in the showers.json file
480+ //! @return version, e.g. "1"
481+ int getJsonFileFormatVersion(void);
482+
483+ //! Check format of the catalog of meteor showers
484+ //! @return valid boolean, e.g. "true"
485+ bool checkJsonFileFormat(void);
486
487 //! Parse JSON file and load showers to map
488 QVariantMap loadShowersMap(QString path=QString());

Subscribers

People subscribed via source and target branches