Marble

KmlLookAtTagWriter.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2010 Gaurav Gupta <1989.gaurav@googlemail.com>
4// SPDX-FileCopyrightText: 2013 Illya Kovalevskyy <illya.kovalevskyy@gmail.com>
5//
6
7#include "KmlLookAtTagWriter.h"
8
9#include "GeoDataLookAt.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_writerLookAt(GeoTagWriter::QualifiedName(QString::fromLatin1(GeoDataTypes::GeoDataLookAtType),
24 QString::fromLatin1(kml::kmlTag_nameSpaceOgc22)),
25 new KmlLookAtTagWriter());
26
27bool KmlLookAtTagWriter::write(const GeoNode *node, GeoWriter &writer) const
28{
29 const auto lookAt = static_cast<const GeoDataLookAt *>(node);
30
31 writer.writeStartElement(QString::fromUtf8(kml::kmlTag_LookAt));
32 KmlObjectTagWriter::writeIdentifiers(writer, lookAt);
33
34 if (lookAt->timeStamp().when().isValid()) {
35 writer.writeStartElement("gx:TimeStamp");
36 writer.writeElement(QStringLiteral("when"), lookAt->timeStamp().when().toString(Qt::ISODate));
37 writer.writeEndElement();
38 }
39
40 if (lookAt->timeSpan().isValid()) {
41 writer.writeStartElement("gx:TimeSpan");
42 if (lookAt->timeSpan().begin().when().isValid())
43 writer.writeElement(QStringLiteral("begin"), lookAt->timeSpan().begin().when().toString(Qt::ISODate));
44 if (lookAt->timeSpan().end().when().isValid())
45 writer.writeElement(QStringLiteral("end"), lookAt->timeSpan().end().when().toString(Qt::ISODate));
46 writer.writeEndElement();
47 }
48
49 writer.writeOptionalElement(QStringLiteral("longitude"), QString::number(lookAt->longitude(GeoDataCoordinates::Degree), 'f', 10));
50 writer.writeOptionalElement(QStringLiteral("latitude"), QString::number(lookAt->latitude(GeoDataCoordinates::Degree), 'f', 10));
51 writer.writeOptionalElement(QStringLiteral("altitude"), QString::number(lookAt->altitude(), 'f', 10));
52 writer.writeOptionalElement(QStringLiteral("range"), QString::number(lookAt->range(), 'f', 10));
53 KmlGroundOverlayWriter::writeAltitudeMode(writer, lookAt->altitudeMode());
54
55 writer.writeEndElement();
56
57 return true;
58}
59
60}
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
Binds a QML item to a specific geodetic location in screen coordinates.
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 4 2024 16:37:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.