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 "GeoDataPhotoOverlay.h"
10#include "GeoDataTypes.h"
11#include "GeoDataImagePyramid.h"
12#include "GeoDataPoint.h"
13#include "GeoDataViewVolume.h"
14#include "GeoWriter.h"
15#include "KmlElementDictionary.h"
16
17namespace Marble
18{
19
20static GeoTagWriterRegistrar s_writerLookAt(
21 GeoTagWriter::QualifiedName( GeoDataTypes::GeoDataPhotoOverlayType,
22 kml::kmlTag_nameSpaceOgc22 ),
23 new KmlPhotoOverlayWriter );
24
25KmlPhotoOverlayWriter::KmlPhotoOverlayWriter() : KmlOverlayTagWriter( 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 GeoDataPhotoOverlay *photo_overlay =
35 static_cast<const GeoDataPhotoOverlay*>( node );
36
37 // rotation
38 QString const rotation = QString::number( photo_overlay->rotation(), 'f', 3 );
39 writer.writeOptionalElement( kml::kmlTag_rotation, rotation, "0.000" );
40
41 // ViewVolume
42 writer.writeStartElement( kml::kmlTag_ViewVolume );
43 writer.writeOptionalElement<qreal>( kml::kmlTag_leftFov, photo_overlay->viewVolume().leftFov(), 0 );
44 writer.writeOptionalElement<qreal>( kml::kmlTag_rightFov, photo_overlay->viewVolume().rightFov(), 0 );
45 writer.writeOptionalElement<qreal>( kml::kmlTag_bottomFov, photo_overlay->viewVolume().bottomFov(), 0 );
46 writer.writeOptionalElement<qreal>( kml::kmlTag_topFov, photo_overlay->viewVolume().topFov(), 0 );
47 writer.writeOptionalElement<qreal>( kml::kmlTag_near, photo_overlay->viewVolume().near(), 0 );
48 writer.writeEndElement();
49
50 // ImagePyramid
51 writer.writeStartElement( kml::kmlTag_ImagePyramid );
52 writer.writeOptionalElement<int>( kml::kmlTag_tileSize, photo_overlay->imagePyramid().tileSize(), 256 );
53 writer.writeOptionalElement<int>( kml::kmlTag_maxWidth, photo_overlay->imagePyramid().maxWidth() );
54 writer.writeOptionalElement<int>( kml::kmlTag_maxHeight, photo_overlay->imagePyramid().maxHeight() );
55
56 switch ( photo_overlay->imagePyramid().gridOrigin() )
57 {
58 case GeoDataImagePyramid::LowerLeft:
59 writer.writeElement( kml::kmlTag_gridOrigin, "lowerLeft" );
60 break;
61 case GeoDataImagePyramid::UpperLeft:
62 writer.writeElement( kml::kmlTag_gridOrigin, "upperLeft" );
63 break;
64 }
65 writer.writeEndElement();
66
67 // Point
68 writeElement( &photo_overlay->point(), writer );
69
70 // shape
71 switch ( photo_overlay->shape() )
72 {
73 case GeoDataPhotoOverlay::Rectangle:
74 break;
75 case GeoDataPhotoOverlay::Cylinder:
76 writer.writeElement( kml::kmlTag_shape, "cylinder" );
77 break;
78 case GeoDataPhotoOverlay::Sphere:
79 writer.writeElement( kml::kmlTag_shape, "sphere" );
80 break;
81 }
82
83 return true;
84}
85
86}
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 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 May 24 2024 11:50:53 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.