• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • geodata
  • writers
  • kml
KmlPointTagWriter.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2009 Andrew Manson <g.real.ate@gmail.com>
9 // Copyright 2014 Marek Hakala <hakala.marek@gmail.com>
10 //
11 
12 #include "KmlPointTagWriter.h"
13 
14 #include "GeoDataPoint.h"
15 #include "GeoDataTypes.h"
16 #include "GeoWriter.h"
17 #include "KmlElementDictionary.h"
18 #include "KmlGroundOverlayWriter.h"
19 #include "KmlObjectTagWriter.h"
20 
21 namespace Marble
22 {
23 
24 static GeoTagWriterRegistrar s_writerPoint( GeoTagWriter::QualifiedName(GeoDataTypes::GeoDataPointType,
25  kml::kmlTag_nameSpaceOgc22),
26  new KmlPointTagWriter() );
27 
28 
29 bool KmlPointTagWriter::write( const GeoNode *node,
30  GeoWriter& writer ) const
31 {
32  const GeoDataPoint *point = static_cast<const GeoDataPoint*>(node);
33 
34  if ( !point->coordinates().isValid() ){
35  return true;
36  }
37 
38  writer.writeStartElement( kml::kmlTag_Point );
39  KmlObjectTagWriter::writeIdentifiers( writer, point );
40  writer.writeOptionalElement( kml::kmlTag_extrude, QString::number( point->extrude() ), "0" );
41  writer.writeStartElement("coordinates");
42 
43  QString coordinateString;
44 
45  //FIXME: this should be using the GeoDataCoordinates::toString but currently
46  // it is not including the altitude and is adding an extra space after commas
47 
48  coordinateString += QString::number( point->coordinates().longitude( GeoDataCoordinates::Degree ), 'f', 10 );
49  coordinateString += ',' ;
50  coordinateString += QString::number( point->coordinates().latitude( GeoDataCoordinates::Degree ) , 'f', 10 );
51 
52  if( point->coordinates().altitude() ) {
53  coordinateString += ',';
54  coordinateString += QString::number( point->coordinates().altitude() , 'f' , 10);
55  }
56 
57  writer.writeCharacters( coordinateString );
58  writer.writeEndElement();
59 
60  KmlGroundOverlayWriter::writeAltitudeMode( writer, point->altitudeMode() );
61 
62  writer.writeEndElement();
63 
64  return true;
65 }
66 
67 }
Marble::GeoDataPoint
A Geometry object representing a 3d point.
Definition: GeoDataPoint.h:47
KmlPointTagWriter.h
Marble::GeoWriter::writeOptionalElement
void writeOptionalElement(const QString &key, const QString &value, const QString &defaultValue=QString())
Convenience method to write value if value is not equal to defaultValue.
Definition: GeoWriter.cpp:98
Marble::KmlGroundOverlayWriter::writeAltitudeMode
static void writeAltitudeMode(GeoWriter &writer, AltitudeMode altitudeMode)
Definition: KmlGroundOverlayWriter.cpp:71
Marble::GeoDataTypes::GeoDataPointType
const char * GeoDataPointType
Definition: GeoDataTypes.cpp:68
Marble::kml::kmlTag_extrude
const char * kmlTag_extrude
Definition: KmlElementDictionary.cpp:68
KmlObjectTagWriter.h
Marble::GeoNode
A shared base class for all classes that are mapped to a specific tag (ie.
Definition: GeoDocument.h:60
Marble::s_writerPoint
static GeoTagWriterRegistrar s_writerPoint(GeoTagWriter::QualifiedName(GeoDataTypes::GeoDataPointType, kml::kmlTag_nameSpaceOgc22), new KmlPointTagWriter())
KmlGroundOverlayWriter.h
Marble::GeoDataCoordinates::latitude
qreal latitude(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
retrieves the latitude of the GeoDataCoordinates object use the unit parameter to switch between Radi...
Definition: GeoDataCoordinates.cpp:751
Marble::GeoDataCoordinates::Degree
Definition: GeoDataCoordinates.h:66
Marble::KmlObjectTagWriter::writeIdentifiers
static void writeIdentifiers(GeoWriter &writer, const GeoDataObject *object)
Parses the id and targetId attributes and assign their values to the given object.
Definition: KmlObjectTagWriter.cpp:15
GeoWriter.h
Marble::GeoDataGeometry::extrude
bool extrude() const
Definition: GeoDataGeometry.cpp:100
Marble::KmlPointTagWriter::write
virtual bool write(const GeoNode *node, GeoWriter &writer) const
Definition: KmlPointTagWriter.cpp:29
Marble::GeoDataCoordinates::altitude
qreal altitude() const
return the altitude of the Point in meters
Definition: GeoDataCoordinates.cpp:1197
QString::number
QString number(int n, int base)
Marble::GeoDataGeometry::altitudeMode
AltitudeMode altitudeMode() const
Definition: GeoDataGeometry.cpp:111
KmlElementDictionary.h
Marble::GeoWriter
Standard Marble way of writing XML This class is intended to be a standardised way of writing XML for...
Definition: GeoWriter.h:29
Marble::GeoTagWriter::QualifiedName
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
Definition: GeoTagWriter.h:48
QString
Marble::kml::kmlTag_nameSpaceOgc22
const char * kmlTag_nameSpaceOgc22
Definition: KmlElementDictionary.cpp:34
Marble::GeoDataCoordinates::longitude
qreal longitude(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
retrieves the longitude of the GeoDataCoordinates object use the unit parameter to switch between Rad...
Definition: GeoDataCoordinates.cpp:739
GeoDataPoint.h
Marble::GeoDataPoint::coordinates
const GeoDataCoordinates & coordinates() const
Definition: GeoDataPoint.cpp:81
GeoDataTypes.h
Marble::GeoDataCoordinates::isValid
bool isValid() const
Returns.
Definition: GeoDataCoordinates.cpp:624
Marble::kml::kmlTag_Point
const char * kmlTag_Point
Definition: KmlElementDictionary.cpp:144
QXmlStreamWriter::writeCharacters
void writeCharacters(const QString &text)
QXmlStreamWriter::writeEndElement
void writeEndElement()
QXmlStreamWriter::writeStartElement
void writeStartElement(const QString &qualifiedName)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal