Marble

KmlLatLonQuadWriter.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2013 Mayank Madan <[email protected]>
4 //
5 
6 #include "KmlLatLonQuadWriter.h"
7 
8 #include "GeoDataLatLonQuad.h"
9 #include "GeoDataTypes.h"
10 #include "GeoWriter.h"
11 #include "KmlElementDictionary.h"
12 #include "KmlObjectTagWriter.h"
13 
14 namespace Marble
15 {
16 
17 static GeoTagWriterRegistrar s_writerLatLonQuad(
18  GeoTagWriter::QualifiedName( GeoDataTypes::GeoDataLatLonQuadType,
19  kml::kmlTag_nameSpaceOgc22 ),
20  new KmlLatLonQuadWriter );
21 
22 bool KmlLatLonQuadWriter::write( const GeoNode *node,
23  GeoWriter& writer ) const
24 {
25  const GeoDataLatLonQuad *latLonQuad = static_cast<const GeoDataLatLonQuad*>( node );
26 
27  if ( latLonQuad->isValid() ) {
28  writer.writeStartElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_LatLonQuad );
29  KmlObjectTagWriter::writeIdentifiers( writer, latLonQuad );
30 
31  writer.writeStartElement( kml::kmlTag_coordinates );
32 
33  writer.writeCharacters( QString::number( latLonQuad->bottomLeftLongitude( GeoDataCoordinates::Degree ) ) );
34  writer.writeCharacters( QString( ',' ) );
35  writer.writeCharacters( QString::number( latLonQuad->bottomLeftLatitude( GeoDataCoordinates::Degree ) ) );
36  writer.writeCharacters( QString( ' ' ) );
37 
38  writer.writeCharacters( QString::number( latLonQuad->bottomRightLongitude( GeoDataCoordinates::Degree ) ) );
39  writer.writeCharacters( QString( ',' ) );
40  writer.writeCharacters( QString::number( latLonQuad->bottomRightLatitude( GeoDataCoordinates::Degree ) ) );
41  writer.writeCharacters( QString( ' ' ) );
42 
43  writer.writeCharacters( QString::number( latLonQuad->topRightLongitude( GeoDataCoordinates::Degree ) ) );
44  writer.writeCharacters( QString( ',' ) );
45  writer.writeCharacters( QString::number( latLonQuad->topRightLatitude( GeoDataCoordinates::Degree ) ) );
46  writer.writeCharacters( QString( ' ' ) );
47 
48  writer.writeCharacters( QString::number( latLonQuad->topLeftLongitude( GeoDataCoordinates::Degree ) ) );
49  writer.writeCharacters( QString( ',' ) );
50  writer.writeCharacters( QString::number( latLonQuad->topLeftLatitude( GeoDataCoordinates::Degree ) ) );
51 
52  writer.writeEndElement();
53 
54  writer.writeEndElement();
55  }
56 
57  return true;
58 }
59 
60 }
QString number(int n, int base)
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
Definition: GeoTagWriter.h:44
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Oct 2 2023 03:52:08 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.