Marble

DgmlMapTagWriter.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2011 Utku Aydın <utkuaydin34@gmail.com>
4//
5
6#include "DgmlMapTagWriter.h"
7
8#include "DgmlElementDictionary.h"
9#include "GeoSceneLayer.h"
10#include "GeoSceneMap.h"
11#include "GeoSceneTypes.h"
12#include "GeoWriter.h"
13
14#include <QColor>
15
16namespace Marble
17{
18
19static GeoTagWriterRegistrar s_writerMap(GeoTagWriter::QualifiedName(QString::fromLatin1(GeoSceneTypes::GeoSceneMapType),
20 QString::fromLatin1(dgml::dgmlTag_nameSpace20)),
21 new DgmlMapTagWriter());
22
23bool DgmlMapTagWriter::write(const GeoNode *node, GeoWriter &writer) const
24{
25 const auto map = static_cast<const GeoSceneMap *>(node);
26 writer.writeStartElement(QString::fromUtf8(dgml::dgmlTag_Map));
27 writer.writeAttribute("bgcolor", map->backgroundColor().name());
28 writer.writeAttribute("labelColor", map->labelColor().name());
29
30 writer.writeStartElement("canvas");
31 writer.writeEndElement();
32
33 if (!map->center().isEmpty()) {
34 if (map->center().count() == 2) {
35 writer.writeElement(QString::fromLatin1(dgml::dgmlTag_Center),
36 map->center().at(0).toString() + QStringLiteral(",") + map->center().at(1).toString());
37 } else if (map->center().count() == 4) {
38 writer.writeElement(QString::fromLatin1(dgml::dgmlTag_Center),
39 map->center().at(0).toString() + QStringLiteral(",") + map->center().at(1).toString() + QStringLiteral(",")
40 + map->center().at(2).toString() + QStringLiteral(",") + map->center().at(3).toString());
41 }
42 }
43
44 writer.writeStartElement(QString::fromUtf8(dgml::dgmlTag_Target));
45 writer.writeEndElement();
46
47 for (int i = 0; i < map->layers().count(); ++i) {
48 writeElement(map->layers().at(i), writer);
49 }
50
51 writer.writeEndElement();
52 return true;
53}
54
55}
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)
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
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.