• 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
  • writer
GeoWriter.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 "GeoWriter.h"
12 
13 #include "GeoTagWriter.h"
14 #include "KmlElementDictionary.h"
15 #include "DgmlElementDictionary.h"
16 
17 #include "MarbleDebug.h"
18 
19 namespace Marble
20 {
21 
22 GeoWriter::GeoWriter()
23 {
24  //FIXME: work out a standard way to do this.
25  m_documentType = kml::kmlTag_nameSpaceOgc22;
26 }
27 
28 bool GeoWriter::write(QIODevice* device, const GeoNode *feature)
29 {
30  setDevice( device );
31  setAutoFormatting( true );
32  writeStartDocument();
33 
34  //FIXME: write the starting tags. Possibly register a tag handler to do this
35  // with a null string as the object name?
36 
37  GeoTagWriter::QualifiedName name( "", m_documentType );
38  const GeoTagWriter* writer = GeoTagWriter::recognizes(name);
39  if( writer ) {
40  //FIXME is this too much of a hack?
41  //geodataobject is never used in this context
42  GeoNode node;
43  writer->write( &node, *this );
44  } else {
45  mDebug() << "There is no GeoWriter registered for: " << name;
46  return false;
47  }
48 
49  if( ! writeElement( feature ) ) {
50  return false;
51  }
52 
53  //close the document
54  writeEndElement();
55  return true;
56 }
57 
58 bool GeoWriter::writeElement(const GeoNode *object)
59 {
60  // Add checks to see that everything is ok here
61 
62  GeoTagWriter::QualifiedName name( object->nodeType(), m_documentType );
63  const GeoTagWriter* writer = GeoTagWriter::recognizes( name );
64 
65  if( writer ) {
66  if( ! writer->write( object, *this ) ) {
67  mDebug() << "An error has been reported by the GeoWriter for: "
68  << name;
69  return false;
70  }
71  } else {
72  mDebug() << "There is no GeoWriter registered for: " << name;
73  return true;
74  }
75  return true;
76 }
77 
78 
79 void GeoWriter::setDocumentType( const QString &documentType )
80 {
81  m_documentType = documentType;
82 }
83 
84 void GeoWriter::writeElement( const QString &namespaceUri, const QString &key, const QString &value )
85 {
86  writeStartElement( namespaceUri, key );
87  writeCharacters( value );
88  writeEndElement();
89 }
90 
91 void GeoWriter::writeElement( const QString &key, const QString &value )
92 {
93  writeStartElement( key );
94  writeCharacters( value );
95  writeEndElement();
96 }
97 
98 void GeoWriter::writeOptionalElement( const QString &key, const QString &value, const QString &defaultValue )
99 {
100  if( value != defaultValue ) {
101  writeElement( key, value );
102  }
103 }
104 
105 }
QIODevice
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
GeoTagWriter.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
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
KmlElementDictionary.h
Marble::GeoTagWriter
Base class intended to be subclassed by specific XML tag writers This class provides a base class tha...
Definition: GeoTagWriter.h:31
DgmlElementDictionary.h
QString
Marble::GeoTagWriter::write
virtual bool write(const GeoNode *node, GeoWriter &writer) const =0
QPair< QString, QString >
Marble::kml::kmlTag_nameSpaceOgc22
const char * kmlTag_nameSpaceOgc22
Definition: KmlElementDictionary.cpp:34
Marble::GeoWriter::setDocumentType
void setDocumentType(const QString &documentType)
Set the current document type.
Definition: GeoWriter.cpp:79
QXmlStreamWriter::setAutoFormatting
void setAutoFormatting(bool enable)
Marble::GeoWriter::GeoWriter
GeoWriter()
Definition: GeoWriter.cpp:22
QXmlStreamWriter::setDevice
void setDevice(QIODevice *device)
Marble::GeoWriter::write
bool write(QIODevice *device, const GeoNode *feature)
The main API call to use the XML writer.
Definition: GeoWriter.cpp:28
QXmlStreamWriter::writeStartDocument
void writeStartDocument()
QXmlStreamWriter::writeCharacters
void writeCharacters(const QString &text)
Marble::mDebug
QDebug mDebug()
a function to replace qDebug() in Marble library code
Definition: MarbleDebug.cpp:36
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:39 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