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

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • geodata
  • writers
  • kml
KmlDocumentTagWriter.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 //
10 
11 #include "KmlDocumentTagWriter.h"
12 
13 #include "GeoDocument.h"
14 #include "GeoDataDocument.h"
15 #include "GeoWriter.h"
16 #include "KmlElementDictionary.h"
17 #include "GeoDataStyle.h"
18 #include "GeoDataStyleMap.h"
19 #include "MarbleDebug.h"
20 #include "GeoDataExtendedData.h"
21 #include "GeoDataTimeStamp.h"
22 
23 #include "GeoDataTypes.h"
24 
25 #include <QVector>
26 
27 namespace Marble
28 {
29 
30 static GeoTagWriterRegistrar s_writerDocument( GeoTagWriter::QualifiedName(GeoDataTypes::GeoDataDocumentType,
31  kml::kmlTag_nameSpace22),
32  new KmlDocumentTagWriter() );
33 
34 bool KmlDocumentTagWriter::write( const GeoNode *node, GeoWriter& writer ) const
35 {
36  const GeoDataDocument *document = static_cast<const GeoDataDocument*>(node);
37 
38  // when a document has only one feature and no styling
39  // the document tag is excused
40  if( (document->styles().count() == 0)
41  && (document->styleMaps().count() == 0)
42  && (document->extendedData().isEmpty())
43  && (document->featureList().count() == 1) ) {
44  writeElement( document->featureList()[0], writer );
45  return true;
46  }
47 
48  writer.writeStartElement( kml::kmlTag_Document );
49 
50  foreach( const GeoDataStyle &style, document->styles() ) {
51  writeElement( &style, writer );
52  }
53  foreach( const GeoDataStyleMap &map, document->styleMaps() ) {
54  writeElement( &map, writer );
55  }
56 
57  writer.writeOptionalElement( "name", document->name() );
58  writer.writeElement( kml::kmlTag_visibility, QString::number( document->isVisible() ) );
59  writer.writeOptionalElement( "address", document->address() );
60 
61  QVector<GeoDataFeature*>::ConstIterator it = document->constBegin();
62  QVector<GeoDataFeature*>::ConstIterator const end = document->constEnd();
63 
64  for ( ; it != end; ++it ) {
65  writeElement( &(**it), writer );
66  }
67 
68  if( !document->extendedData().isEmpty() ){
69  writeElement( &document->extendedData(), writer );
70  }
71 
72  if( document->timeStamp().when().isValid() )
73  writeElement( &document->timeStamp(), writer );
74 
75 
76  //Write the actual important stuff!
77  writer.writeEndElement();
78  return true;
79 }
80 
81 }
GeoDataDocument.h
Marble::kml::kmlTag_Document
const char * kmlTag_Document
Definition: KmlElementDictionary.cpp:61
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:64
Marble::GeoDataFeature::timeStamp
GeoDataTimeStamp & timeStamp() const
Return the timestamp of the feature.
Definition: GeoDataFeature.cpp:613
Marble::kml::kmlTag_visibility
const char * kmlTag_visibility
Definition: KmlElementDictionary.cpp:197
Marble::GeoDataContainer::constBegin
QVector< GeoDataFeature * >::ConstIterator constBegin() const
Definition: GeoDataContainer.cpp:234
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:34
GeoDataStyle.h
Marble::GeoDataFeature::isVisible
bool isVisible() const
Return whether this feature is visible or not.
Definition: GeoDataFeature.cpp:581
Marble::GeoDataStyleMap
a class to map different styles to one style
Definition: GeoDataStyleMap.h:38
Marble::kml::kmlTag_nameSpace22
const char * kmlTag_nameSpace22
Definition: KmlElementDictionary.cpp:33
GeoDataExtendedData.h
MarbleDebug.h
Marble::GeoWriter::writeElement
void writeElement(const QString &namespaceUri, const QString &key, const QString &value)
Convenience method to write value with key prefixed format namespaceUri.
Definition: GeoWriter.cpp:84
GeoWriter.h
Marble::KmlDocumentTagWriter::write
virtual bool write(const GeoNode *node, GeoWriter &writer) const
Definition: KmlDocumentTagWriter.cpp:34
Marble::GeoDataStyle
an addressable style group
Definition: GeoDataStyle.h:55
Marble::GeoDataExtendedData::isEmpty
bool isEmpty() const
return wthethe QHash is empty or not
Definition: GeoDataExtendedData.cpp:79
Marble::GeoDataContainer::constEnd
QVector< GeoDataFeature * >::ConstIterator constEnd() const
Definition: GeoDataContainer.cpp:239
KmlElementDictionary.h
Marble::GeoDataTimeStamp::when
QDateTime when() const
return the when time of timestamp
Definition: GeoDataTimeStamp.cpp:53
Marble::GeoWriter
Standard Marble way of writing XML This class is intended to be a standardised way of writing XML for...
Definition: GeoWriter.h:28
GeoDocument.h
Marble::s_writerDocument
static GeoTagWriterRegistrar s_writerDocument(GeoTagWriter::QualifiedName("GeoSceneDocument", dgml::dgmlTag_nameSpace20), new DgmlDocumentTagWriter())
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
GeoDataStyleMap.h
Marble::GeoTagWriter::writeElement
bool writeElement(const GeoNode *object, GeoWriter &writer) const
Definition: GeoTagWriter.cpp:29
Marble::GeoDataFeature::address
QString address() const
Return the address of the feature.
Definition: GeoDataFeature.cpp:491
Marble::GeoDataFeature::name
QString name() const
The name of the feature.
Definition: GeoDataFeature.cpp:480
Marble::GeoDataContainer::featureList
QVector< GeoDataFeature * > featureList() const
A convenience function that returns all features in this container.
Definition: GeoDataContainer.cpp:124
Marble::GeoDataDocument::styles
QList< GeoDataStyle > styles() const
dump a Vector of all styles
Definition: GeoDataDocument.cpp:132
GeoDataTypes.h
Marble::GeoDataFeature::extendedData
GeoDataExtendedData & extendedData() const
Return the ExtendedData assigned to the feature.
Definition: GeoDataFeature.cpp:653
Marble::GeoDataDocument::styleMaps
QList< GeoDataStyleMap > styleMaps() const
dump a Vector of all styles
Definition: GeoDataDocument.cpp:155
KmlDocumentTagWriter.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:50 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
  • kstars
  • libkdeedu
  •   keduvocdocument
  • 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