Marble

KmlPhotoOverlayWriter.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2012 Shou Ya <shouyatf@gmail.com>
4// SPDX-FileCopyrightText: 2012 Dennis Nienhüser <nienhueser@kde.org>
5//
6
7#include "KmlPhotoOverlayWriter.h"
8
9#include "GeoDataImagePyramid.h"
10#include "GeoDataPhotoOverlay.h"
11#include "GeoDataPoint.h"
12#include "GeoDataTypes.h"
13#include "GeoDataViewVolume.h"
14#include "GeoWriter.h"
15#include "KmlElementDictionary.h"
16
17namespace Marble
18{
19
20static GeoTagWriterRegistrar s_writerLookAt(GeoTagWriter::QualifiedName(QString::fromLatin1(GeoDataTypes::GeoDataPhotoOverlayType),
21 QString::fromLatin1(kml::kmlTag_nameSpaceOgc22)),
22 new KmlPhotoOverlayWriter);
23
24KmlPhotoOverlayWriter::KmlPhotoOverlayWriter()
25 : KmlOverlayTagWriter(QString::fromLatin1(kml::kmlTag_PhotoOverlay))
26{
27 // nothing to do
28}
29
30bool KmlPhotoOverlayWriter::writeMid(const GeoNode *node, GeoWriter &writer) const
31{
32 KmlOverlayTagWriter::writeMid(node, writer);
33
34 const auto photo_overlay = static_cast<const GeoDataPhotoOverlay *>(node);
35
36 // rotation
37 QString const rotation = QString::number(photo_overlay->rotation(), 'f', 3);
38 writer.writeOptionalElement(QLatin1String(kml::kmlTag_rotation), rotation, QStringLiteral("0.000"));
39
40 // ViewVolume
41 writer.writeStartElement(QString::fromUtf8(kml::kmlTag_ViewVolume));
42 writer.writeOptionalElement<qreal>(QString::fromLatin1(kml::kmlTag_leftFov), photo_overlay->viewVolume().leftFov(), 0);
43 writer.writeOptionalElement<qreal>(QString::fromLatin1(kml::kmlTag_rightFov), photo_overlay->viewVolume().rightFov(), 0);
44 writer.writeOptionalElement<qreal>(QString::fromLatin1(kml::kmlTag_bottomFov), photo_overlay->viewVolume().bottomFov(), 0);
45 writer.writeOptionalElement<qreal>(QString::fromLatin1(kml::kmlTag_topFov), photo_overlay->viewVolume().topFov(), 0);
46 writer.writeOptionalElement<qreal>(QString::fromLatin1(kml::kmlTag_near), photo_overlay->viewVolume().near(), 0);
47 writer.writeEndElement();
48
49 // ImagePyramid
50 writer.writeStartElement(QString::fromUtf8(kml::kmlTag_ImagePyramid));
51 writer.writeOptionalElement<int>(QString::fromLatin1(kml::kmlTag_tileSize), photo_overlay->imagePyramid().tileSize(), 256);
52 writer.writeOptionalElement<int>(QString::fromLatin1(kml::kmlTag_maxWidth), photo_overlay->imagePyramid().maxWidth());
53 writer.writeOptionalElement<int>(QString::fromLatin1(kml::kmlTag_maxHeight), photo_overlay->imagePyramid().maxHeight());
54
55 switch (photo_overlay->imagePyramid().gridOrigin()) {
56 case GeoDataImagePyramid::LowerLeft:
57 writer.writeElement(QString::fromLatin1(kml::kmlTag_gridOrigin), QStringLiteral("lowerLeft"));
58 break;
59 case GeoDataImagePyramid::UpperLeft:
60 writer.writeElement(QString::fromLatin1(kml::kmlTag_gridOrigin), QStringLiteral("upperLeft"));
61 break;
62 }
63 writer.writeEndElement();
64
65 // Point
66 writeElement(&photo_overlay->point(), writer);
67
68 // shape
69 switch (photo_overlay->shape()) {
70 case GeoDataPhotoOverlay::Rectangle:
71 break;
72 case GeoDataPhotoOverlay::Cylinder:
73 writer.writeElement(QString::fromLatin1(kml::kmlTag_shape), QStringLiteral("cylinder"));
74 break;
75 case GeoDataPhotoOverlay::Sphere:
76 writer.writeElement(QString::fromLatin1(kml::kmlTag_shape), QStringLiteral("sphere"));
77 break;
78 }
79
80 return true;
81}
82
83}
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 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.