Marble

KmlCameraTagWriter.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2013 Mayank Madan <maddiemadan@gmail.com>
4// SPDX-FileCopyrightText: 2013 Illya Kovalevskyy <illya.kovalevskyy@gmail.com>
5//
6
7
8#include "KmlCameraTagWriter.h"
9
10#include "GeoDataCamera.h"
11#include "GeoDataTypes.h"
12#include "GeoDataTimeSpan.h"
13#include "GeoDataTimeStamp.h"
14#include "GeoWriter.h"
15#include "KmlGroundOverlayWriter.h"
16#include "KmlElementDictionary.h"
17#include "KmlObjectTagWriter.h"
18
19#include <QDateTime>
20
21namespace Marble
22{
23
24static GeoTagWriterRegistrar s_writerCamera( GeoTagWriter::QualifiedName(GeoDataTypes::GeoDataCameraType,
25 kml::kmlTag_nameSpaceOgc22),
26 new KmlCameraTagWriter() );
27
28
29bool KmlCameraTagWriter::write( const GeoNode *node, GeoWriter& writer ) const
30{
31 const GeoDataCamera *camera = static_cast<const GeoDataCamera*>(node);
32
33 writer.writeStartElement( kml::kmlTag_Camera );
34 KmlObjectTagWriter::writeIdentifiers( writer, camera );
35
36 if (camera->timeStamp().when().isValid()) {
37 writer.writeStartElement("gx:TimeStamp");
38 writer.writeElement("when", camera->timeStamp().when().toString(Qt::ISODate));
39 writer.writeEndElement();
40 }
41
42 if (camera->timeSpan().isValid()) {
43 writer.writeStartElement("gx:TimeSpan");
44 if (camera->timeSpan().begin().when().isValid())
45 writer.writeElement("begin", camera->timeSpan().begin().when().toString(Qt::ISODate));
46 if (camera->timeSpan().end().when().isValid())
47 writer.writeElement("end", camera->timeSpan().end().when().toString(Qt::ISODate));
48 writer.writeEndElement();
49 }
50
51 if ( camera->longitude() != 0.0 ) {
52 writer.writeElement( "longitude", QString::number( camera->longitude( GeoDataCoordinates::Degree ), 'f', 10 ) );
53 }
54 if ( camera->latitude() != 0.0 ) {
55 writer.writeElement( "latitude", QString::number( camera->latitude( GeoDataCoordinates::Degree ), 'f', 10 ) );
56 }
57 writer.writeOptionalElement( "altitude", camera->altitude() );
58 writer.writeOptionalElement( "roll", camera->roll() );
59 writer.writeOptionalElement( "tilt", camera->tilt() );
60 writer.writeOptionalElement( "heading", camera->heading() );
61 KmlGroundOverlayWriter::writeAltitudeMode( writer, camera->altitudeMode() );
62
63 writer.writeEndElement();
64
65 return true;
66}
67
68}
69
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
Q_SCRIPTABLE QString camera()
Binds a QML item to a specific geodetic location in screen coordinates.
iterator begin()
iterator end()
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 Jun 14 2024 11:54:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.