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 "GeoDataModel.h"
9#include "GeoDataAlias.h"
10#include "GeoDataTypes.h"
11#include "GeoDataLocation.h"
12#include "GeoDataOrientation.h"
13#include "GeoDataResourceMap.h"
14#include "GeoDataScale.h"
15#include "GeoWriter.h"
16#include "KmlGroundOverlayWriter.h"
17#include "KmlLinkTagWriter.h"
18#include "KmlElementDictionary.h"
19#include "KmlObjectTagWriter.h"
20
21namespace Marble
22{
23
24static GeoTagWriterRegistrar s_writerModel(
25 GeoTagWriter::QualifiedName( GeoDataTypes::GeoDataModelType,
26 kml::kmlTag_nameSpaceOgc22 ),
27 new KmlModelTagWriter);
28
29bool KmlModelTagWriter::write( const GeoNode *node, GeoWriter& writer ) const
30{
31 const GeoDataModel *model = static_cast<const GeoDataModel*>( node );
32
33 writer.writeStartElement( kml::kmlTag_Model );
34 KmlObjectTagWriter::writeIdentifiers( writer, model );
35
36 KmlGroundOverlayWriter::writeAltitudeMode( writer, model->altitudeMode());
37
38 const GeoDataLocation location = model->location() ;
39
40 writer.writeStartElement( kml::kmlTag_Location );
41
42 writer.writeOptionalElement( kml::kmlTag_longitude, QString::number( location.longitude( GeoDataCoordinates::Degree ) ), "0" );
43 writer.writeOptionalElement( kml::kmlTag_latitude, QString::number( location.latitude( GeoDataCoordinates::Degree ) ), "0" );
44 writer.writeOptionalElement( kml::kmlTag_altitude, QString::number( location.altitude() ), "0" );
45
46 writer.writeEndElement();
47
48 const GeoDataOrientation orientation = model->orientation();
49
50 writer.writeStartElement( kml::kmlTag_Orientation );
51
52 writer.writeOptionalElement( kml::kmlTag_heading, QString::number( orientation.heading() ), "0" );
53 writer.writeOptionalElement( kml::kmlTag_tilt, QString::number( orientation.tilt() ), "0" );
54 writer.writeOptionalElement( kml::kmlTag_roll, QString::number( orientation.roll() ), "0" );
55
56 writer.writeEndElement();
57
58 const GeoDataScale scale = model->scale() ;
59
60 writer.writeStartElement( kml::kmlTag_Scale );
61
62 writer.writeOptionalElement( kml::kmlTag_x, QString::number( scale.x() ), "1" );
63 writer.writeOptionalElement( kml::kmlTag_y, QString::number( scale.y() ), "1" );
64 writer.writeOptionalElement( kml::kmlTag_z, QString::number( scale.z() ), "1" );
65
66 writer.writeEndElement();
67
68 writeElement( &model->link(), writer );
69
70 const GeoDataResourceMap map = model->resourceMap() ;
71
72 writer.writeStartElement( kml::kmlTag_ResourceMap );
73
74 const GeoDataAlias alias = map.alias() ;
75 writer.writeStartElement( kml::kmlTag_Alias );
76
77 writer.writeTextElement( kml::kmlTag_targetHref, alias.targetHref() );
78 writer.writeTextElement( kml::kmlTag_sourceHref, alias.sourceHref() );
79
80 writer.writeEndElement();
81
82 writer.writeEndElement();
83
84 writer.writeEndElement();
85 return true;
86}
87
88}
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 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 Fri Jun 7 2024 12:03:13 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.