Marble

KmlTrackWriter.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2011 Guillaume Martres <smarter@ubuntu.com>
4//
5
6#include "KmlTrackWriter.h"
7
8#include "GeoDataCoordinates.h"
9#include "GeoDataTrack.h"
10#include "GeoDataTypes.h"
11#include "GeoWriter.h"
12#include "KmlElementDictionary.h"
13#include "KmlObjectTagWriter.h"
14
15#include <QDateTime>
16
17using namespace Marble;
18
19static GeoTagWriterRegistrar s_writerPoint(GeoTagWriter::QualifiedName(QString::fromLatin1(GeoDataTypes::GeoDataTrackType),
20 QString::fromLatin1(kml::kmlTag_nameSpaceOgc22)),
21 new KmlTrackWriter());
22
23bool KmlTrackWriter::write(const GeoNode *node, GeoWriter &writer) const
24{
25 const auto track = static_cast<const GeoDataTrack *>(node);
26
27 writer.writeStartElement("gx:Track");
28 KmlObjectTagWriter::writeIdentifiers(writer, track);
29
30 int points = track->size();
31 for (int i = 0; i < points; i++) {
32 writer.writeElement(QStringLiteral("when"), track->whenList().at(i).toString(Qt::ISODate));
33
34 qreal lon, lat, alt;
35 track->coordinatesList().at(i).geoCoordinates(lon, lat, alt, GeoDataCoordinates::Degree);
36 const QString coord =
37 QString::number(lon, 'f', 10) + QLatin1Char(' ') + QString::number(lat, 'f', 10) + QLatin1Char(' ') + QString::number(alt, 'f', 10);
38
39 writer.writeElement(QStringLiteral("gx:coord"), coord);
40 }
41 writer.writeEndElement();
42
43 return true;
44}
A geometry for tracking objects made of (time, coordinates) pairs.
A shared base class for all classes that are mapped to a specific tag (ie.
Definition GeoDocument.h:35
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
Standard Marble way of writing XML This class is intended to be a standardised way of writing XML for...
Definition GeoWriter.h:26
void writeElement(const QString &namespaceUri, const QString &key, const QString &value)
Convenience method to write <key>value</key> with key prefixed format namespaceUri.
Definition GeoWriter.cpp:75
Binds a QML item to a specific geodetic location in screen coordinates.
QString fromLatin1(QByteArrayView str)
QString number(double n, char format, int precision)
void writeEndElement()
void writeStartElement(QAnyStringView namespaceUri, QAnyStringView name)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:52:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.