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(GeoDataTypes::GeoDataTrackType,
20 kml::kmlTag_nameSpaceOgc22),
21 new KmlTrackWriter() );
22
23bool KmlTrackWriter::write( const GeoNode *node, GeoWriter &writer ) const
24{
25 const GeoDataTrack *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( "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 = QString::number(lon, 'f', 10) + QLatin1Char(' ') +
37 QString::number(lat, 'f', 10) + QLatin1Char(' ') +
38 QString::number(alt, 'f', 10);
39
40 writer.writeElement( "gx:coord", coord );
41 }
42 writer.writeEndElement();
43
44 return true;
45}
A geometry for tracking objects made of (time, coordinates) pairs.
int size() const
Returns the number of points in the track.
QVector< GeoDataCoordinates > coordinatesList() const
Returns the coordinates of all the points in the map, sorted by their time value.
QVector< QDateTime > whenList() const
Returns the time value of all the points in the map, in chronological order.
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:78
Binds a QML item to a specific geodetic location in screen coordinates.
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 Jun 14 2024 11:54:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.