Merge lp:~georg-zotti/stellarium/gz_fix-ObjectInfoMap into lp:stellarium

Proposed by gzotti
Status: Merged
Merged at revision: 9161
Proposed branch: lp:~georg-zotti/stellarium/gz_fix-ObjectInfoMap
Merge into: lp:stellarium
Diff against target: 1262 lines (+615/-216)
27 files modified
cmake/stellarium.rc.cmake (+1/-1)
plugins/Exoplanets/src/Exoplanet.cpp (+20/-1)
plugins/Exoplanets/src/Exoplanet.hpp (+10/-1)
plugins/MeteorShowers/src/MeteorShower.cpp (+56/-1)
plugins/MeteorShowers/src/MeteorShower.hpp (+11/-1)
plugins/Novae/src/Nova.cpp (+21/-1)
plugins/Novae/src/Nova.hpp (+17/-7)
plugins/Pulsars/src/Pulsar.cpp (+23/-1)
plugins/Pulsars/src/Pulsar.hpp (+23/-3)
plugins/Quasars/src/Quasar.cpp (+12/-1)
plugins/Quasars/src/Quasar.hpp (+15/-3)
plugins/RemoteControl/src/ObjectService.cpp (+1/-2)
plugins/Satellites/src/Satellite.cpp (+84/-0)
plugins/Satellites/src/Satellite.hpp (+22/-1)
plugins/Supernovae/src/Supernova.cpp (+15/-1)
plugins/Supernovae/src/Supernova.hpp (+17/-3)
src/core/StelObject.cpp (+101/-0)
src/core/StelObject.hpp (+30/-0)
src/core/StelObjectMgr.cpp (+16/-0)
src/core/StelObjectMgr.hpp (+5/-0)
src/core/modules/Atmosphere.cpp (+1/-1)
src/core/modules/Comet.cpp (+8/-0)
src/core/modules/Comet.hpp (+6/-0)
src/core/modules/Planet.cpp (+27/-0)
src/core/modules/Planet.hpp (+19/-7)
src/scripting/StelMainScriptAPI.cpp (+36/-135)
src/scripting/StelMainScriptAPI.hpp (+18/-45)
To merge this branch: bzr merge lp:~georg-zotti/stellarium/gz_fix-ObjectInfoMap
Reviewer Review Type Date Requested Status
Alexander Wolf Approve
gzotti Needs Resubmitting
Review via email: mp+319316@code.launchpad.net

Description of the change

Allow extended per-type object info maps, most useful for scripting.

To post a comment you must log in.
Revision history for this message
Alexander Wolf (alexwolf) wrote :

Please make names of keys are more consistent - for example:
------------
map.insert("range_km", range);
map.insert("RangeRate_km/s", rangeRate);
------------
Plus keys, like "speed_km/s" is very strange.

Compare it to original format of key: azimuth-geometric.

The list of possible keys is necessary also in description of methods (the doxygen format).

I see inconsistency in filing of types - please compare:
-------------
map.insert("type", q_("meteor shower"));
-------------
and
-------------
map.insert("type", "artificial satellite");
-------------

And obvious that all translatable values should be given to users in two format - English and localized (see keys "name" and "localized-name" in original code).

review: Needs Fixing
9164. By gzotti

Added more doxygen, changed a few key names.

Revision history for this message
gzotti (georg-zotti) wrote :

Key name format is rather arbitrary as long as there is no reference documentation/guideline. I removed "km/s" types, which makes the tags harder to understand without docs IMHO.

Is it possible to dump such a map completely to script output, so that keys can be found more easily? (This should be added to the scripting API docs!)

name and localized-name are the only entries where un-/+translated makes sense. The map is mostly useful for scripting extensions.

I have added a basic implementation of the added tags into your various object catalog plugins.
I don't know exact details of object types for some plugins. Please add them. Some entries may have to be harmonized (RA/ra, ...) or even removed (position is already there)?

Revision history for this message
Alexander Wolf (alexwolf) wrote :

Please read the comments in the code.

review: Needs Fixing
9165. By gzotti

Removed duplicate fields in AW's plugin object infomaps. Removed translations in InfoMap values. Remove Exoplanet detail lists in InfoMap.

Revision history for this message
gzotti (georg-zotti) wrote :

Done. More details can (and should) be adjusted anytime after merge when the principal function is seen OK.

