[Marble-commits] KDE/kdeedu/marble
Utku Aydın
utkuaydin34 at gmail.com
Sat Jan 8 20:17:30 CET 2011
SVN commit 1212953 by aydin:
Extend GeoWriter so it can write GeoSceneDocuments
M +11 -0 src/lib/geodata/scene/GeoSceneDocument.cpp
M +2 -0 src/lib/geodata/scene/GeoSceneDocument.h
M +5 -0 src/lib/geodata/scene/GeoSceneTexture.cpp
M +1 -0 src/lib/geodata/scene/GeoSceneTexture.h
M +3 -3 src/lib/geodata/writer/GeoWriter.cpp
M +1 -1 src/lib/geodata/writers/dgml/DgmlHeadTagWriter.cpp
M +1 -1 src/lib/geodata/writers/dgml/DgmlHeadTagWriter.h
M +5 -6 src/lib/geodata/writers/dgml/DgmlLayerTagWriter.cpp
M +2 -5 src/lib/geodata/writers/dgml/DgmlMapTagWriter.cpp
M +1 -2 src/lib/geodata/writers/dgml/DgmlTagWriter.cpp
M +1 -1 src/lib/geodata/writers/dgml/DgmlTagWriter.h
M +11 -6 src/lib/geodata/writers/dgml/DgmlTextureTagWriter.cpp
M +29 -3 tests/TestGeoSceneWriter.cpp
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneDocument.cpp #1212952:1212953
@@ -28,6 +28,7 @@
#include "GeoSceneMap.h"
#include "GeoSceneLegend.h"
#include "GeoSceneSettings.h"
+#include "GeoSceneTypes.h"
namespace Marble
{
@@ -51,6 +52,11 @@
delete m_legend;
}
+ const char* nodeType() const
+ {
+ return GeoSceneTypes::GeoSceneDocumentType;
+ }
+
GeoSceneHead* m_head;
GeoSceneMap* m_map;
GeoSceneSettings* m_settings;
@@ -72,6 +78,11 @@
delete d;
}
+const char* GeoSceneDocument::nodeType() const
+{
+ return d->nodeType();
+}
+
const GeoSceneHead* GeoSceneDocument::head() const
{
return d->m_head;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneDocument.h #1212952:1212953
@@ -51,6 +51,8 @@
GeoSceneDocument();
~GeoSceneDocument();
+ virtual const char* nodeType() const;
+
virtual bool isGeoSceneDocument() const { return true; }
const GeoSceneHead* head() const;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneTexture.cpp #1212952:1212953
@@ -55,6 +55,11 @@
delete m_serverLayout;
}
+const char* GeoSceneTexture::nodeType() const
+{
+ return "GeoSceneTexture";
+}
+
QString GeoSceneTexture::sourceDir() const
{
return m_sourceDir;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneTexture.h #1212952:1212953
@@ -52,6 +52,7 @@
explicit GeoSceneTexture( const QString& name );
~GeoSceneTexture();
+ virtual const char* nodeType() const;
QString sourceDir() const;
void setSourceDir( const QString& sourceDir );
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writer/GeoWriter.cpp #1212952:1212953
@@ -42,7 +42,7 @@
GeoNode* node = new GeoNode;
writer->write( node, *this );
} else {
- qDebug() << "There is no GeoWriter registered for: " << name;
+ mDebug() << "There is no GeoWriter registered for: " << name;
return false;
}
@@ -64,12 +64,12 @@
if( writer ) {
if( ! writer->write( object, *this ) ) {
- qDebug() << "An error has been reported by the GeoWriter for: "
+ mDebug() << "An error has been reported by the GeoWriter for: "
<< name;
return false;
}
} else {
- qDebug() << "There is no GeoWriter registered for: " << name;
+ mDebug() << "There is no GeoWriter registered for: " << name;
return true;
}
return true;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/dgml/DgmlHeadTagWriter.cpp #1212952:1212953
@@ -5,7 +5,7 @@
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
-// Copyright 2010 Utku Aydın <utkuaydin34 at gmail.com>
+// Copyright 2011 Utku Aydın <utkuaydin34 at gmail.com>
//
#include "DgmlHeadTagWriter.h"
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/dgml/DgmlHeadTagWriter.h #1212952:1212953
@@ -5,7 +5,7 @@
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
-// Copyright 2010 Utku Aydın <utkuaydin34 at gmail.com>
+// Copyright 2011 Utku Aydın <utkuaydin34 at gmail.com>
//
#ifndef DGMLHEADTAGWRITER_H
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/dgml/DgmlLayerTagWriter.cpp #1212952:1212953
@@ -14,7 +14,6 @@
#include "GeoWriter.h"
#include "GeoSceneLayer.h"
#include "DgmlElementDictionary.h"
-#include <GeoSceneTexture.h>
namespace Marble
{
@@ -28,14 +27,14 @@
{
const GeoSceneLayer *layer = static_cast<const GeoSceneLayer*>( node );
writer.writeStartElement( dgml::dgmlTag_Layer );
+ writer.writeAttribute( "name", layer->name() );
+ writer.writeAttribute( "backend", layer->backend() );
- GeoSceneAbstractDataset** iterator = layer->datasets().begin();
- while( iterator != layer->datasets().end() )
+ for( int i = 0; i < layer->datasets().count(); ++i )
{
- GeoSceneAbstractDataset* dataset = *iterator;
- writeElement( dataset, writer );
- ++iterator;
+ writeElement( layer->datasets().at( i ), writer );
}
+
writer.writeEndElement();
return true;
}
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/dgml/DgmlMapTagWriter.cpp #1212952:1212953
@@ -37,12 +37,9 @@
writer.writeStartElement( "target" );
writer.writeEndElement();
- QVector<GeoSceneLayer*>::ConstIterator iterator = map->layers().constBegin();
- QVector<GeoSceneLayer*>::ConstIterator const end = map->layers().constEnd();
-
- for( ; iterator != end; ++iterator )
+ for( int i = 0; i < map->layers().count(); ++i )
{
- writeElement( &(**iterator), writer );
+ writeElement( map->layers().at( i ), writer );
}
writer.writeEndElement();
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/dgml/DgmlTagWriter.cpp #1212952:1212953
@@ -5,7 +5,7 @@
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
-// Copyright 2009 Andrew Manson <g.real.ate at gmail.com>
+// Copyright 2011 Utku Aydın <utkuaydin34 at gmail.com>
//
#include "DgmlTagWriter.h"
@@ -19,7 +19,6 @@
static GeoTagWriterRegistrar s_writerDgml( GeoTagWriter::QualifiedName( "", dgml::dgmlTag_nameSpace20 ), new DgmlTagWriter() );
-
bool DgmlTagWriter::write( const GeoNode *node, GeoWriter& writer ) const
{
Q_UNUSED(node);
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/dgml/DgmlTagWriter.h #1212952:1212953
@@ -5,7 +5,7 @@
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
-// Copyright 2009 Andrew Manson <g.real.ate at gmail.com>
+// Copyright 2011 Utku Aydın <utkuaydin34 at gmail.com>
//
#ifndef MARBLE_DGMLTAGWRITER_H
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/dgml/DgmlTextureTagWriter.cpp #1212952:1212953
@@ -15,7 +15,6 @@
#include "GeoSceneTexture.h"
#include "DownloadPolicy.h"
#include "DgmlElementDictionary.h"
-#include <TileId.h>
namespace Marble
{
@@ -29,6 +28,8 @@
{
const GeoSceneTexture *texture = static_cast<const GeoSceneTexture*>( node );
writer.writeStartElement( dgml::dgmlTag_Texture );
+ writer.writeAttribute( "name", texture->name() );
+ writer.writeAttribute( "expire", QString::number( texture->expire() ) );
writer.writeStartElement( dgml::dgmlTag_SourceDir );
writer.writeAttribute( "format", texture->fileFormat() );
@@ -38,12 +39,14 @@
writer.writeOptionalElement( "installmap", texture->installMap() );
writer.writeEndElement();
+ writer.writeStartElement( dgml::dgmlTag_StorageLayout );
if( texture->hasMaximumTileLevel() )
{
- writer.writeStartElement( dgml::dgmlTag_StorageLayout );
- writer.writeAttribute( "maximumTileLevel", texture->fileFormat() );
+ writer.writeAttribute( "maximumTileLevel", QString::number( texture->maximumTileLevel() ) );
+ writer.writeAttribute( "levelZeroColumns", QString::number( texture->levelZeroColumns() ) );
+ writer.writeAttribute( "levelZeroRows", QString::number( texture->levelZeroRows() ) );
+ }
writer.writeEndElement();
- }
if ( texture->downloadUrls().size() > 0 )
{
@@ -69,12 +72,14 @@
if( policy->key().usage() == DownloadBrowse )
{
- writer.writeAttribute( "Browse", QString::number( policy->maximumConnections() ) );
+ writer.writeAttribute( "usage", "Browse" );
+ writer.writeAttribute( "maximumConnections", QString::number( policy->maximumConnections() ) );
}
else if( policy->key().usage() == DownloadBulk )
{
- writer.writeAttribute( "Bulk", QString::number( policy->maximumConnections() ) );
+ writer.writeAttribute( "usage", "Bulk" );
+ writer.writeAttribute( "maximumConnections", QString::number( policy->maximumConnections() ) );
}
writer.writeEndElement();
--- trunk/KDE/kdeedu/marble/tests/TestGeoSceneWriter.cpp #1212952:1212953
@@ -16,6 +16,10 @@
#include "GeoSceneDocument.h"
#include "GeoSceneHead.h"
#include "GeoSceneZoom.h"
+#include "GeoSceneIcon.h"
+#include "GeoSceneMap.h"
+#include "GeoSceneLayer.h"
+#include "GeoSceneTexture.h"
#include "GeoWriter.h"
using namespace Marble;
@@ -37,17 +41,39 @@
head->setTheme( "testmap" );
head->setTarget( "earth" );
+ GeoSceneIcon* icon = document->head()->icon();
+ icon->setPixmap( "preview.jpg" );
+
GeoSceneZoom* zoom = document->head()->zoom();
zoom->setMaximum( 1000 );
zoom->setMaximum( 500 );
zoom->setDiscrete( true );
- QTemporaryFile file;
- file.open();
+ GeoSceneTexture* texture = new GeoSceneTexture( "map" );
+ texture->setSourceDir( "earth/testmap" );
+ texture->setFileFormat( "png" );
+ texture->setProjection( GeoSceneTexture::Equirectangular );
+ texture->addDownloadUrl( QUrl( "http://download.kde.org/marble/map/{x}/{y}/{zoomLevel}" ) );
+ texture->addDownloadUrl( QUrl( "http://download.google.com/marble/map/{x}/{y}/{zoomLevel}" ) );
+ texture->addDownloadPolicy( DownloadBrowse, 20 );
+ texture->addDownloadPolicy( DownloadBulk, 20 );
+ texture->setMaximumTileLevel( 15 );
+ texture->setLevelZeroColumns( 2 );
+ texture->setLevelZeroRows( 2 );
+ GeoSceneLayer* layer = new GeoSceneLayer( "testmap" );
+ layer->setBackend( "texture" );
+ layer->addDataset( texture );
+
+ GeoSceneMap* map = document->map();
+ map->addLayer( layer );
+
+ QTemporaryFile tempFile;
+ tempFile.open();
+
GeoWriter writer;
writer.setDocumentType( "http://edu.kde.org/marble/dgml/2.0" );
- QVERIFY( writer.write( &file, head ) );
+ QVERIFY( writer.write( &tempFile, document ) );
}
QTEST_MAIN( TestGeoSceneWriter )
More information about the Marble-commits
mailing list