• 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
KmlFeatureTagWriter.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 2013 Dennis Nienhüser <earthwings@gentoo.org>
9 //
10 
11 #include "KmlFeatureTagWriter.h"
12 
13 #include "GeoDataTypes.h"
14 #include "GeoDataOverlay.h"
15 #include "GeoDataTimeStamp.h"
16 #include "GeoDataTimeSpan.h"
17 #include "GeoDataDocument.h"
18 #include "GeoDataStyle.h"
19 #include "GeoDataStyleMap.h"
20 #include "GeoDataExtendedData.h"
21 #include "GeoDataLookAt.h"
22 #include "GeoDataCamera.h"
23 #include "GeoWriter.h"
24 #include "GeoDataRegion.h"
25 #include "KmlElementDictionary.h"
26 #include "KmlObjectTagWriter.h"
27 
28 namespace Marble
29 {
30 
31 KmlFeatureTagWriter::KmlFeatureTagWriter(const QString &elementName)
32  : m_elementName( elementName )
33 {
34  // nothing to do
35 }
36 
37 bool KmlFeatureTagWriter::write( const Marble::GeoNode *node, GeoWriter &writer ) const
38 {
39  if ( node->nodeType() == GeoDataTypes::GeoDataDocumentType ) {
40  const GeoDataDocument *document = static_cast<const GeoDataDocument*>(node);
41 
42  // when a document has only one feature and no styling
43  // the document tag is excused
44  if( (document->styles().count() == 0)
45  && (document->styleMaps().count() == 0)
46  && (document->extendedData().isEmpty())
47  && (document->featureList().count() == 1) ) {
48  writeElement( document->featureList()[0], writer );
49  return true;
50  }
51  }
52 
53  writer.writeStartElement( m_elementName );
54 
55  GeoDataFeature const *feature = static_cast<const GeoDataFeature*>(node);
56  KmlObjectTagWriter::writeIdentifiers( writer, feature );
57 
58  writer.writeOptionalElement( kml::kmlTag_name, feature->name() );
59  writer.writeOptionalElement( kml::kmlTag_visibility, QString::number( feature->isVisible() ), "1" );
60  writer.writeOptionalElement( "address", feature->address() );
61 
62  if( !feature->description().isEmpty() ) {
63  writer.writeStartElement( "description" );
64  if( feature->descriptionIsCDATA() ) {
65  writer.writeCDATA( feature->description() );
66  } else {
67  writer.writeCharacters( feature->description() );
68  }
69  writer.writeEndElement();
70  }
71 
72  GeoDataLookAt const * lookAt = dynamic_cast<const GeoDataLookAt*>( feature->abstractView() );
73  if ( lookAt ) {
74  writeElement( lookAt, writer );
75  }
76  GeoDataCamera const * camera = dynamic_cast<const GeoDataCamera*>( feature->abstractView() );
77  if ( camera ) {
78  writeElement( camera, writer );
79  }
80 
81  if( feature->timeStamp().when().isValid() ) {
82  writeElement( &feature->timeStamp(), writer );
83  }
84 
85  if( feature->timeSpan().isValid() ) {
86  writeElement( &feature->timeSpan(), writer );
87  }
88 
89  if( !feature->extendedData().isEmpty() ) {
90  writeElement( &feature->extendedData(), writer );
91  }
92 
93  if ( !feature->region().latLonAltBox().isNull() ) {
94  writeElement( &feature->region(), writer );
95  }
96 
97  bool const result = writeMid( node, writer );
98  writer.writeEndElement();
99  return result;
100 }
101 
102 }
GeoDataDocument.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::GeoDataDocument
A container for Features, Styles and in the future Schemas.
Definition: GeoDataDocument.h:65
Marble::kml::kmlTag_visibility
const char * kmlTag_visibility
Definition: KmlElementDictionary.cpp:197
KmlObjectTagWriter.h
Marble::GeoNode::nodeType
virtual const char * nodeType() const
Definition: GeoDocument.cpp:74
Marble::GeoNode
A shared base class for all classes that are mapped to a specific tag (ie.
Definition: GeoDocument.h:60
GeoDataTimeStamp.h
Marble::GeoDataTypes::GeoDataDocumentType
const char * GeoDataDocumentType
Definition: GeoDataTypes.cpp:38
GeoDataStyle.h
Marble::GeoDataFeature::isVisible
bool isVisible() const
Return whether this feature is visible or not.
Definition: GeoDataFeature.cpp:656
Marble::GeoDataFeature::description
QString description() const
Return the text description of the feature.
Definition: GeoDataFeature.cpp:588
Marble::GeoDataCamera
Definition: GeoDataCamera.h:22
GeoDataExtendedData.h
KmlFeatureTagWriter.h
GeoDataTimeSpan.h
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
GeoDataCamera.h
Marble::GeoDataLatLonAltBox::isNull
bool isNull() const
Indicates whether the bounding box only contains a single 2D point ("singularity").
Definition: GeoDataLatLonAltBox.cpp:275
Marble::GeoDataFeature::abstractView
const GeoDataAbstractView * abstractView() const
Get the Abstract view of the feature.
Definition: GeoDataFeature.cpp:610
Marble::GeoDataTimeSpan::isValid
bool isValid() const
Definition: GeoDataTimeSpan.cpp:62
QString::number
QString number(int n, int base)
GeoDataRegion.h
Marble::GeoDataExtendedData::isEmpty
bool isEmpty() const
return wthethe QHash is empty or not
Definition: GeoDataExtendedData.cpp:91
GeoDataLookAt.h
Marble::GeoDataFeature::descriptionIsCDATA
bool descriptionIsCDATA() const
test if the description is CDATA or not CDATA allows for special characters to be included in XML and...
Definition: GeoDataFeature.cpp:599
KmlElementDictionary.h
Marble::GeoDataFeature::timeSpan
const GeoDataTimeSpan & timeSpan() const
Return the timespan of the feature.
Definition: GeoDataFeature.cpp:677
Marble::GeoDataTimeStamp::when
QDateTime when() const
return the when time of timestamp
Definition: GeoDataTimeStamp.cpp:66
Marble::GeoDataFeature::region
GeoDataRegion & region() const
Return the region assigned to the placemark.
Definition: GeoDataFeature.cpp:754
QString::isEmpty
bool isEmpty() const
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
QXmlStreamWriter::writeCDATA
void writeCDATA(const QString &text)
QString
Marble::KmlFeatureTagWriter::writeMid
virtual bool writeMid(const GeoNode *node, GeoWriter &writer) const =0
Marble::GeoDataRegion::latLonAltBox
const GeoDataLatLonAltBox & latLonAltBox() const
Returns a geodesic bounding box ("latLonAltBox") of the region. Returns a geodesic bounding box that ...
Definition: GeoDataRegion.cpp:73
GeoDataStyleMap.h
Marble::KmlFeatureTagWriter::write
bool write(const GeoNode *node, GeoWriter &writer) const
Definition: KmlFeatureTagWriter.cpp:37
Marble::GeoTagWriter::writeElement
bool writeElement(const GeoNode *object, GeoWriter &writer) const
Definition: GeoTagWriter.cpp:29
Marble::GeoDataLookAt
Definition: GeoDataLookAt.h:23
QDateTime::isValid
bool isValid() const
GeoDataOverlay.h
Marble::GeoDataFeature::address
QString address() const
Return the address of the feature.
Definition: GeoDataFeature.cpp:566
Marble::GeoDataFeature
A base class for all geodata features.
Definition: GeoDataFeature.h:57
Marble::GeoDataFeature::name
QString name() const
The name of the feature.
Definition: GeoDataFeature.cpp:544
Marble::GeoDataContainer::featureList
QVector< GeoDataFeature * > featureList() const
A convenience function that returns all features in this container.
Definition: GeoDataContainer.cpp:231
Marble::GeoDataDocument::styles
QList< GeoDataStyle > styles() const
dump a Vector of all styles
Definition: GeoDataDocument.cpp:161
GeoDataTypes.h
Marble::GeoDataFeature::extendedData
GeoDataExtendedData & extendedData() const
Return the ExtendedData assigned to the feature.
Definition: GeoDataFeature.cpp:743
Marble::GeoDataDocument::styleMaps
QList< GeoDataStyleMap > styleMaps() const
dump a Vector of all styles
Definition: GeoDataDocument.cpp:189
Marble::GeoDataFeature::timeStamp
const GeoDataTimeStamp & timeStamp() const
Return the timestamp of the feature.
Definition: GeoDataFeature.cpp:693
Marble::KmlFeatureTagWriter::KmlFeatureTagWriter
KmlFeatureTagWriter(const QString &elementName)
Definition: KmlFeatureTagWriter.cpp:31
Marble::kml::kmlTag_name
const char * kmlTag_name
Definition: KmlElementDictionary.cpp:126
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