10#include "kstarsdata.h"
11#include "kstarsdatetime.h"
13#include "observinglist.h"
15#include "skycomponents/constellationboundarylines.h"
16#include "skycomponents/skymapcomposite.h"
17#include "skyobjects/skyobject.h"
18#include "skyobjects/starobject.h"
20#include "kstars_debug.h"
25 qDeleteAll(m_observerList);
26 qDeleteAll(m_eyepieceList);
27 qDeleteAll(m_lensList);
28 qDeleteAll(m_filterList);
29 qDeleteAll(m_siteList);
30 qDeleteAll(m_sessionList);
31 qDeleteAll(m_scopeList);
32 qDeleteAll(m_dslrLensList);
33 qDeleteAll(m_observationList);
36void OAL::Log::writeBegin()
40 m_targetList = KStarsData::Instance()->observingList()->
sessionList();
42 writer->setAutoFormatting(
true);
43 writer->writeStartDocument();
44 writer->writeNamespace(
"http://observation.sourceforge.net/openastronomylog",
"oal");
45 writer->writeNamespace(
"http://www.w3.org/2001/XMLSchema-instance",
"xsi");
46 writer->writeNamespace(
"http://observation.sourceforge.net/openastronomylog oal20.xsd",
"schemaLocation");
47 writer->writeStartElement(
"oal:observations");
48 writer->writeAttribute(
"version",
"2.0");
51QString OAL::Log::writeLog(
bool _native)
72void OAL::Log::writeEnd()
74 writer->writeEndDocument();
78void OAL::Log::writeObservers()
80 writer->writeStartElement(
"observers");
83 writer->writeEndElement();
86void OAL::Log::writeSites()
88 writer->writeStartElement(
"sites");
91 writer->writeEndElement();
94void OAL::Log::writeSessions()
96 writer->writeStartElement(
"sessions");
99 writer->writeEndElement();
102void OAL::Log::writeTargets()
104 writer->writeStartElement(
"targets");
106 for (
auto &o : m_targetList)
108 writeTarget(o.data());
110 writer->writeEndElement();
113void OAL::Log::writeScopes()
115 writer->writeStartElement(
"scopes");
118 writer->writeEndElement();
121void OAL::Log::writeDSLRLenses()
123 writer->writeStartElement(
"dslrlenses");
124 for (
const auto &o : m_dslrLensList)
126 writer->writeEndElement();
129void OAL::Log::writeEyepieces()
131 writer->writeStartElement(
"eyepieces");
132 foreach (OAL::Eyepiece *o, m_eyepieceList)
134 writer->writeEndElement();
137void OAL::Log::writeLenses()
139 writer->writeStartElement(
"lenses");
142 writer->writeEndElement();
145void OAL::Log::writeFilters()
147 writer->writeStartElement(
"filters");
150 writer->writeEndElement();
153void OAL::Log::writeImagers()
155 writer->writeStartElement(
"imagers");
156 writer->writeEndElement();
159void OAL::Log::writeObservations()
167 writer->writeStartElement(
"target");
168 writer->writeAttribute(
"id", o->
name().
remove(
' '));
171 writer->writeAttribute(
"type", o->
typeName());
177 typeString =
"oal:starTargetType";
180 typeString =
"oal:starTargetType";
183 typeString =
"oal:PlanetTargetType";
186 typeString =
"oal:deepSkyOC";
189 typeString =
"oal:deepSkyGC";
192 typeString =
"oal:deepSkyGN";
195 typeString =
"oal:deepSkyPN";
198 typeString =
"oal:deepSkyGX";
201 typeString =
"oal:CometTargetType";
204 typeString =
"oal:MoonTargetType";
207 typeString =
"oal:deepSkyAS";
210 typeString =
"oal:deepSkyCG";
213 typeString =
"oal:deepSkyDN";
216 typeString =
"oal:deepSkyQS";
219 typeString =
"oal:deepSkyMS";
222 typeString =
"oal:deepSkyNA";
225 writer->writeAttribute(
"xsi:type", typeString);
227 writer->writeStartElement(
"datasource");
228 writer->writeCDATA(
"KStars");
229 writer->writeEndElement();
230 writer->writeStartElement(
"name");
237 writer->writeCDATA(name);
238 writer->writeEndElement();
239 writer->writeStartElement(
"position");
240 writer->writeStartElement(
"ra");
241 writer->writeAttribute(
"unit",
"rad");
243 writer->writeEndElement();
244 writer->writeStartElement(
"dec");
245 writer->writeAttribute(
"unit",
"rad");
247 writer->writeEndElement();
248 writer->writeEndElement();
249 if (native && !KStarsData::Instance()->observingList()->getTime(o).isEmpty())
251 writer->writeStartElement(
"time");
252 writer->writeCDATA(KStarsData::Instance()->observingList()->getTime(o));
253 writer->writeEndElement();
255 writer->writeStartElement(
"constellation");
256 writer->writeCDATA(KStarsData::Instance()
258 ->constellationBoundary()
259 ->constellationName(o));
260 writer->writeEndElement();
261 writer->writeStartElement(
"notes");
262 writer->writeCDATA(KStarsData::Instance()->getUserData(o->
name()).userLog);
263 writer->writeEndElement();
264 writer->writeEndElement();
269 writer->writeStartElement(
"observer");
270 writer->writeAttribute(
"id", o->id());
271 writer->writeStartElement(
"name");
272 writer->writeCDATA(o->name());
273 writer->writeEndElement();
274 writer->writeStartElement(
"surname");
275 writer->writeCDATA(o->surname());
276 writer->writeEndElement();
277 writer->writeStartElement(
"contact");
278 writer->writeCDATA(o->contact());
279 writer->writeEndElement();
280 writer->writeEndElement();
285 writer->writeStartElement(
"site");
286 writer->writeAttribute(
"id", s->id());
287 writer->writeStartElement(
"name");
288 writer->writeCDATA(s->name());
289 writer->writeEndElement();
290 writer->writeStartElement(
"latitude");
291 writer->writeAttribute(
"unit", s->latUnit());
293 writer->writeStartElement(
"longitude");
294 writer->writeAttribute(
"unit", s->lonUnit());
296 writer->writeEndElement();
297 writer->writeEndElement();
302 writer->writeStartElement(
"session");
303 writer->writeAttribute(
"id", s->id());
304 writer->writeStartElement(
"begin");
306 writer->writeEndElement();
307 writer->writeStartElement(
"end");
309 writer->writeEndElement();
310 writer->writeStartElement(
"site");
311 writer->writeCharacters(s->site());
312 writer->writeEndElement();
313 writer->writeStartElement(
"weather");
314 writer->writeCDATA(s->weather());
315 writer->writeEndElement();
316 writer->writeStartElement(
"equipment");
317 writer->writeCDATA(s->equipment());
318 writer->writeEndElement();
319 writer->writeStartElement(
"comments");
320 writer->writeCDATA(s->comments());
321 writer->writeEndElement();
322 writer->writeEndElement();
327 writer->writeStartElement(
"scope");
328 writer->writeAttribute(
"id", s->id());
329 writer->writeStartElement(
"model");
330 writer->writeCDATA(s->model());
331 writer->writeEndElement();
332 writer->writeStartElement(
"type");
333 writer->writeCDATA(s->type().
at(0));
334 writer->writeEndElement();
335 writer->writeStartElement(
"vendor");
336 writer->writeCDATA(s->vendor());
337 writer->writeEndElement();
338 writer->writeStartElement(
"aperture");
340 writer->writeEndElement();
341 writer->writeStartElement(
"focalLength");
343 writer->writeEndElement();
344 writer->writeEndElement();
345 writer->writeEndElement();
350 writer->writeStartElement(
"dslrlens");
351 writer->writeAttribute(
"id", s->id());
352 writer->writeStartElement(
"model");
353 writer->writeCDATA(s->model());
354 writer->writeEndElement();
355 writer->writeStartElement(
"vendor");
356 writer->writeCDATA(s->vendor());
357 writer->writeEndElement();
358 writer->writeStartElement(
"focalLength");
360 writer->writeEndElement();
361 writer->writeStartElement(
"focalRatio");
363 writer->writeEndElement();
364 writer->writeEndElement();
367void OAL::Log::writeEyepiece(OAL::Eyepiece *ep)
369 writer->writeStartElement(
"eyepiece");
370 writer->writeAttribute(
"id", ep->id());
371 writer->writeStartElement(
"model");
372 writer->writeCDATA(ep->model());
373 writer->writeEndElement();
374 writer->writeStartElement(
"vendor");
375 writer->writeCDATA(ep->vendor());
376 writer->writeEndElement();
377 writer->writeStartElement(
"focalLength");
379 writer->writeEndElement();
380 writer->writeStartElement(
"apparantFOV");
381 writer->writeAttribute(
"unit", ep->fovUnit());
383 writer->writeEndElement();
384 writer->writeEndElement();
389 writer->writeStartElement(
"lens");
390 writer->writeAttribute(
"id", l->id());
391 writer->writeStartElement(
"model");
392 writer->writeCDATA(l->model());
393 writer->writeEndElement();
394 writer->writeStartElement(
"vendor");
395 writer->writeCDATA(l->vendor());
396 writer->writeEndElement();
397 writer->writeStartElement(
"factor");
399 writer->writeEndElement();
400 writer->writeEndElement();
405 writer->writeStartElement(
"filter");
406 writer->writeAttribute(
"id", f->id());
409 writer->writeStartElement(
"model");
410 writer->writeCDATA(f->model());
411 writer->writeEndElement();
413 writer->writeStartElement(
"vendor");
414 writer->writeCDATA(f->vendor());
415 writer->writeEndElement();
417 writer->writeStartElement(
"type");
418 writer->writeCDATA(f->type());
419 writer->writeEndElement();
421 writer->writeStartElement(
"color");
422 writer->writeCDATA(f->color());
423 writer->writeEndElement();
425 writer->writeStartElement(
"offset");
427 writer->writeEndElement();
429 writer->writeStartElement(
"exposure");
431 writer->writeEndElement();
433 writer->writeStartElement(
"autofocus");
435 writer->writeEndElement();
437 writer->writeStartElement(
"lockedfilter");
438 writer->writeCDATA(f->lockedFilter());
439 writer->writeEndElement();
441 writer->writeEndElement();
446 writer->writeStartElement(
"observation");
447 writer->writeStartElement(
"observer");
448 writer->writeCharacters(o->observer());
449 writer->writeEndElement();
450 writer->writeStartElement(
"site");
451 writer->writeCharacters(o->site());
452 writer->writeEndElement();
453 writer->writeStartElement(
"session");
454 writer->writeCharacters(o->session());
455 writer->writeEndElement();
456 writer->writeStartElement(
"target");
457 writer->writeCharacters(o->target().
remove(
' '));
458 writer->writeEndElement();
459 writer->writeStartElement(
"begin");
461 writer->writeEndElement();
462 writer->writeStartElement(
"faintestStar");
464 writer->writeEndElement();
465 writer->writeStartElement(
"seeing");
467 writer->writeEndElement();
468 writer->writeStartElement(
"scope");
469 writer->writeCharacters(o->scope());
470 writer->writeEndElement();
471 writer->writeStartElement(
"eyepiece");
472 writer->writeCharacters(o->eyepiece());
473 writer->writeEndElement();
474 writer->writeStartElement(
"lens");
475 writer->writeCharacters(o->lens());
476 writer->writeEndElement();
477 writer->writeStartElement(
"filter");
478 writer->writeCharacters(o->filter());
479 writer->writeEndElement();
480 writer->writeStartElement(
"result");
481 writer->writeAttribute(
"xsi:type",
"oal:findingsType");
482 writer->writeAttribute(
"lang", o->lang());
483 writer->writeStartElement(
"description");
484 writer->writeCDATA(o->result());
485 writer->writeEndElement();
486 writer->writeEndElement();
487 writer->writeEndElement();
490void OAL::Log::writeGeoDate()
492 writer->writeStartElement(
"geodate");
493 writer->writeStartElement(
"name");
494 writer->writeCDATA(KStarsData::Instance()->observingList()->geoLocation()->
name());
495 writer->writeEndElement();
496 writer->writeStartElement(
"province");
497 writer->writeCDATA(KStarsData::Instance()->observingList()->geoLocation()->province());
498 writer->writeEndElement();
499 writer->writeStartElement(
"country");
500 writer->writeCDATA(KStarsData::Instance()->observingList()->geoLocation()->
country());
501 writer->writeEndElement();
502 writer->writeStartElement(
"date");
503 writer->writeCDATA(KStarsData::Instance()->observingList()->dateTime().date().
toString(
"ddMMyyyy"));
504 writer->writeEndElement();
505 writer->writeEndElement();
508void OAL::Log::readBegin(
QString input)
511 while (!reader->atEnd())
514 if (reader->isStartElement())
522void OAL::Log::readUnknownElement()
524 while (!reader->atEnd())
528 if (reader->isEndElement())
531 if (reader->isStartElement())
532 readUnknownElement();
536void OAL::Log::readLog()
538 while (!reader->atEnd())
542 if (reader->isEndElement())
545 if (reader->isStartElement())
547 if (reader->name().toString() ==
"targets")
549 else if (reader->name().toString() ==
"sites")
551 else if (reader->name().toString() ==
"sessions")
553 else if (reader->name().toString() ==
"observation")
554 readObservation(reader->attributes().value(
"id").toString());
555 else if (reader->name().toString() ==
"geodate")
558 readUnknownElement();
563void OAL::Log::readTargets()
565 while (!reader->atEnd())
569 if (reader->isEndElement())
572 if (reader->isStartElement())
574 if (reader->name().toString() ==
"target")
577 readUnknownElement();
582void OAL::Log::readObservers()
587void OAL::Log::readSites()
589 while (!reader->atEnd())
593 if (reader->isEndElement())
596 if (reader->isStartElement())
598 if (reader->name().toString() ==
"site")
599 readSite(reader->attributes().value(
"id").toString());
601 readUnknownElement();
606void OAL::Log::readSessions()
608 while (!reader->atEnd())
612 if (reader->isEndElement())
615 if (reader->isStartElement())
617 if (reader->name().toString() ==
"session")
618 readSession(reader->attributes().value(
"id").toString(), reader->attributes().value(
"lang").toString());
620 readUnknownElement();
625void OAL::Log::readScopes()
630void OAL::Log::readDSLRLenses()
635void OAL::Log::readEyepieces()
640void OAL::Log::readLenses()
645void OAL::Log::readFilters()
650void OAL::Log::readTarget()
656 while (!reader->atEnd())
660 if (reader->isEndElement())
663 if (reader->isStartElement())
665 if (reader->name().toString() ==
"name")
667 name = reader->readElementText();
672 o = KStarsData::Instance()
674 ->findStarByGenetiveName(name);
679 else if (!o && reader->name().toString() ==
"position")
681 pos = readPosition(posOK);
685 while (!o && maxrd <= 2.0)
697 else if (reader->name().toString() ==
"time")
699 time = reader->readElementText();
703 else if (reader->name().toString() ==
"notes")
705 notes = reader->readElementText();
718 readUnknownElement();
723void OAL::Log::readSite(
const QString &
id)
726 while (!reader->atEnd())
730 if (reader->isEndElement())
733 if (reader->isStartElement())
735 if (reader->name().toString() ==
"name")
737 name = reader->readElementText();
739 else if (reader->name().toString() ==
"latitude")
741 lat = reader->readElementText();
742 latUnit = reader->attributes().value(
"unit").toString();
744 else if (reader->name().toString() ==
"longitude")
746 lon = reader->readElementText();
747 lonUnit = reader->attributes().value(
"unit").toString();
750 readUnknownElement();
754 m_siteList.append(o);
761 while (!reader->atEnd())
765 if (reader->isEndElement())
768 if (reader->isStartElement())
770 if (reader->name().toString() ==
"site")
772 site = reader->readElementText();
774 else if (reader->name().toString() ==
"begin")
776 begin = reader->readElementText();
779 else if (reader->name().toString() ==
"end")
781 end = reader->readElementText();
784 else if (reader->name().toString() ==
"weather")
786 weather = reader->readElementText();
788 else if (reader->name().toString() ==
"equipment")
790 equipment = reader->readElementText();
792 else if (reader->name().toString() ==
"comments")
794 comments = reader->readElementText();
797 readUnknownElement();
801 m_sessionList.append(o);
804SkyPoint OAL::Log::readPosition(
bool &OK)
807 bool RAOK =
false, DEOK =
false;
808 while (!reader->atEnd())
812 if (reader->isEndElement())
815 if (reader->isStartElement())
817 if (reader->name().toString() ==
"ra")
819 qDebug() << reader->readElementText() << reader->attributes().value(
"unit");
821 if (reader->attributes().value(
"unit").toString() ==
"rad")
822 ra.
setRadians(reader->readElementText().toDouble(&RAOK));
824 ra.
setD(reader->readElementText().toDouble(&RAOK));
828 else if (reader->name().toString() ==
"dec")
830 qDebug() << reader->readElementText() << reader->attributes().value(
"unit");
832 if (reader->attributes().value(
"unit").toString() ==
"rad")
833 de.
setRadians(reader->readElementText().toDouble(&DEOK));
835 de.
setD(reader->readElementText().toDouble(&DEOK));
840 readUnknownElement();
849void OAL::Log::readObservation(
const QString &
id)
851 QString observer, site, session, target, faintestStar, seeing, scope, eyepiece, lens,
filter, result, lang;
853 while (!reader->atEnd())
856 if (reader->isEndElement())
858 if (reader->isStartElement())
860 if (reader->name().toString() ==
"observer")
861 observer = reader->readElementText();
862 else if (reader->name().toString() ==
"site")
863 site = reader->readElementText();
864 else if (reader->name().toString() ==
"session")
865 session = reader->readElementText();
866 else if (reader->name().toString() ==
"target")
867 target = reader->readElementText();
868 else if (reader->name().toString() ==
"begin")
869 begin.fromString(reader->readElementText());
870 else if (reader->name().toString() ==
"faintestStar")
871 faintestStar = reader->readElementText();
872 else if (reader->name().toString() ==
"seeing")
873 seeing = reader->readElementText();
874 else if (reader->name().toString() ==
"scope")
875 scope = reader->readElementText();
876 else if (reader->name().toString() ==
"eyepiece")
877 eyepiece = reader->readElementText();
878 else if (reader->name().toString() ==
"lens")
879 lens = reader->readElementText();
880 else if (reader->name().toString() ==
"filter")
881 filter = reader->readElementText();
882 else if (reader->name().toString() ==
"result")
884 lang = reader->attributes().value(
"lang").toString();
885 result = readResult();
888 readUnknownElement();
892 seeing.
toDouble(), scope, eyepiece, lens, filter, result, lang);
893 m_observationList.append(o);
899 while (!reader->atEnd())
903 if (reader->isEndElement())
905 if (reader->isStartElement())
907 if (reader->name().toString() ==
"description")
908 result = reader->readElementText();
910 readUnknownElement();
916void OAL::Log::readGeoDate()
919 while (!reader->atEnd())
923 if (reader->isEndElement())
926 if (reader->isStartElement())
928 if (reader->name().toString() ==
"name")
929 name = reader->readElementText();
930 else if (reader->name().toString() ==
"province")
931 province = reader->readElementText();
932 else if (reader->name().toString() ==
"country")
933 country = reader->readElementText();
934 else if (reader->name().toString() ==
"date")
936 date = reader->readElementText();
939 readUnknownElement();
942 geo = KStarsData::Instance()->locationNamed(name, province, country);
945 qCWarning(KSTARS) <<
"Location " <<
name <<
", " << province <<
", " <<
country
946 <<
" not found in KStars. Using current location.";
947 geo = KStarsData::Instance()->
geo();
956 if (
QString(obs->name() +
' ' + obs->surname()) == name)
996 if (s->name() == name)
1012OAL::Eyepiece *OAL::Log::findEyepieceById(
const QString &
id)
1014 foreach (OAL::Eyepiece *e, *eyepieceList())
1046 if (s->name() == name)
1054 for (
const auto &s : *dslrLensList())
1056 if (s->name() == name)
1064 for (
const auto &s : *dslrLensList())
1072OAL::Eyepiece *OAL::Log::findEyepieceByName(
const QString &name)
1074 foreach (OAL::Eyepiece *e, *eyepieceList())
1076 if (e->name() == name)
1086 if (f->name() == name)
1096 if (l->name() == name)
1112void OAL::Log::readAll()
bool GetAllScopes(QList< OAL::Scope * > &m_scopeList)
updates the scope list with all scopes from database List is cleared and then filled with content.
bool GetAllObservers(QList< OAL::Observer * > &observer_list)
Updates the passed reference of observer_list with all observers The original content of the list is ...
bool GetAllLenses(QList< OAL::Lens * > &m_lensList)
Populate the reference passed with all lenses.
bool GetAllFilters(QList< OAL::Filter * > &m_filterList)
Populate the reference passed with all filters.
bool GetAllDSLRLenses(QList< OAL::DSLRLens * > &dslrlens_list)
updates the dslr list with all DSLR lenses from database List is cleared and then filled with content...
bool GetAllEyepieces(QList< OAL::Eyepiece * > &m_eyepieceList)
Populate the reference passed with all eyepieces.
SkyObject * objectNamed(const QString &name)
Find object by name.
std::pair< bool, QString > updateUserLog(const QString &name, const QString &newLog)
Update the user log of the object with the name to contain newLog (find and replace).
SkyMapComposite * skyComposite()
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
static KStarsDateTime fromString(const QString &s)
static KStars * Instance()
KStarsData * data() const
Information on DSLR lens used in astrophotography.
Information of user filters.
Information of lens utilized in the observation.
Information on observation session details.
FIXME: why not just use a QHash?
Information on telescope used in observation.
Information on session details.
Information on site of observation.
QList< QSharedPointer< SkyObject > > & sessionList()
SkyObject * starNearest(SkyPoint *p, double &maxrad)
Provides all necessary information about an object in the sky: its coordinates, name(s),...
virtual SkyObject * clone() const
Create copy of object.
virtual QString name(void) const
static QString typeName(const int t)
The sky coordinates of a point in the sky.
const CachingDms & dec() const
void setDec(dms d)
Sets Dec, the current Declination.
void setRA(dms &r)
Sets RA, the current Right Ascension.
const CachingDms & ra() const
This is a subclass of SkyObject.
QString name(void) const override
If star is unnamed return "star" otherwise return the name.
An angle, stored as degrees, but expressible in many ways.
double radians() const
Express the angle in radians.
virtual void setRadians(const double &Rad)
Set angle according to the argument, in radians.
virtual void setD(const double &x)
Sets floating-point value of angle, in degrees.
char * toString(const EngineQuery &query)
QString name(GameStandardAction id)
QAction * end(const QObject *recvr, const char *slot, QObject *parent)
GeoCoordinates geo(const QVariant &location)
QStringView country(QStringView ifopt)
const QList< QKeySequence > & begin()
KEDUVOCDOCUMENT_EXPORT QStringList comments(const QString &language=QString())
QDate fromString(QStringView string, QStringView format, QCalendar cal)
QString toString(QStringView format, QCalendar cal) const const
QString arg(Args &&... args) const const
const QChar at(qsizetype position) const const
QString & insert(qsizetype position, QChar ch)
QString number(double n, char format, int precision)
QString & remove(QChar ch, Qt::CaseSensitivity cs)
double toDouble(bool *ok) const const
QFuture< void > filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)
QTime fromString(QStringView string, QStringView format)
QString toString(QStringView format) const const