Marble

KmlLookAtTagWriter.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2010 Gaurav Gupta <1989.gaurav@googlemail.com>
4// SPDX-FileCopyrightText: 2013 Illya Kovalevskyy <illya.kovalevskyy@gmail.com>
5//
6
7
8#include "KmlLookAtTagWriter.h"
9
10#include "GeoDataLookAt.h"
11#include "GeoDataTypes.h"
12#include "GeoDataTimeSpan.h"
13#include "GeoDataTimeStamp.h"
14#include "GeoWriter.h"
15#include "KmlElementDictionary.h"
16#include "KmlGroundOverlayWriter.h"
17#include "KmlObjectTagWriter.h"
18
19#include <QDateTime>
20
21namespace Marble
22{
23
24static GeoTagWriterRegistrar s_writerLookAt( GeoTagWriter::QualifiedName(GeoDataTypes::GeoDataLookAtType,
25 kml::kmlTag_nameSpaceOgc22),
26 new KmlLookAtTagWriter() );
27
28
29bool KmlLookAtTagWriter::write( const GeoNode *node,
30 GeoWriter& writer ) const
31{
32 const GeoDataLookAt *lookAt = static_cast<const GeoDataLookAt*>(node);
33
34 writer.writeStartElement( kml::kmlTag_LookAt );
35 KmlObjectTagWriter::writeIdentifiers( writer, lookAt );
36
37 if (lookAt->timeStamp().when().isValid()) {
38 writer.writeStartElement("gx:TimeStamp");
39 writer.writeElement("when", lookAt->timeStamp().when().toString(Qt::ISODate));
40 writer.writeEndElement();
41 }
42
43 if( lookAt->timeSpan().isValid() ){
44 writer.writeStartElement("gx:TimeSpan");
45 if (lookAt->timeSpan().begin().when().isValid())
46 writer.writeElement("begin", lookAt->timeSpan().begin().when().toString(Qt::ISODate));
47 if (lookAt->timeSpan().end().when().isValid())
48 writer.writeElement("end", lookAt->timeSpan().end().when().toString(Qt::ISODate));
49 writer.writeEndElement();
50 }
51
52 writer.writeOptionalElement( "longitude", QString::number( lookAt->longitude( GeoDataCoordinates::Degree ), 'f', 10 ) );
53 writer.writeOptionalElement( "latitude", QString::number( lookAt->latitude( GeoDataCoordinates::Degree ), 'f', 10 ) );
54 writer.writeOptionalElement( "altitude", QString::number( lookAt->altitude(), 'f', 10 ) );
55 writer.writeOptionalElement( "range", QString::number( lookAt->range(), 'f', 10 ) );
56 KmlGroundOverlayWriter::writeAltitudeMode( writer, lookAt->altitudeMode() );
57
58 writer.writeEndElement();
59
60 return true;
61}
62
63}
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 Jun 21 2024 12:00:07 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.