Marble

KmlCameraTagWriter.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2013 Mayank Madan <maddiemadan@gmail.com>
4// SPDX-FileCopyrightText: 2013 Illya Kovalevskyy <illya.kovalevskyy@gmail.com>
5//
6
7#include "KmlCameraTagWriter.h"
8
9#include "GeoDataCamera.h"
10#include "GeoDataTimeSpan.h"
11#include "GeoDataTimeStamp.h"
12#include "GeoDataTypes.h"
13#include "GeoWriter.h"
14#include "KmlElementDictionary.h"
15#include "KmlGroundOverlayWriter.h"
16#include "KmlObjectTagWriter.h"
17
18#include <QDateTime>
19
20namespace Marble
21{
22
23static GeoTagWriterRegistrar s_writerCamera(GeoTagWriter::QualifiedName(QString::fromLatin1(GeoDataTypes::GeoDataCameraType),
24 QString::fromLatin1(kml::kmlTag_nameSpaceOgc22)),
25 new KmlCameraTagWriter());
26
27bool KmlCameraTagWriter::write(const GeoNode *node, GeoWriter &writer) const
28{
29 const auto camera = static_cast<const GeoDataCamera *>(node);
30
31 writer.writeStartElement(QString::fromUtf8(kml::kmlTag_Camera));
32 KmlObjectTagWriter::writeIdentifiers(writer, camera);
33
34 if (camera->timeStamp().when().isValid()) {
35 writer.writeStartElement("gx:TimeStamp");
36 writer.writeElement(QStringLiteral("when"), camera->timeStamp().when().toString(Qt::ISODate));
37 writer.writeEndElement();
38 }
39
40 if (camera->timeSpan().isValid()) {
41 writer.writeStartElement("gx:TimeSpan");
42 if (camera->timeSpan().begin().when().isValid())
43 writer.writeElement(QStringLiteral("begin"), camera->timeSpan().begin().when().toString(Qt::ISODate));
44 if (camera->timeSpan().end().when().isValid())
45 writer.writeElement(QStringLiteral("end"), camera->timeSpan().end().when().toString(Qt::ISODate));
46 writer.writeEndElement();
47 }
48
49 if (camera->longitude() != 0.0) {
50 writer.writeElement(QStringLiteral("longitude"), QString::number(camera->longitude(GeoDataCoordinates::Degree), 'f', 10));
51 }
52 if (camera->latitude() != 0.0) {
53 writer.writeElement(QStringLiteral("latitude"), QString::number(camera->latitude(GeoDataCoordinates::Degree), 'f', 10));
54 }
55 writer.writeOptionalElement(QStringLiteral("altitude"), camera->altitude());
56 writer.writeOptionalElement(QStringLiteral("roll"), camera->roll());
57 writer.writeOptionalElement(QStringLiteral("tilt"), camera->tilt());
58 writer.writeOptionalElement(QStringLiteral("heading"), camera->heading());
59 KmlGroundOverlayWriter::writeAltitudeMode(writer, camera->altitudeMode());
60
61 writer.writeEndElement();
62
63 return true;
64}
65
66}
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
Q_SCRIPTABLE QString camera()
Binds a QML item to a specific geodetic location in screen coordinates.
iterator begin()
iterator end()
QString fromLatin1(QByteArrayView str)
QString fromUtf8(QByteArrayView str)
QString number(double n, char format, int precision)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.