Marble

KmlModelTagWriter.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2013 Sanjiban Bairagya <sanjiban22393@gmail.com>
4//
5
6#include "KmlModelTagWriter.h"
7
8#include "GeoDataAlias.h"
9#include "GeoDataLocation.h"
10#include "GeoDataModel.h"
11#include "GeoDataOrientation.h"
12#include "GeoDataResourceMap.h"
13#include "GeoDataScale.h"
14#include "GeoDataTypes.h"
15#include "GeoWriter.h"
16#include "KmlElementDictionary.h"
17#include "KmlGroundOverlayWriter.h"
18#include "KmlLinkTagWriter.h"
19#include "KmlObjectTagWriter.h"
20
21namespace Marble
22{
23
24static GeoTagWriterRegistrar s_writerModel(GeoTagWriter::QualifiedName(QString::fromLatin1(GeoDataTypes::GeoDataModelType),
25 QString::fromLatin1(kml::kmlTag_nameSpaceOgc22)),
26 new KmlModelTagWriter);
27
28bool KmlModelTagWriter::write(const GeoNode *node, GeoWriter &writer) const
29{
30 const auto model = static_cast<const GeoDataModel *>(node);
31
32 writer.writeStartElement(QString::fromUtf8(kml::kmlTag_Model));
33 KmlObjectTagWriter::writeIdentifiers(writer, model);
34
35 KmlGroundOverlayWriter::writeAltitudeMode(writer, model->altitudeMode());
36
37 const GeoDataLocation location = model->location();
38
39 writer.writeStartElement(QString::fromUtf8(kml::kmlTag_Location));
40
41 writer.writeOptionalElement(QLatin1String(kml::kmlTag_longitude), QString::number(location.longitude(GeoDataCoordinates::Degree)), QStringLiteral("0"));
42 writer.writeOptionalElement(QLatin1String(kml::kmlTag_latitude), QString::number(location.latitude(GeoDataCoordinates::Degree)), QStringLiteral("0"));
43 writer.writeOptionalElement(QLatin1String(kml::kmlTag_altitude), QString::number(location.altitude()), QStringLiteral("0"));
44
45 writer.writeEndElement();
46
47 const GeoDataOrientation orientation = model->orientation();
48
49 writer.writeStartElement(QString::fromUtf8(kml::kmlTag_Orientation));
50
51 writer.writeOptionalElement(QString::fromLatin1(kml::kmlTag_heading), QString::number(orientation.heading()), QStringLiteral("0"));
52 writer.writeOptionalElement(QString::fromLatin1(kml::kmlTag_tilt), QString::number(orientation.tilt()), QStringLiteral("0"));
53 writer.writeOptionalElement(QString::fromLatin1(kml::kmlTag_roll), QString::number(orientation.roll()), QStringLiteral("0"));
54
55 writer.writeEndElement();
56
57 const GeoDataScale scale = model->scale();
58
59 writer.writeStartElement(QString::fromUtf8(kml::kmlTag_Scale));
60
61 writer.writeOptionalElement(QString::fromLatin1(kml::kmlTag_x), QString::number(scale.x()), QStringLiteral("1"));
62 writer.writeOptionalElement(QString::fromLatin1(kml::kmlTag_y), QString::number(scale.y()), QStringLiteral("1"));
63 writer.writeOptionalElement(QString::fromLatin1(kml::kmlTag_z), QString::number(scale.z()), QStringLiteral("1"));
64
65 writer.writeEndElement();
66
67 writeElement(&model->link(), writer);
68
69 const GeoDataResourceMap map = model->resourceMap();
70
71 writer.writeStartElement(QString::fromLatin1(kml::kmlTag_ResourceMap));
72
73 const GeoDataAlias alias = map.alias();
74 writer.writeStartElement(QString::fromLatin1(kml::kmlTag_Alias));
75
76 writer.writeTextElement(QString::fromLatin1(kml::kmlTag_targetHref), alias.targetHref());
77 writer.writeTextElement(QString::fromLatin1(kml::kmlTag_sourceHref), alias.sourceHref());
78
79 writer.writeEndElement();
80
81 writer.writeEndElement();
82
83 writer.writeEndElement();
84 return true;
85}
86
87}
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
QVariant location(const QVariant &res)
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)
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 Sat Dec 21 2024 17:04:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.