[Marble-commits] KDE/kdeedu/marble
Andrew Manson
g.real.ate at gmail.com
Sun Aug 9 01:00:15 CEST 2009
SVN commit 1009027 by mansona:
more work on writing the KML. This should now output valid KML but as of
yet does not pass the pedantic unit test
M +2 -2 Mainpage.dox
M +8 -0 src/lib/geodata/writer/GeoTagWriter.cpp
M +2 -0 src/lib/geodata/writer/GeoTagWriter.h
M +17 -0 src/lib/geodata/writer/GeoWriter.cpp
M +7 -0 src/lib/geodata/writers/kml/KmlDocumentTagWriter.cpp
M +20 -1 src/lib/geodata/writers/kml/KmlPlacemarkTagWriter.cpp
A src/lib/geodata/writers/kml/KmlPointTagWriter.cpp [License: LGPL]
A src/lib/geodata/writers/kml/KmlPointTagWriter.h [License: LGPL]
A src/lib/geodata/writers/kml/KmlTagWriter.cpp [License: LGPL]
A src/lib/geodata/writers/kml/KmlTagWriter.h [License: LGPL]
M +1 -1 tests/TestGeoDataWriter.cpp
M +0 -2 tests/data/NewYorkDocument.kml
--- trunk/KDE/kdeedu/marble/Mainpage.dox #1009026:1009027
@@ -45,8 +45,8 @@
tab. This control widget can be used in simpler application where
theming, searching and other advanced controls are not needed.
- at see MarbleWidget
- at see MarbleModel
+ at see Marble::MarbleWidget
+ at see Marble::MarbleModel
@see MarbleControlBox
@see MarbleNavigator
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writer/GeoTagWriter.cpp #1009026:1009027
@@ -11,6 +11,8 @@
#include "GeoTagWriter.h"
+#include "GeoWriter.h"
+
namespace Marble
{
@@ -24,6 +26,12 @@
{
}
+bool GeoTagWriter::writeElement( const GeoDataObject &object,
+ GeoWriter &writer) const
+{
+ return writer.writeElement( object );
+}
+
void GeoTagWriter::registerWriter(const QualifiedName& name,
const GeoTagWriter* writer )
{
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writer/GeoTagWriter.h #1009026:1009027
@@ -50,6 +50,8 @@
GeoTagWriter();
virtual ~GeoTagWriter();
+ bool writeElement( const GeoDataObject& object, GeoWriter& writer ) const;
+
private:
// Only our registrar is allowed to register tag writers.
friend struct GeoTagWriterRegistrar;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writer/GeoWriter.cpp #1009026:1009027
@@ -27,8 +27,22 @@
bool GeoWriter::write(QIODevice* device, const QList<GeoDataFeature> &features)
{
setDevice( device );
+ setAutoFormatting( true );
+
+ writeDTD("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+
//FIXME: write the starting tags. Possibly register a tag handler to do this
// with a null string as the object name?
+ GeoTagWriter::QualifiedName name( "", m_documentType );
+ const GeoTagWriter* writer = GeoTagWriter::recognizes(name);
+ if( writer ) {
+ //FIXME is this too much of a hack?
+ //geodataobject is never used in this context
+ writer->write( GeoDataObject(), *this );
+ } else {
+ qDebug() << "There is no GeoWriter registered for: " << name;
+ return false;
+ }
QListIterator<GeoDataFeature> it(features);
@@ -39,6 +53,9 @@
return false;
}
}
+
+ //close the document
+ writeEndElement();
return true;
}
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/kml/KmlDocumentTagWriter.cpp #1009026:1009027
@@ -17,6 +17,7 @@
#include "GeoDataObject.h"
#include <QtCore/QDebug>
+#include <QtCore/QVector>
namespace Marble
{
@@ -31,6 +32,12 @@
writer.writeStartElement( kml::kmlTag_Document );
+ QVector<GeoDataFeature>::ConstIterator it = document.constBegin();
+
+ for( ; it < document.constEnd(); ++it ) {
+ writeElement( (*it), writer );
+ }
+
//Write the actual important stuff!
writer.writeEndElement();
return true;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/kml/KmlPlacemarkTagWriter.cpp #1009026:1009027
@@ -9,7 +9,9 @@
//
#include "KmlPlacemarkTagWriter.h"
+
#include "KmlElementDictionary.h"
+#include "GeoDataPlacemark.h"
//FIXME:should the GeoDataTypes enum be in the GeoDocument?
#include "GeoDocument.h"
#include "GeoWriter.h"
@@ -28,8 +30,25 @@
bool KmlPlacemarkTagWriter::write( const GeoDataObject &node,
GeoWriter& writer ) const
{
+ const GeoDataPlacemark &placemark = static_cast<const GeoDataPlacemark&>(node);
writer.writeStartElement( kml::kmlTag_Placemark );
- //Write the actual important stuff!
+
+ if( !placemark.name().isEmpty() ) {
+ writer.writeStartElement( "name" );
+ writer.writeCharacters( placemark.name() );
+ writer.writeEndElement();
+ }
+
+ if( !placemark.description().isEmpty() ) {
+ writer.writeStartElement( "description" );
+ writer.writeCharacters( placemark.description() );
+ writer.writeEndElement();
+ }
+
+ if( placemark.geometry() ) {
+ writeElement( *placemark.geometry(), writer );
+ }
+
writer.writeEndElement();
return true;
}
--- trunk/KDE/kdeedu/marble/tests/TestGeoDataWriter.cpp #1009026:1009027
@@ -196,7 +196,7 @@
QTextStream oldFile( &file );
QTextStream newFile( &tempFile );
- QCOMPARE( newFile.readAll(), oldFile.readAll() );
+ QCOMPARE( newFile.readAll().simplified(), oldFile.readAll().simplified() );
}
void TestGeoDataWriter::cleanupTestCase()
--- trunk/KDE/kdeedu/marble/tests/data/NewYorkDocument.kml #1009026:1009027
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
- <name></name>
- <description><![CDATA[]]></description>
<Placemark>
<name>New York City</name>
<description>New York City</description>
More information about the Marble-commits
mailing list