review: Needs Resubmitting
Revision history for this message
Alexander Wolf (alexwolf) :
Revision history for this message
Alexander Wolf (alexwolf) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmake/stellarium.rc.cmake'
2--- cmake/stellarium.rc.cmake 2016-05-31 16:54:06 +0000
3+++ cmake/stellarium.rc.cmake 2017-03-09 14:02:12 +0000
4@@ -11,7 +11,7 @@
5 BLOCK "040904B0" // Lang=English (United States, 0x0409, decimal 1033), CharSet=Unicode (0x04B0, decimal 1200).
6 BEGIN
7 VALUE "CompanyName", "Stellarium team\0"
8- VALUE "FileDescription", "Stellarium is a free open source planetarium\0"
9+ VALUE "FileDescription", "Stellarium, the free open source planetarium\0"
10 VALUE "FileVersion", "@PACKAGE_VERSION@\0"
11 VALUE "LegalCopyright", "Copyright (C) @COPYRIGHT_YEARS@ Stellarium team\0"
12 VALUE "Info", "http://www.stellarium.org/\0"
13
14=== modified file 'plugins/Exoplanets/src/Exoplanet.cpp'
15--- plugins/Exoplanets/src/Exoplanet.cpp 2016-11-28 16:01:23 +0000
16+++ plugins/Exoplanets/src/Exoplanet.cpp 2017-03-09 14:02:12 +0000
17@@ -166,7 +166,7 @@
18 //
19 }
20
21-QVariantMap Exoplanet::getMap(void)
22+QVariantMap Exoplanet::getMap(void) const
23 {
24 QVariantMap map;
25 map["designation"] = designation;
26@@ -467,6 +467,25 @@
27 return str;
28 }
29
30+QVariantMap Exoplanet::getInfoMap(const StelCore *core) const
31+{
32+ QVariantMap map = StelObject::getInfoMap(core);
33+
34+ // Tentatively add a few more strings. Details are left to the plugin author.
35+ if (!starProperName.isEmpty()) map["starProperName"] = starProperName;
36+ map["distance"] = distance;
37+ map["stype"] = stype;
38+ map["smass"] = smass;
39+ map["smetal"] = smetal;
40+ // map["Vmag"] = Vmag; // maybe same as getVmagnitude?
41+ map["sradius"] = sradius;
42+ map["effectiveTemp"] = effectiveTemp;
43+ map["hasHabitablePlanets"] = hasHabitableExoplanets;
44+ map["type"] = "ExoplanetSystem"; // Replace default but confusing "Exoplanet" from class name.
45+ // TODO: Maybe add number of habitables? Add details?
46+ return map;
47+}
48+
49 QString Exoplanet::getPlanetaryClassI18n(QString ptype) const
50 {
51 QString result = "";
52
53=== modified file 'plugins/Exoplanets/src/Exoplanet.hpp'
54--- plugins/Exoplanets/src/Exoplanet.hpp 2016-10-03 16:08:03 +0000
55+++ plugins/Exoplanets/src/Exoplanet.hpp 2017-03-09 14:02:12 +0000
56@@ -66,7 +66,7 @@
57
58 //! Get a QVariantMap which describes the exoplanet. Could be used to
59 //! create a duplicate.
60- QVariantMap getMap(void);
61+ QVariantMap getMap(void) const;
62
63 //! Get the type of object
64 virtual QString getType(void) const
65@@ -80,6 +80,15 @@
66 //! @param core A pointer to the core
67 //! @flags a set of flags with information types to include.
68 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;
69+ //! Return a map like StelObject, but with a few extra tags also available in getMap().
70+ //! - distance = distance in pc
71+ //! - stype = Spectral type of star
72+ //! - smass = Mass of star in Msun
73+ //! - smetal = [Fe/H] of star
74+ //! - sradius = Radius of star in Rsun
75+ //! - effectiveTemp = Effective temperature of star in K
76+ //! - hasHabitablePlanets (true/false)
77+ virtual QVariantMap getInfoMap(const StelCore *core) const;
78 virtual Vec3f getInfoColor(void) const;
79 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const
80 {
81
82=== modified file 'plugins/MeteorShowers/src/MeteorShower.cpp'
83--- plugins/MeteorShowers/src/MeteorShower.cpp 2017-01-08 16:39:11 +0000
84+++ plugins/MeteorShowers/src/MeteorShower.cpp 2017-03-09 14:02:12 +0000
85@@ -476,7 +476,7 @@
86 return qRound(gaussian);
87 }
88
89-QString MeteorShower::getSolarLongitude(QDate date) const
90+QString MeteorShower::getSolarLongitude(QDate date)
91 {
92 //The number of days (positive or negative) since Greenwich noon,
93 //Terrestrial Time, on 1 January 2000 (J2000.0)
94@@ -632,3 +632,58 @@
95
96 return str;
97 }
98+
99+QVariantMap MeteorShower::getInfoMap(const StelCore *core) const
100+{
101+ QVariantMap map = StelObject::getInfoMap(core);
102+
103+ if (enabled())
104+ {
105+ QString mstdata;
106+ if (m_status == ACTIVE_GENERIC)
107+ {
108+ mstdata = "generic-data";
109+ }
110+ else if (m_status == ACTIVE_CONFIRMED)
111+ {
112+ mstdata = "confirmed-data";
113+ }
114+ else if (m_status == INACTIVE)
115+ {
116+ mstdata = "inactive";
117+ }
118+ map.insert("status", mstdata);
119+
120+ if (!m_showerID.toInt())
121+ {
122+ map.insert("id", m_showerID);
123+ }
124+ else
125+ {
126+ map.insert("id", "?");
127+ }
128+
129+ map.insert("velocity", m_speed);
130+ map.insert("population-index", m_pidx);
131+ map.insert("parent", m_parentObj);
132+
133+ if(m_activity.zhr > 0)
134+ {
135+ map.insert("zhr-max", m_activity.zhr);
136+ }
137+ else
138+ {
139+ QString varStr="variable";
140+ if(m_activity.variable.size() == 2)
141+ {
142+ varStr=QString("%1; %2-%3")
143+ .arg("variable")
144+ .arg(m_activity.variable.at(0))
145+ .arg(m_activity.variable.at(1));
146+ }
147+ map.insert("zhr-max", varStr);
148+ }
149+ }
150+
151+ return map;
152+}
153
154=== modified file 'plugins/MeteorShowers/src/MeteorShower.hpp'
155--- plugins/MeteorShowers/src/MeteorShower.hpp 2015-08-29 02:37:17 +0000
156+++ plugins/MeteorShowers/src/MeteorShower.hpp 2017-03-09 14:02:12 +0000
157@@ -105,6 +105,16 @@
158 // Methods defined in StelObject class
159 //
160 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;
161+ //! Return a map like StelObject, but with a few extra tags:
162+ // TODO: Describe the fields!
163+ //! - status
164+ //! - id
165+ //! - type (translated string "meteor shower")
166+ //! - speed (km/s)
167+ //! - pop-idx (population index)
168+ //! - parent
169+ //! - zhr-max (information string)
170+ virtual QVariantMap getInfoMap(const StelCore *core) const;
171 virtual QString getType(void) const { return "MeteorShower"; }
172 virtual QString getEnglishName(void) const { return m_designation.trimmed(); }
173 virtual QString getNameI18n(void) const { return q_(m_designation.trimmed()); }
174@@ -151,7 +161,7 @@
175 //! Gets the solar longitude for a specified date
176 //! @param date QDate
177 //! @return solar longitude in degree
178- QString getSolarLongitude(QDate date) const;
179+ static QString getSolarLongitude(QDate date);
180 };
181
182 #endif /*_METEORSHOWER_HPP_*/
183
184=== modified file 'plugins/Novae/src/Nova.cpp'
185--- plugins/Novae/src/Nova.cpp 2016-07-30 18:20:22 +0000
186+++ plugins/Novae/src/Nova.cpp 2017-03-09 14:02:12 +0000
187@@ -80,7 +80,7 @@
188 //
189 }
190
191-QVariantMap Nova::getMap(void)
192+QVariantMap Nova::getMap(void) const
193 {
194 QVariantMap map;
195 map["designation"] = designation;
196@@ -161,6 +161,26 @@
197 return str;
198 }
199
200+
201+QVariantMap Nova::getInfoMap(const StelCore *core) const
202+{
203+ QVariantMap map = StelObject::getInfoMap(core);
204+
205+ map["designation"] = designation;
206+ map["name"] = novaName;
207+ map["nova-type"] = novaType;
208+ map["max-magnitude"] = maxMagnitude;
209+ map["min-magnitude"] = minMagnitude;
210+ map["peakJD"] = peakJD;
211+ map["m2"] = m2;
212+ map["m3"] = m3;
213+ map["m6"] = m6;
214+ map["m9"] = m9;
215+ map["distance"] = distance;
216+
217+ return map;
218+}
219+
220 Vec3f Nova::getInfoColor(void) const
221 {
222 return Vec3f(1.0, 1.0, 1.0);
223
224=== modified file 'plugins/Novae/src/Nova.hpp'
225--- plugins/Novae/src/Nova.hpp 2015-12-22 15:15:35 +0000
226+++ plugins/Novae/src/Nova.hpp 2017-03-09 14:02:12 +0000
227@@ -46,19 +46,29 @@
228 Nova(const QVariantMap& map);
229 ~Nova();
230
231- //! Get a QVariantMap which describes the nova. Could be used to
232- //! create a duplicate.
233- QVariantMap getMap(void);
234+ //! Get a QVariantMap which describes the nova. Could be used to create a duplicate.
235+ QVariantMap getMap(void) const;
236
237- virtual QString getType(void) const
238- {
239- return "Nova";
240- }
241+ virtual QString getType(void) const {return "Nova";}
242
243 //! Get an HTML string to describe the object
244 //! @param core A pointer to the core
245 //! @flags a set of flags with information types to include.
246 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;
247+ //! Return a map like StelObject::getInfoMap(), but with a few extra tags also available in getMap().
248+ // TODO: Describe the entries!
249+ //! - designation
250+ //! - name
251+ //! - nova-type
252+ //! - max-magnitude
253+ //! - min-magnitude
254+ //! - peakJD
255+ //! - m2
256+ //! - m3
257+ //! - m6
258+ //! - m9
259+ //! - distance
260+ virtual QVariantMap getInfoMap(const StelCore *core) const;
261 virtual Vec3f getInfoColor(void) const;
262 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const
263 {
264
265=== modified file 'plugins/Pulsars/src/Pulsar.cpp'
266--- plugins/Pulsars/src/Pulsar.cpp 2016-11-28 14:24:21 +0000
267+++ plugins/Pulsars/src/Pulsar.cpp 2017-03-09 14:02:12 +0000
268@@ -111,7 +111,7 @@
269 //
270 }
271
272-QVariantMap Pulsar::getMap(void)
273+QVariantMap Pulsar::getMap(void) const
274 {
275 QVariantMap map;
276 map["designation"] = designation;
277@@ -268,6 +268,28 @@
278 return str;
279 }
280
281+QVariantMap Pulsar::getInfoMap(const StelCore *core) const
282+{
283+ QVariantMap map = StelObject::getInfoMap(core);
284+
285+ map["parallax"] = parallax;
286+ map["bperiod"] = bperiod;
287+ map["frequency"] = frequency;
288+ map["pfrequency"] = pfrequency;
289+ map["pderivative"] = pderivative;
290+ map["dmeasure"] = dmeasure;
291+ map["eccentricity"] = eccentricity;
292+ map["period"] = period;
293+ map["w50"] = w50;
294+ map["s400"] = s400;
295+ map["s600"] = s600;
296+ map["s1400"] = s1400;
297+ map["distance"] = distance;
298+ map["glitch"] = glitch;
299+ map["notes"] = notes;
300+ return map;
301+}
302+
303 Vec3f Pulsar::getInfoColor(void) const
304 {
305 return Vec3f(1.0, 1.0, 1.0);
306
307=== modified file 'plugins/Pulsars/src/Pulsar.hpp'
308--- plugins/Pulsars/src/Pulsar.hpp 2015-05-30 19:56:47 +0000
309+++ plugins/Pulsars/src/Pulsar.hpp 2017-03-09 14:02:12 +0000
310@@ -46,9 +46,27 @@
311 Pulsar(const QVariantMap& map);
312 ~Pulsar();
313
314- //! Get a QVariantMap which describes the pulsar. Could be used to
315- //! create a duplicate.
316- QVariantMap getMap(void);
317+ //! Get a QVariantMap which describes the pulsar. Could be used to create a duplicate.
318+ // TODO: Add proper documentation of these fields!
319+ //! - designation
320+ //! - parallax
321+ //! - bperiod
322+ //! - frequency
323+ //! - pfrequency
324+ //! - pderivative
325+ //! - dmeasure
326+ //! - eccentricity
327+ //! - RA
328+ //! - DE
329+ //! - period
330+ //! - w50
331+ //! - s400
332+ //! - s600
333+ //! - s1400
334+ //! - distance
335+ //! - glitch
336+ //! - notes
337+ QVariantMap getMap(void) const;
338
339 //! Get the type of object
340 virtual QString getType(void) const
341@@ -62,6 +80,8 @@
342 //! @param core A pointer to the core
343 //! @flags a set of flags with information types to include.
344 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;
345+ //! Return a map like StelObject::getInfoMap(), but with a few extra tags also available in getMap(), except for designation, RA and DE fields.
346+ virtual QVariantMap getInfoMap(const StelCore *core) const;
347 virtual Vec3f getInfoColor(void) const;
348 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const
349 {
350
351=== modified file 'plugins/Quasars/src/Quasar.cpp'
352--- plugins/Quasars/src/Quasar.cpp 2016-11-28 14:24:21 +0000
353+++ plugins/Quasars/src/Quasar.cpp 2017-03-09 14:02:12 +0000
354@@ -73,7 +73,7 @@
355 //
356 }
357
358-QVariantMap Quasar::getMap(void)
359+QVariantMap Quasar::getMap(void) const
360 {
361 QVariantMap map;
362 map["designation"] = designation;
363@@ -137,6 +137,17 @@
364 return str;
365 }
366
367+QVariantMap Quasar::getInfoMap(const StelCore *core) const
368+{
369+ QVariantMap map = StelObject::getInfoMap(core);
370+
371+ map["amag"] = AMagnitude;
372+ map["bV"] = bV;
373+ map["redshift"] = redshift;
374+
375+ return map;
376+}
377+
378 Vec3f Quasar::getInfoColor(void) const
379 {
380 return Vec3f(1.0, 1.0, 1.0);
381
382=== modified file 'plugins/Quasars/src/Quasar.hpp'
383--- plugins/Quasars/src/Quasar.hpp 2016-07-30 18:20:22 +0000
384+++ plugins/Quasars/src/Quasar.hpp 2017-03-09 14:02:12 +0000
385@@ -46,9 +46,15 @@
386 Quasar(const QVariantMap& map);
387 ~Quasar();
388
389- //! Get a QVariantMap which describes the Quasar. Could be used to
390- //! create a duplicate.
391- QVariantMap getMap(void);
392+ //! Get a QVariantMap which describes the Quasar. Could be used to create a duplicate.
393+ //! - designation
394+ //! - Vmag
395+ //! - Amag
396+ //! - bV
397+ //! - RA
398+ //! - DE
399+ //! - z
400+ QVariantMap getMap(void) const;
401
402 virtual QString getType(void) const
403 {
404@@ -61,6 +67,12 @@
405 //! @param core A pointer to the core
406 //! @flags a set of flags with information types to include.
407 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;
408+ //! Return a map like StelObject::getInfoMap(), but with a few extra tags also available in getMap().
409+ // TODO: Describe the fields.
410+ //! - amag
411+ //! - bV
412+ //! - redshift
413+ virtual QVariantMap getInfoMap(const StelCore *core) const;
414 virtual Vec3f getInfoColor(void) const;
415 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const
416 {
417
418=== modified file 'plugins/RemoteControl/src/ObjectService.cpp'
419--- plugins/RemoteControl/src/ObjectService.cpp 2017-02-04 14:15:20 +0000
420+++ plugins/RemoteControl/src/ObjectService.cpp 2017-03-09 14:02:12 +0000
421@@ -25,7 +25,6 @@
422 #include "StelObjectMgr.hpp"
423 #include "StelTranslator.hpp"
424 #include "StelModuleMgr.hpp"
425-#include "StelMainScriptAPI.hpp"
426 #include "StelObjectMgr.hpp"
427 #include "LandscapeMgr.hpp"
428
429@@ -163,7 +162,7 @@
430 QJsonObject infoObj;
431 StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);
432 StelObjectP obj = omgr->searchByName(name);
433- QVariantMap infoMap=StelMainScriptAPI::getObjectInfo(obj);
434+ QVariantMap infoMap=StelObjectMgr::getObjectInfo(obj);
435 QVariantMap::const_iterator i;
436 for (i=infoMap.constBegin(); i!=infoMap.constEnd(); ++i)
437 infoObj.insert(i.key(), i.value().toString());
438
439=== modified file 'plugins/Satellites/src/Satellite.cpp'
440--- plugins/Satellites/src/Satellite.cpp 2017-01-08 16:39:11 +0000
441+++ plugins/Satellites/src/Satellite.cpp 2017-03-09 14:02:12 +0000
442@@ -395,6 +395,90 @@
443 return str;
444 }
445
446+QVariantMap Satellite::getInfoMap(const StelCore *core) const
447+{
448+ QVariantMap map = StelObject::getInfoMap(core);
449+
450+ map.insert("description", QString(description).replace("\n", " - "));
451+ map.insert("catalog", id);
452+ if (!internationalDesignator.isEmpty())
453+ map.insert("international-designator", internationalDesignator);
454+
455+ if (stdMag==99.f) // replace whatever has been computed
456+ {
457+ map.insert("vmag", "?");
458+ map.insert("vmage", "?");
459+ }
460+
461+ map.insert("range", range);
462+ map.insert("rangerate", rangeRate);
463+ map.insert("height", height);
464+ map.insert("subpoint-lat", latLongSubPointPosition[0]);
465+ map.insert("subpoint-long", latLongSubPointPosition[1]);
466+ map.insert("TEME-km-X", position[0]);
467+ map.insert("TEME-km-Y", position[1]);
468+ map.insert("TEME-km-Z", position[2]);
469+ map.insert("TEME-speed-X", velocity[0]);
470+ map.insert("TEME-speed-Y", velocity[1]);
471+ map.insert("TEME-speed-Z", velocity[2]);
472+ if (sunReflAngle>0)
473+ { // Iridium
474+ map.insert("sun-reflection-angle", sunReflAngle);
475+ }
476+ map.insert("operational-status", getOperationalStatus());
477+
478+ //TODO: Move to a more prominent place.
479+ QString visibilityState;
480+ switch (visibility)
481+ {
482+ case RADAR_SUN:
483+ visibilityState = "The satellite and the observer are in sunlight.";
484+ break;
485+ case VISIBLE:
486+ visibilityState = "The satellite is visible.";
487+ break;
488+ case RADAR_NIGHT:
489+ visibilityState = "The satellite is eclipsed.";
490+ break;
491+ case NOT_VISIBLE:
492+ visibilityState = "The satellite is not visible";
493+ break;
494+ default:
495+ break;
496+ }
497+ map.insert("visibility", visibilityState);
498+ if (comms.size() > 0)
499+ {
500+ foreach(const CommLink &c, comms)
501+ {
502+ double dop = getDoppler(c.frequency);
503+ double ddop = dop;
504+ char sign;
505+ if (dop<0.)
506+ {
507+ sign='-';
508+ ddop*=-1;
509+ }
510+ else
511+ sign='+';
512+
513+ QString commModDesc;
514+ if (!c.modulation.isEmpty() && c.modulation != "") commModDesc=c.modulation;
515+ if ((!c.modulation.isEmpty() && c.modulation != "") || (!c.description.isEmpty() && c.description != "")) commModDesc.append(" ");
516+ if (!c.description.isEmpty() && c.description != "") commModDesc.append(c.description);
517+ if ((!c.modulation.isEmpty() && c.modulation != "") || (!c.description.isEmpty() && c.description != "")) commModDesc.append(": ");
518+ map.insertMulti("comm", QString("%1%2 MHz (%3%4 kHz)")
519+ .arg(commModDesc)
520+ .arg(c.frequency, 8, 'f', 5)
521+ .arg(sign)
522+ .arg(ddop, 6, 'f', 3));
523+ }
524+ }
525+
526+ return map;
527+}
528+
529+
530 Vec3d Satellite::getJ2000EquatorialPos(const StelCore* core) const
531 {
532 // Bugfix LP:1654331. I assume the elAzPosition has been computed without refraction! We must say this definitely.
533
534=== modified file 'plugins/Satellites/src/Satellite.hpp'
535--- plugins/Satellites/src/Satellite.hpp 2016-11-21 20:20:20 +0000
536+++ plugins/Satellites/src/Satellite.hpp 2017-03-09 14:02:12 +0000
537@@ -131,8 +131,29 @@
538 //! Supported types for Satellite objects:
539 //! - Name: designation in large type with the description underneath
540 //! - RaDecJ2000, RaDecOfDate, HourAngle, AltAzi
541- //! - Extra: range, rage rate and altitude of satellite above the Earth, comms frequencies, modulation types and so on.
542+ //! - Extra: range, range rate and altitude of satellite above the Earth, comms frequencies, modulation types and so on.
543 virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;
544+ //! Return a map like StelObject::getInfoMap(), but with a few extra tags also available in getInfoString().
545+ //! - description
546+ //! - catalog
547+ //! - international-designator
548+ //! - type
549+ //! - range (distance in km)
550+ //! - rangerate (distance change in km/s)
551+ //! - height (height in km)
552+ //! - subpoint-lat (latitude of subpoint, decimal degrees)
553+ //! - subpoint-long (longitude of subpoint, decimal degrees)
554+ //! - TEME-km-X
555+ //! - TEME-km-Y
556+ //! - TEME-km-Z
557+ //! - TEME-speed-X
558+ //! - TEME-speed-Y
559+ //! - TEME-speed-Z
560+ //! - sun-reflection-angle (if available)
561+ //! - operational-status
562+ //! - visibility (descriptive string)
563+ //! - comm (Radio information, optional, if available. There may be several comm entries!)
564+ virtual QVariantMap getInfoMap(const StelCore *core) const;
565 virtual Vec3f getInfoColor(void) const;
566 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const;
567 virtual float getVMagnitude(const StelCore* core) const;
568
569=== modified file 'plugins/Supernovae/src/Supernova.cpp'
570--- plugins/Supernovae/src/Supernova.cpp 2016-12-10 15:11:36 +0000
571+++ plugins/Supernovae/src/Supernova.cpp 2017-03-09 14:02:12 +0000
572@@ -71,7 +71,7 @@
573 //
574 }
575
576-QVariantMap Supernova::getMap(void)
577+QVariantMap Supernova::getMap(void) const
578 {
579 QVariantMap map;
580 map["designation"] = designation;
581@@ -155,6 +155,20 @@
582 return str;
583 }
584
585+
586+QVariantMap Supernova::getInfoMap(const StelCore *core) const
587+{
588+ QVariantMap map = StelObject::getInfoMap(core);
589+
590+ map["sntype"] = sntype;
591+ map["max-magnitude"] = maxMagnitude;
592+ map["peakJD"] = peakJD;
593+ map["note"] = note;
594+ map["distance"] = distance;
595+
596+ return map;
597+}
598+
599 Vec3f Supernova::getInfoColor(void) const
600 {
601 return Vec3f(1.0, 1.0, 1.0);
602
603=== modified file 'plugins/Supernovae/src/Supernova.hpp'
604--- plugins/Supernovae/src/Supernova.hpp 2015-05-30 19:56:47 +0000
605+++ plugins/Supernovae/src/Supernova.hpp 2017-03-09 14:02:12 +0000
606@@ -46,9 +46,16 @@
607 Supernova(const QVariantMap& map);
608 ~Supernova();
609
610- //! Get a QVariantMap which describes the supernova. Could be used to
611- //! create a duplicate.
612- QVariantMap getMap(void);
613+ //! Get a QVariantMap which describes the supernova. Could be used to create a duplicate.
614+ //! - designation
615+ //! - sntype
616+ //! - maxMagnitude
617+ //! - peakJD
618+ //! - snra
619+ //! - snde
620+ //! - note
621+ //! - distance
622+ QVariantMap getMap(void) const;
623
624 virtual QString getType(void) const
625 {
626@@ -59,6 +66,13 @@
627 //! @param core A pointer to the core
628 //! @flags a set of flags with information types to include.
629 virtual QString getInfoString(const StelCore* core, const InfoStringGroup& flags) const;
630+ //! Return a map like StelObject::getInfoMap(), but with a few extra tags also available in getMap().
631+ //! - sntype
632+ //! - max-magnitude
633+ //! - peakJD
634+ //! - note
635+ //! - distance
636+ virtual QVariantMap getInfoMap(const StelCore *core) const;
637 virtual Vec3f getInfoColor(void) const;
638 virtual Vec3d getJ2000EquatorialPos(const StelCore*) const
639 {
640
641=== modified file 'src/core/StelObject.cpp'
642--- src/core/StelObject.cpp 2016-12-29 15:37:01 +0000
643+++ src/core/StelObject.cpp 2017-03-09 14:02:12 +0000
644@@ -318,3 +318,104 @@
645 }
646 }
647
648+QVariantMap StelObject::getInfoMap(const StelCore *core) const
649+{
650+ QVariantMap map;
651+
652+ Vec3d pos;
653+ double ra, dec, alt, az, glong, glat;
654+ bool useOldAzimuth = StelApp::getInstance().getFlagSouthAzimuthUsage();
655+
656+ map.insert("type", getType());
657+ // ra/dec
658+ pos = getEquinoxEquatorialPos(core);
659+ StelUtils::rectToSphe(&ra, &dec, pos);
660+ map.insert("ra", ra*180./M_PI);
661+ map.insert("dec", dec*180./M_PI);
662+
663+ // ra/dec in J2000
664+ pos = getJ2000EquatorialPos(core);
665+ StelUtils::rectToSphe(&ra, &dec, pos);
666+ map.insert("raJ2000", ra*180./M_PI);
667+ map.insert("decJ2000", dec*180./M_PI);
668+
669+ // apparent altitude/azimuth
670+ pos = getAltAzPosApparent(core);
671+ StelUtils::rectToSphe(&az, &alt, pos);
672+ float direction = 3.; // N is zero, E is 90 degrees
673+ if (useOldAzimuth)
674+ direction = 2.;
675+ az = direction*M_PI - az;
676+ if (az > M_PI*2)
677+ az -= M_PI*2;
678+
679+ map.insert("altitude", alt*180./M_PI);
680+ map.insert("azimuth", az*180./M_PI);
681+
682+ // geometric altitude/azimuth
683+ pos = getAltAzPosGeometric(core);
684+ StelUtils::rectToSphe(&az, &alt, pos);
685+ az = direction*M_PI - az;
686+ if (az > M_PI*2)
687+ az -= M_PI*2;
688+
689+ map.insert("altitude-geometric", alt*180./M_PI);
690+ map.insert("azimuth-geometric", az*180./M_PI);
691+
692+ // galactic long/lat
693+ pos = getGalacticPos(core);
694+ StelUtils::rectToSphe(&glong, &glat, pos);
695+ map.insert("glong", glong*180./M_PI);
696+ map.insert("glat", glat*180./M_PI);
697+
698+ // supergalactic long/lat
699+ pos = getSupergalacticPos(core);
700+ StelUtils::rectToSphe(&glong, &glat, pos);
701+ map.insert("sglong", glong*180./M_PI);
702+ map.insert("sglat", glat*180./M_PI);
703+
704+ SolarSystem* ssmgr = GETSTELMODULE(SolarSystem);
705+ double ra_equ, dec_equ, lambda, beta;
706+ // J2000
707+ double eclJ2000 = ssmgr->getEarth()->getRotObliquity(2451545.0);
708+ double ecl = ssmgr->getEarth()->getRotObliquity(core->getJDE());
709+
710+ // ecliptic longitude/latitude (J2000 frame)
711+ StelUtils::rectToSphe(&ra_equ,&dec_equ, getJ2000EquatorialPos(core));
712+ StelUtils::equToEcl(ra_equ, dec_equ, eclJ2000, &lambda, &beta);
713+ if (lambda<0) lambda+=2.0*M_PI;
714+ map.insert("elongJ2000", lambda*180./M_PI);
715+ map.insert("elatJ2000", beta*180./M_PI);
716+
717+ if (QString("Earth Sun").contains(core->getCurrentLocation().planetName))
718+ {
719+ // ecliptic longitude/latitude
720+ StelUtils::rectToSphe(&ra_equ,&dec_equ, getEquinoxEquatorialPos(core));
721+ StelUtils::equToEcl(ra_equ, dec_equ, ecl, &lambda, &beta);
722+ if (lambda<0) lambda+=2.0*M_PI;
723+ map.insert("elong", lambda*180./M_PI);
724+ map.insert("elat", beta*180./M_PI);
725+ }
726+
727+ // magnitude
728+ map.insert("vmag", getVMagnitude(core));
729+ map.insert("vmage", getVMagnitudeWithExtinction(core));
730+
731+ // angular size
732+ double angularSize = 2.*getAngularSize(core)*M_PI/180.;
733+ bool sign;
734+ double deg;
735+ StelUtils::radToDecDeg(angularSize, sign, deg);
736+ if (!sign)
737+ deg *= -1;
738+ map.insert("size", angularSize);
739+ map.insert("size-dd", deg);
740+ map.insert("size-deg", StelUtils::radToDecDegStr(angularSize, 5));
741+ map.insert("size-dms", StelUtils::radToDmsStr(angularSize, true));
742+
743+ // english name or designation & localized name
744+ map.insert("name", getEnglishName());
745+ map.insert("localized-name", getNameI18n());
746+
747+ return map;
748+}
749
750=== modified file 'src/core/StelObject.hpp'
751--- src/core/StelObject.hpp 2016-12-29 15:37:01 +0000
752+++ src/core/StelObject.hpp 2017-03-09 14:02:12 +0000
753@@ -99,6 +99,36 @@
754 //! @return an HTML string containing information about the StelObject.
755 virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags=StelObject::AllInfo) const = 0;
756
757+ //! Return a key/value map with data about an object's position, magnitude and so on. Useful in a context like scripting.
758+ //! Derived objects can add their own special information tags.
759+ //! @param core the current StelCore
760+ //! @return a map of object data. Keys:
761+ //! - altitude : apparent altitude angle in decimal degrees
762+ //! - azimuth : apparent azimuth angle in decimal degrees
763+ //! - altitude-geometric : geometric altitude angle in decimal degrees
764+ //! - azimuth-geometric : geometric azimuth angle in decimal degrees
765+ //! - ra : right ascension angle (current date frame) in decimal degrees
766+ //! - dec : declination angle (current date frame) in decimal degrees
767+ //! - raJ2000 : right ascension angle (J2000 frame) in decimal degrees
768+ //! - decJ2000 : declination angle (J2000 frame) in decimal degrees
769+ //! - glong : galactic longitude in decimal degrees
770+ //! - glat : galactic latitude in decimal degrees
771+ //! - sglong : supergalactic longitude in decimal degrees
772+ //! - sglat : supergalactic latitude in decimal degrees
773+ //! - elong : ecliptic longitude in decimal degrees (on Earth only!)
774+ //! - elat : ecliptic latitude in decimal degrees (on Earth only!)
775+ //! - elongJ2000 : ecliptic longitude (Earth's J2000 frame) in decimal degrees
776+ //! - elatJ2000 : ecliptic latitude (Earth's J2000 frame) in decimal degrees
777+ //! - vmag : visual magnitude
778+ //! - vmage : visual magnitude (after atmospheric extinction)
779+ //! - size: angular size in radians
780+ //! - size-dd : angular size in decimal degrees
781+ //! - size-deg : angular size in decimal degrees (formatted string)
782+ //! - size-dms : angular size in DMS format
783+ //! - name : english name of the object
784+ //! - localized-name : localized name
785+ virtual QVariantMap getInfoMap(const StelCore *core) const;
786+
787 //! Return object's type. It should be the name of the class.
788 virtual QString getType() const = 0;
789
790
791=== modified file 'src/core/StelObjectMgr.cpp'
792--- src/core/StelObjectMgr.cpp 2017-01-06 09:53:37 +0000
793+++ src/core/StelObjectMgr.cpp 2017-03-09 14:02:12 +0000
794@@ -374,3 +374,19 @@
795 }
796 return result;
797 }
798+
799+QVariantMap StelObjectMgr::getObjectInfo(const StelObjectP obj)
800+{
801+ QVariantMap map;
802+ if (!obj)
803+ {
804+ qDebug() << "getObjectInfo WARNING - object not found";
805+ map.insert("found", false);
806+ }
807+ else
808+ {
809+ map=obj->getInfoMap(StelApp::getInstance().getCore());
810+ map.insert("found", true);
811+ }
812+ return map;
813+}
814
815=== modified file 'src/core/StelObjectMgr.hpp'
816--- src/core/StelObjectMgr.hpp 2016-07-03 21:58:54 +0000
817+++ src/core/StelObjectMgr.hpp 2017-03-09 14:02:12 +0000
818@@ -132,6 +132,11 @@
819 //! Default to 1.
820 void setDistanceWeight(float newDistanceWeight) {distanceWeight=newDistanceWeight;}
821
822+ //! Return a QMap of data about the object (calls obj->getInfoMap()).
823+ //! If obj is valid, add an element ["found", true].
824+ //! If obj is NULL, returns a 1-element map [["found", false]]
825+ static QVariantMap getObjectInfo(const StelObjectP obj);
826+
827 signals:
828 //! Indicate that the selected StelObjects has changed.
829 //! @param action define if the user requested that the objects are added to the selection or just replace it
830
831=== modified file 'src/core/modules/Atmosphere.cpp'
832--- src/core/modules/Atmosphere.cpp 2016-11-28 14:24:21 +0000
833+++ src/core/modules/Atmosphere.cpp 2017-03-09 14:02:12 +0000
834@@ -381,7 +381,7 @@
835
836 // And draw everything at once
837 indicesBuffer.bind();
838- int shift=0;
839+ std::size_t shift=0;
840 for (int y=0;y<skyResolutionY;++y)
841 {
842 sPainter.glFuncs()->glDrawElements(GL_TRIANGLE_STRIP, (skyResolutionX+1)*2, GL_UNSIGNED_SHORT, reinterpret_cast<void*>(shift));
843
844=== modified file 'src/core/modules/Comet.cpp'
845--- src/core/modules/Comet.cpp 2017-01-08 16:39:11 +0000
846+++ src/core/modules/Comet.cpp 2017-03-09 14:02:12 +0000
847@@ -272,6 +272,14 @@
848 return str;
849 }
850
851+QVariantMap Comet::getInfoMap(const StelCore *core) const
852+{
853+ QVariantMap map = StelObject::getInfoMap(core);
854+ map.insert("tail-length-km", tailFactors[1]*AU);
855+ map.insert("coma-diameter-km", tailFactors[0]*AU);
856+
857+ return map;
858+}
859 void Comet::setSemiMajorAxis(const double value)
860 {
861 semiMajorAxis = value;
862
863=== modified file 'src/core/modules/Comet.hpp'
864--- src/core/modules/Comet.hpp 2015-09-13 21:33:23 +0000
865+++ src/core/modules/Comet.hpp 2017-03-09 14:02:12 +0000
866@@ -33,6 +33,7 @@
867 2014-01: GZ: Parabolic tails appropriately scaled/rotated. Much is currently empirical, leaving room for physics-based improvements.
868 2014-08: GZ: speedup in case hundreds of comets are loaded.
869 2014-11: GZ: tail extinction, better brightness balance.
870+ 2017-03: GZ: added fields to infoMap
871 */
872 class Comet : public Planet
873 {
874@@ -72,6 +73,11 @@
875 //! \param flags a set of InfoStringGroup items to include in the return value.
876 //! \return a QString containing an HMTL encoded description of the Comet.
877 virtual QString getInfoString(const StelCore *core, const InfoStringGroup &flags) const;
878+ //! In addition to Planet::getInfoMap(), Comets provides estimates for
879+ //! - tail-length-km
880+ //! - coma-diameter-km
881+ //! using the formula from Guide found by the GSoC2012 initiative at http://www.projectpluto.com/update7b.htm#comet_tail_formula
882+ virtual QVariantMap getInfoMap(const StelCore *core) const;
883 //The Comet class inherits the "Planet" type because the SolarSystem class
884 //was not designed to handle different types of objects.
885 //virtual QString getType() const {return "Comet";}
886
887=== modified file 'src/core/modules/Planet.cpp'
888--- src/core/modules/Planet.cpp 2017-01-26 17:39:02 +0000
889+++ src/core/modules/Planet.cpp 2017-03-09 14:02:12 +0000
890@@ -442,6 +442,33 @@
891 return str;
892 }
893
894+QVariantMap Planet::getInfoMap(const StelCore *core) const
895+{
896+ QVariantMap map = StelObject::getInfoMap(core);
897+
898+ if (getEnglishName()!="Sun")
899+ {
900+ const Vec3d& observerHelioPos = core->getObserverHeliocentricEclipticPos();
901+ map.insert("distance", getJ2000EquatorialPos(core).length());
902+ double phase=getPhase(observerHelioPos);
903+ map.insert("phase", phase);
904+ map.insert("illumination", 100.*phase);
905+ double phaseAngle = getPhaseAngle(observerHelioPos);
906+ map.insert("phase-angle", phaseAngle);
907+ map.insert("phase-angle-dms", StelUtils::radToDmsStr(phaseAngle));
908+ map.insert("phase-angle-deg", StelUtils::radToDecDegStr(phaseAngle));
909+ double elongation = getElongation(observerHelioPos);
910+ map.insert("elongation", elongation);
911+ map.insert("elongation-dms", StelUtils::radToDmsStr(elongation));
912+ map.insert("elongation-deg", StelUtils::radToDecDegStr(elongation));
913+ map.insert("type", getPlanetTypeString()); // replace existing "type=Planet" by something more detailed.
914+ // TBD: Is there ANY reason to keep "type"="Planet" and add a "ptype"=getPlanetTypeString() field?
915+ }
916+
917+ return map;
918+}
919+
920+
921 //! Get sky label (sky translation)
922 QString Planet::getSkyLabel(const StelCore*) const
923 {
924
925=== modified file 'src/core/modules/Planet.hpp'
926--- src/core/modules/Planet.hpp 2017-01-06 16:52:05 +0000
927+++ src/core/modules/Planet.hpp 2017-03-09 14:02:12 +0000
928@@ -153,6 +153,18 @@
929 //! @param flags a set of InfoStringGroup items to include in the return value.
930 //! @return a QString containing an HMTL encoded description of the Planet.
931 virtual QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const;
932+ //! In addition to the entries from StelObject::getInfoMap(), Planet objects provide
933+ //! - distance
934+ //! - phase (result of getPhase)
935+ //! - illumination (=100*phase)
936+ //! - phase-angle
937+ //! - phase-angle-dms (formatted string)
938+ //! - phase-angle-deg (formatted string)
939+ //! - elongation
940+ //! - elongation-dms (formatted string)
941+ //! - elongation-deg (formatted string)
942+ //! - type (object type description)
943+ virtual QVariantMap getInfoMap(const StelCore *core) const;
944 virtual double getCloseViewFov(const StelCore* core) const;
945 virtual double getSatellitesFov(const StelCore* core) const;
946 virtual double getParentSatellitesFov(const StelCore* core) const;
947@@ -213,21 +225,21 @@
948
949 const RotationElements &getRotationElements(void) const {return re;}
950
951- // Compute the position in the parent Planet coordinate system
952+ //! Compute the position in the parent Planet coordinate system
953 void computePositionWithoutOrbits(const double dateJDE);
954 void computePosition(const double dateJDE);
955
956- // Compute the transformation matrix from the local Planet coordinate to the parent Planet coordinate.
957- // This requires both flavours of JD in cases involving Earth.
958+ //! Compute the transformation matrix from the local Planet coordinate to the parent Planet coordinate.
959+ //! This requires both flavours of JD in cases involving Earth.
960 void computeTransMatrix(double JD, double JDE);
961
962- // Get the phase angle (rad) for an observer at pos obsPos in heliocentric coordinates (in AU)
963+ //! Get the phase angle (rad) for an observer at pos obsPos in heliocentric coordinates (in AU)
964 double getPhaseAngle(const Vec3d& obsPos) const;
965- // Get the elongation angle (rad) for an observer at pos obsPos in heliocentric coordinates (in AU)
966+ //! Get the elongation angle (rad) for an observer at pos obsPos in heliocentric coordinates (in AU)
967 double getElongation(const Vec3d& obsPos) const;
968- // Get the angular size of the spheroid of the planet (i.e. without the rings)
969+ //! Get the angular size of the spheroid of the planet (i.e. without the rings)
970 double getSpheroidAngularSize(const StelCore* core) const;
971- // Get the planet phase for an observer at pos obsPos in heliocentric coordinates (in AU)
972+ //! Get the planet phase for an observer at pos obsPos in heliocentric coordinates (in AU)
973 float getPhase(const Vec3d& obsPos) const;
974
975 // Set the orbital elements
976
977=== modified file 'src/scripting/StelMainScriptAPI.cpp'
978--- src/scripting/StelMainScriptAPI.cpp 2017-02-04 14:15:20 +0000
979+++ src/scripting/StelMainScriptAPI.cpp 2017-03-09 14:02:12 +0000
980@@ -711,6 +711,39 @@
981 StelApp::getInstance().getScriptMgr().output(s);
982 }
983
984+//! print contents of a QVariantMap
985+//! @param map QVariantMap e.g. from getObjectInfo() or getLocationInfo()
986+QString StelMainScriptAPI::mapToString(const QVariantMap& map) const
987+{
988+ QString res = QString("[\n");
989+ QList<QVariant::Type> simpleTypeList;
990+ simpleTypeList.push_back(QVariant::Bool);
991+ simpleTypeList.push_back(QVariant::Int);
992+ simpleTypeList.push_back(QVariant::UInt);
993+ simpleTypeList.push_back(QVariant::Double);
994+
995+ QVariantMap::const_iterator i=map.constBegin();
996+ while (i != map.constEnd()){
997+
998+ if (i.value().type()==QMetaType::QString)
999+ {
1000+ res.append(QString("[ \"%1\" = \"%2\" ]\n").arg(i.key()).arg(i.value().toString()));
1001+ }
1002+ else if (simpleTypeList.contains(i.value().type()))
1003+ {
1004+ res.append(QString("[ \"%1\" = %2 ]\n").arg(i.key()).arg(i.value().toString()));
1005+ }
1006+ else
1007+ {
1008+ res.append(QString("[ \"%1\" = \"<%2>:%3\" ]\n").arg(i.key()).arg(i.value().typeName()).arg(i.value().toString()));
1009+ }
1010+
1011+ ++i;
1012+ }
1013+ res.append( QString("]\n"));
1014+ return res;
1015+}
1016+
1017 void StelMainScriptAPI::resetOutput(void) const
1018 {
1019 StelApp::getInstance().getScriptMgr().resetOutput();
1020@@ -841,7 +874,7 @@
1021 StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);
1022 StelObjectP obj = omgr->searchByName(name);
1023
1024- return StelMainScriptAPI::getObjectInfo(obj);
1025+ return StelObjectMgr::getObjectInfo(obj);
1026 }
1027
1028 QVariantMap StelMainScriptAPI::getSelectedObjectInfo()
1029@@ -857,140 +890,8 @@
1030
1031 StelObjectP obj = omgr->getSelectedObject()[0];
1032
1033- return StelMainScriptAPI::getObjectInfo(obj);
1034-}
1035-
1036-QVariantMap StelMainScriptAPI::getObjectInfo(const StelObjectP obj)
1037-{
1038- QVariantMap map;
1039- if (!obj)
1040- {
1041- debug("getObjectData WARNING - object not found");
1042- map.insert("found", false);
1043- return map;
1044- }
1045- else
1046- {
1047- map.insert("found", true);
1048- }
1049-
1050- // OK, object found. Let's go.
1051- Vec3d pos;
1052- double ra, dec, alt, az, glong, glat;
1053- StelCore* core = StelApp::getInstance().getCore();
1054- bool useOldAzimuth = StelApp::getInstance().getFlagSouthAzimuthUsage();
1055-
1056- // ra/dec
1057- pos = obj->getEquinoxEquatorialPos(core);
1058- StelUtils::rectToSphe(&ra, &dec, pos);
1059- map.insert("ra", ra*180./M_PI);
1060- map.insert("dec", dec*180./M_PI);
1061-
1062- // ra/dec in J2000
1063- pos = obj->getJ2000EquatorialPos(core);
1064- StelUtils::rectToSphe(&ra, &dec, pos);
1065- map.insert("raJ2000", ra*180./M_PI);
1066- map.insert("decJ2000", dec*180./M_PI);
1067-
1068- // apparent altitude/azimuth
1069- pos = obj->getAltAzPosApparent(core);
1070- StelUtils::rectToSphe(&az, &alt, pos);
1071- float direction = 3.; // N is zero, E is 90 degrees
1072- if (useOldAzimuth)
1073- direction = 2.;
1074- az = direction*M_PI - az;
1075- if (az > M_PI*2)
1076- az -= M_PI*2;
1077-
1078- map.insert("altitude", alt*180./M_PI);
1079- map.insert("azimuth", az*180./M_PI);
1080-
1081- // geometric altitude/azimuth
1082- pos = obj->getAltAzPosGeometric(core);
1083- StelUtils::rectToSphe(&az, &alt, pos);
1084- az = direction*M_PI - az;
1085- if (az > M_PI*2)
1086- az -= M_PI*2;
1087-
1088- map.insert("altitude-geometric", alt*180./M_PI);
1089- map.insert("azimuth-geometric", az*180./M_PI);
1090-
1091- // galactic long/lat
1092- pos = obj->getGalacticPos(core);
1093- StelUtils::rectToSphe(&glong, &glat, pos);
1094- map.insert("glong", glong*180./M_PI);
1095- map.insert("glat", glat*180./M_PI);
1096-
1097- // supergalactic long/lat
1098- pos = obj->getSupergalacticPos(core);
1099- StelUtils::rectToSphe(&glong, &glat, pos);
1100- map.insert("sglong", glong*180./M_PI);
1101- map.insert("sglat", glat*180./M_PI);
1102-
1103- SolarSystem* ssmgr = GETSTELMODULE(SolarSystem);
1104- double ra_equ, dec_equ, lambda, beta;
1105- // J2000
1106- double eclJ2000 = ssmgr->getEarth()->getRotObliquity(2451545.0);
1107- double ecl = ssmgr->getEarth()->getRotObliquity(core->getJDE());
1108-
1109- // ecliptic longitude/latitude (J2000 frame)
1110- StelUtils::rectToSphe(&ra_equ,&dec_equ, obj->getJ2000EquatorialPos(core));
1111- StelUtils::equToEcl(ra_equ, dec_equ, eclJ2000, &lambda, &beta);
1112- if (lambda<0) lambda+=2.0*M_PI;
1113- map.insert("elongJ2000", lambda*180./M_PI);
1114- map.insert("elatJ2000", beta*180./M_PI);
1115-
1116- if (QString("Earth Sun").contains(core->getCurrentLocation().planetName))
1117- {
1118- // ecliptic longitude/latitude
1119- StelUtils::rectToSphe(&ra_equ,&dec_equ, obj->getEquinoxEquatorialPos(core));
1120- StelUtils::equToEcl(ra_equ, dec_equ, ecl, &lambda, &beta);
1121- if (lambda<0) lambda+=2.0*M_PI;
1122- map.insert("elong", lambda*180./M_PI);
1123- map.insert("elat", beta*180./M_PI);
1124- }
1125-
1126- // magnitude
1127- map.insert("vmag", obj->getVMagnitude(core));
1128- map.insert("vmage", obj->getVMagnitudeWithExtinction(core));
1129-
1130- // angular size
1131- double angularSize = 2.*obj->getAngularSize(core)*M_PI/180.;
1132- bool sign;
1133- double deg;
1134- StelUtils::radToDecDeg(angularSize, sign, deg);
1135- if (!sign)
1136- deg *= -1;
1137- map.insert("size", angularSize);
1138- map.insert("size-dd", deg);
1139- map.insert("size-deg", StelUtils::radToDecDegStr(angularSize, 5));
1140- map.insert("size-dms", StelUtils::radToDmsStr(angularSize, true));
1141-
1142- if (obj->getType().toLower()=="planet" && obj->getEnglishName()!="Sun")
1143- {
1144- SolarSystem* ssmgr = GETSTELMODULE(SolarSystem);
1145- map.insert("distance", obj->getJ2000EquatorialPos(core).length());
1146- double phase = ssmgr->getPhaseForPlanet(obj->getEnglishName());
1147- map.insert("phase", phase);
1148- map.insert("illumination", 100.*phase);
1149- double phaseAngle = ssmgr->getPhaseAngleForPlanet(obj->getEnglishName());
1150- map.insert("phase-angle", phaseAngle);
1151- map.insert("phase-angle-dms", StelUtils::radToDmsStr(phaseAngle));
1152- map.insert("phase-angle-deg", StelUtils::radToDecDegStr(phaseAngle));
1153- double elongation = ssmgr->getElongationForPlanet(obj->getEnglishName());
1154- map.insert("elongation", elongation);
1155- map.insert("elongation-dms", StelUtils::radToDmsStr(elongation));
1156- map.insert("elongation-deg", StelUtils::radToDecDegStr(elongation));
1157- map.insert("ptype", ssmgr->getPlanetType(obj->getEnglishName()));
1158- }
1159-
1160- // english name or designation & localized name
1161- map.insert("name", obj->getEnglishName());
1162- map.insert("localized-name", obj->getNameI18n());
1163-
1164- return map;
1165-}
1166-
1167+ return StelObjectMgr::getObjectInfo(obj);
1168+}
1169
1170 void StelMainScriptAPI::clear(const QString& state)
1171 {
1172
1173=== modified file 'src/scripting/StelMainScriptAPI.hpp'
1174--- src/scripting/StelMainScriptAPI.hpp 2017-02-04 14:15:20 +0000
1175+++ src/scripting/StelMainScriptAPI.hpp 2017-03-09 14:02:12 +0000
1176@@ -173,62 +173,29 @@
1177 //! - size-deg : angular size in decimal degrees (formatted string)
1178 //! - size-dms : angular size in DMS format
1179 //! - localized-name : localized name
1180+ //! The returned map can contain other information. For example, Solar System objects add:
1181 //! - distance : distance to object in AU (for Solar system objects only!)
1182- //! - phase : phase of object (for Solar system objects only!)
1183- //! - illumination : phase of object in percentages (for Solar system objects only!)
1184+ //! - phase : phase (illuminated fraction, 0..1) of object (for Solar system objects only!)
1185+ //! - illumination : phase of object in percent (0..100) (for Solar system objects only!)
1186 //! - phase-angle : phase angle of object in radians (for Solar system objects only!)
1187 //! - phase-angle-dms : phase angle of object in DMS (for Solar system objects only!)
1188 //! - phase-angle-deg : phase angle of object in decimal degrees (for Solar system objects only!)
1189 //! - elongation : elongation of object in radians (for Solar system objects only!)
1190 //! - elongation-dms : elongation of object in DMS (for Solar system objects only!)
1191 //! - elongation-deg : elongation of object in decimal degrees (for Solar system objects only!)
1192- //! - ptype : object type (for Solar system objects only!)
1193+ //! Other StelObject derivates, also those defined in plugins, may add more,
1194+ //! these fields are documented in the respective classes, or simply try what you get:
1195+ //! You can print a complete set of entries into output with the following commands:
1196+ //! @code
1197+ //! map=core.getSelectedObjectInfo();
1198+ //! core.output(core.mapToString(map));
1199+ //! @endcode
1200 QVariantMap getObjectInfo(const QString& name);
1201
1202- //! Fetch a map with data about an latest selected object's position, magnitude and so on
1203- //! @return a map of object data. Keys:
1204- //! - altitude : apparent altitude angle in decimal degrees
1205- //! - azimuth : apparent azimuth angle in decimal degrees
1206- //! - altitude-geometric : geometric altitude angle in decimal degrees
1207- //! - azimuth-geometric : geometric azimuth angle in decimal degrees
1208- //! - ra : right ascension angle (current date frame) in decimal degrees
1209- //! - dec : declination angle in (current date frame) decimal degrees
1210- //! - raJ2000 : right ascension angle (J2000 frame) in decimal degrees
1211- //! - decJ2000 : declination angle in (J2000 frame) decimal degrees
1212- //! - glong : galactic longitude in decimal degrees
1213- //! - glat : galactic latitude in decimal degrees
1214- //! - sglong : supergalactic longitude in decimal degrees
1215- //! - sglat : supergalactic latitude in decimal degrees
1216- //! - elong : ecliptic longitude in decimal degrees (on Earth only!)
1217- //! - elat : ecliptic latitude in decimal degrees (on Earth only!)
1218- //! - elongJ2000 : ecliptic longitude (Earth's J2000 frame) in decimal degrees
1219- //! - elatJ2000 : ecliptic latitude (Earth's J2000 frame) in decimal degrees
1220- //! - vmag : visual magnitude
1221- //! - vmage : visual magnitude (extincted)
1222- //! - size: angular size in radians
1223- //! - size-dd : angular size in decimal degrees
1224- //! - size-deg : angular size in decimal degrees (formatted string)
1225- //! - size-dms : angular size in DMS format
1226- //! - name : english name
1227- //! - localized-name : localized name
1228- //! - distance : distance to object in AU (for Solar system objects only!)
1229- //! - phase : phase of object (for Solar system objects only!)
1230- //! - illumination : phase of object in percentages (for Solar system objects only!)
1231- //! - phase-angle : phase angle of object in radians (for Solar system objects only!)
1232- //! - phase-angle-dms : phase angle of object in DMS (for Solar system objects only!)
1233- //! - phase-angle-deg : phase angle of object in decimal degrees (for Solar system objects only!)
1234- //! - elongation : elongation of object in radians (for Solar system objects only!)
1235- //! - elongation-dms : elongation of object in DMS (for Solar system objects only!)
1236- //! - elongation-deg : elongation of object in decimal degrees (for Solar system objects only!)
1237- //! - ptype : object type (for Solar system objects only!)
1238+ //! Fetch a map with data about the latest selected object's position, magnitude and so on
1239+ //! @return a map of object data. See description for getObjectInfo(const QString& name);
1240 QVariantMap getSelectedObjectInfo();
1241
1242-public:
1243- //! Called by getSelectedObjectInfo() and getObjectInfo(name). Not useful to be scriptable, not a slot!
1244- //! The static method can be called more easily by other components.
1245- static QVariantMap getObjectInfo(const StelObjectP obj);
1246-
1247-public slots:
1248 //! Clear the display options, setting a "standard" view.
1249 //! Preset states:
1250 //! - natural : azimuthal mount, atmosphere, landscape,
1251@@ -735,6 +702,12 @@
1252 //! @param s the message to be displayed on the output file.
1253 void output(const QString& s) const;
1254
1255+ //! print contents of a QVariantMap as []-delimited list of [ "key" = <value>] lists.
1256+ //! @param map QVariantMap e.g. from getObjectInfo() or getLocationInfo()
1257+ //! @note string values are surrounded with ", simple numeric types are printed as themselves.
1258+ //! @note More complicated value types like lists are only indicated by their type name. You must extract those (and their contents) yourself.
1259+ QString mapToString(const QVariantMap &map) const;
1260+
1261 //! Reset (clear) output file
1262 void resetOutput(void) const;
1263