Marble

KmlUpdateTagWriter.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2014 Marek Hakala <hakala.marek@gmail.com>
4//
5
6#include "KmlUpdateTagWriter.h"
7#include "GeoDataAbstractView.h"
8#include "GeoDataChange.h"
9#include "GeoDataCreate.h"
10#include "GeoDataDelete.h"
11#include "GeoDataTypes.h"
12#include "GeoDataUpdate.h"
13#include "GeoWriter.h"
14#include "KmlElementDictionary.h"
15#include "KmlObjectTagWriter.h"
16
17namespace Marble
18{
19
20static GeoTagWriterRegistrar s_writerUpdate(GeoTagWriter::QualifiedName(QString::fromLatin1(GeoDataTypes::GeoDataUpdateType),
21 QString::fromLatin1(kml::kmlTag_nameSpaceOgc22)),
22 new KmlUpdateTagWriter);
23
24bool KmlUpdateTagWriter::write(const GeoNode *node, GeoWriter &writer) const
25{
26 const auto update = static_cast<const GeoDataUpdate *>(node);
27 KmlObjectTagWriter::writeIdentifiers(writer, update);
28 writer.writeStartElement(QString::fromUtf8(kml::kmlTag_Update));
29 writer.writeElement(QString::fromLatin1(kml::kmlTag_targetHref), update->targetHref());
30
31 if (update->change() && update->change()->size() > 0) {
32 writer.writeStartElement(QString::fromUtf8(kml::kmlTag_Change));
33 QList<GeoDataFeature *>::ConstIterator it = update->change()->constBegin();
34 QList<GeoDataFeature *>::ConstIterator const end = update->change()->constEnd();
35
36 for (; it != end; ++it) {
37 writeElement(*it, writer);
38 }
39 writer.writeEndElement();
40 } else if (update->create() && update->create()->size() > 0) {
41 writer.writeStartElement(QString::fromUtf8(kml::kmlTag_Create));
42 QList<GeoDataFeature *>::ConstIterator it = update->create()->constBegin();
43 QList<GeoDataFeature *>::ConstIterator const end = update->create()->constEnd();
44
45 for (; it != end; ++it) {
46 writeElement(*it, writer);
47 }
48 writer.writeEndElement();
49 } else if (update->getDelete() && update->getDelete()->size() > 0) {
50 writer.writeStartElement(QString::fromUtf8(kml::kmlTag_Delete));
51 QList<GeoDataFeature *>::ConstIterator it = update->getDelete()->constBegin();
52 QList<GeoDataFeature *>::ConstIterator const end = update->getDelete()->constEnd();
53
54 for (; it != end; ++it) {
55 writeElement(*it, writer);
56 }
57 writer.writeEndElement();
58 }
59
60 writer.writeEndElement();
61 return true;
62}
63
64}
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
void update(Part *part, const QByteArray &data, qint64 dataSize)
QAction * end(const QObject *recvr, const char *slot, QObject *parent)
Binds a QML item to a specific geodetic location in screen coordinates.
QString fromLatin1(QByteArrayView str)
QString fromUtf8(QByteArrayView str)
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.