Marble

KmlPointTagWriter.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2009 Andrew Manson <[email protected]>
4 // SPDX-FileCopyrightText: 2014 Marek Hakala <[email protected]>
5 //
6 
7 #include "KmlPointTagWriter.h"
8 
9 #include "GeoDataPoint.h"
10 #include "GeoDataTypes.h"
11 #include "GeoWriter.h"
12 #include "KmlElementDictionary.h"
13 #include "KmlGroundOverlayWriter.h"
14 #include "KmlObjectTagWriter.h"
15 
16 namespace Marble
17 {
18 
19 static GeoTagWriterRegistrar s_writerPoint( GeoTagWriter::QualifiedName(GeoDataTypes::GeoDataPointType,
20  kml::kmlTag_nameSpaceOgc22),
21  new KmlPointTagWriter() );
22 
23 
24 bool KmlPointTagWriter::write( const GeoNode *node,
25  GeoWriter& writer ) const
26 {
27  const GeoDataPoint *point = static_cast<const GeoDataPoint*>(node);
28 
29  if ( !point->coordinates().isValid() ){
30  return true;
31  }
32 
33  writer.writeStartElement( kml::kmlTag_Point );
34  KmlObjectTagWriter::writeIdentifiers( writer, point );
35  writer.writeOptionalElement( kml::kmlTag_extrude, QString::number( point->extrude() ), "0" );
36  writer.writeStartElement("coordinates");
37 
38  //FIXME: this should be using the GeoDataCoordinates::toString but currently
39  // it is not including the altitude and is adding an extra space after commas
40 
41  QString coordinateString =
42  QString::number(point->coordinates().longitude(GeoDataCoordinates::Degree), 'f', 10) +
43  QLatin1Char(',') +
44  QString::number(point->coordinates().latitude(GeoDataCoordinates::Degree) , 'f', 10);
45 
46  if( point->coordinates().altitude() ) {
47  coordinateString += QLatin1Char(',') + QString::number( point->coordinates().altitude() , 'f' , 10);
48  }
49 
50  writer.writeCharacters( coordinateString );
51  writer.writeEndElement();
52 
53  KmlGroundOverlayWriter::writeAltitudeMode( writer, point->altitudeMode() );
54 
55  writer.writeEndElement();
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.