Marble

KmlPointTagWriter.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2009 Andrew Manson <g.real.ate@gmail.com>
4// SPDX-FileCopyrightText: 2014 Marek Hakala <hakala.marek@gmail.com>
5//
6
7#include "KmlPointTagWriter.h"
8
9#include "GeoDataPoint.h"
10#include "GeoDataTypes.h"
11#include "GeoWriter.h"
12#include "KmlElementDictionary.h"
13#include "KmlGroundOverlayWriter.h"
14#include "KmlObjectTagWriter.h"
15
16namespace Marble
17{
18
19static GeoTagWriterRegistrar s_writerPoint(GeoTagWriter::QualifiedName(QString::fromLatin1(GeoDataTypes::GeoDataPointType),
20 QString::fromLatin1(kml::kmlTag_nameSpaceOgc22)),
21 new KmlPointTagWriter());
22
23bool KmlPointTagWriter::write(const GeoNode *node, GeoWriter &writer) const
24{
25 const auto point = static_cast<const GeoDataPoint *>(node);
26
27 if (!point->coordinates().isValid()) {
28 return true;
29 }
30
31 writer.writeStartElement(QString::fromUtf8(kml::kmlTag_Point));
32 KmlObjectTagWriter::writeIdentifiers(writer, point);
33 writer.writeOptionalElement(QLatin1String(kml::kmlTag_extrude), QString::number(point->extrude()), QStringLiteral("0"));
34 writer.writeStartElement("coordinates");
35
36 // FIXME: this should be using the GeoDataCoordinates::toString but currently
37 // it is not including the altitude and is adding an extra space after commas
38
39 QString coordinateString = QString::number(point->coordinates().longitude(GeoDataCoordinates::Degree), 'f', 10) + QLatin1Char(',')
40 + QString::number(point->coordinates().latitude(GeoDataCoordinates::Degree), 'f', 10);
41
42 if (point->coordinates().altitude()) {
43 coordinateString += QLatin1Char(',') + QString::number(point->coordinates().altitude(), 'f', 10);
44 }
45
46 writer.writeCharacters(coordinateString);
47 writer.writeEndElement();
48
49 KmlGroundOverlayWriter::writeAltitudeMode(writer, point->altitudeMode());
50
51 writer.writeEndElement();
52
53 return true;
54}
55
56}
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 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.