[Marble-commits] KDE/kdeedu/marble/src/lib
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Sun Feb 20 16:55:01 CET 2011
SVN commit 1221815 by beschow:
have the ServerLayouts know the name of their layout mode
* fixes DgmlTextureTagWriter::write(), which improperly took the *Storage*Layout into account
* allows for the factory design pattern (not implemented yet)
M +4 -3 MapWizard.cpp
M +21 -0 ServerLayout.cpp
M +14 -0 ServerLayout.h
M +5 -0 geodata/scene/GeoSceneTexture.cpp
M +2 -1 geodata/scene/GeoSceneTexture.h
M +2 -15 geodata/writers/dgml/DgmlTextureTagWriter.cpp
--- trunk/KDE/kdeedu/marble/src/lib/MapWizard.cpp #1221814:1221815
@@ -14,6 +14,7 @@
#include "global.h"
#include "MarbleDirs.h"
#include "MarbleDebug.h"
+#include "ServerLayout.h"
#include "GeoSceneDocument.h"
#include "GeoSceneHead.h"
#include "GeoSceneIcon.h"
@@ -686,7 +687,6 @@
GeoSceneTexture *texture = new GeoSceneTexture( "map" );
texture->setExpire( 31536000 );
- texture->setStorageLayout( GeoSceneTexture::Marble );
texture->setSourceDir( "earth/" + document->head()->theme() );
if( d->mapProviderType == MapWizardPrivate::WmsMap )
{
@@ -698,7 +698,7 @@
texture->setMaximumTileLevel( 20 );
texture->setLevelZeroRows( 1 );
texture->setLevelZeroColumns( 1 );
- texture->setStorageLayout( GeoSceneTexture::WebMapService );
+ texture->setServerLayout( new WmsServerLayout( texture ) );
texture->setProjection( GeoSceneTexture::Equirectangular );
}
@@ -712,7 +712,7 @@
texture->setMaximumTileLevel( 20 );
texture->setLevelZeroRows( 1 );
texture->setLevelZeroColumns( 1 );
- texture->setStorageLayout( GeoSceneTexture::Custom );
+ texture->setServerLayout( new CustomServerLayout( texture ) );
texture->setProjection( GeoSceneTexture::Mercator );
}
@@ -722,6 +722,7 @@
d->format = image.right( image.length() - image.lastIndexOf( '.' ) - 1 ).toLower();
texture->setFileFormat( d->format.toUpper() );
texture->setInstallMap( document->head()->theme() + "." + d->format );
+ texture->setServerLayout( new MarbleServerLayout( texture ) );
texture->setProjection( GeoSceneTexture::Equirectangular );
int imageWidth = QImage( image ).width();
int tileSize = c_defaultTileSize;
--- trunk/KDE/kdeedu/marble/src/lib/ServerLayout.cpp #1221814:1221815
@@ -52,7 +52,12 @@
return url;
}
+QString MarbleServerLayout::name() const
+{
+ return "Marble";
+}
+
OsmServerLayout::OsmServerLayout( GeoSceneTexture *textureLayer )
: ServerLayout( textureLayer )
{
@@ -72,7 +77,12 @@
return url;
}
+QString OsmServerLayout::name() const
+{
+ return "OpenStreetMap";
+}
+
CustomServerLayout::CustomServerLayout( GeoSceneTexture *texture )
: ServerLayout( texture )
{
@@ -89,6 +99,12 @@
return QUrl( urlStr );
}
+QString CustomServerLayout::name() const
+{
+ return "Custom";
+}
+
+
WmsServerLayout::WmsServerLayout( GeoSceneTexture *texture )
: ServerLayout( texture )
{
@@ -129,6 +145,11 @@
return url;
}
+QString WmsServerLayout::name() const
+{
+ return "WebMapService";
+}
+
qreal WmsServerLayout::latBottom( const Marble::TileId &tileId ) const
{
const qint64 radius = numTilesY( tileId ) / 2;
--- trunk/KDE/kdeedu/marble/src/lib/ServerLayout.h #1221814:1221815
@@ -34,6 +34,12 @@
*/
virtual QUrl downloadUrl( const QUrl &prototypeUrl, const TileId &id ) const = 0;
+ /**
+ * Returns the name of the server layout to be used as the value in the
+ * mode attribute in the DGML file.
+ */
+ virtual QString name() const = 0;
+
protected:
qint64 numTilesX( const Marble::TileId &tileId ) const;
qint64 numTilesY( const Marble::TileId &tileId ) const;
@@ -51,6 +57,8 @@
* Completes the path of the @p prototypeUrl and returns it.
*/
virtual QUrl downloadUrl( const QUrl &prototypeUrl, const TileId & ) const;
+
+ virtual QString name() const;
};
class OsmServerLayout : public ServerLayout
@@ -63,6 +71,8 @@
* the result.
*/
virtual QUrl downloadUrl( const QUrl &prototypeUrl, const TileId & ) const;
+
+ virtual QString name() const;
};
class CustomServerLayout : public ServerLayout
@@ -77,6 +87,8 @@
* Escape sequences are: {zoomLevel}, {x}, and {y}.
*/
virtual QUrl downloadUrl( const QUrl &prototypeUrl, const TileId &id ) const;
+
+ virtual QString name() const;
};
class WmsServerLayout : public ServerLayout
@@ -94,6 +106,8 @@
*/
virtual QUrl downloadUrl( const QUrl &prototypeUrl, const Marble::TileId &tileId ) const;
+ virtual QString name() const;
+
private:
qreal latBottom( const Marble::TileId &tileId ) const;
qreal latTop( const Marble::TileId &tileId ) const;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneTexture.cpp #1221814:1221815
@@ -96,6 +96,11 @@
m_serverLayout = layout;
}
+const ServerLayout* GeoSceneTexture::serverLayout() const
+{
+ return m_serverLayout;
+}
+
int GeoSceneTexture::levelZeroColumns() const
{
return m_levelZeroColumns;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneTexture.h #1221814:1221815
@@ -47,7 +47,7 @@
class GeoSceneTexture : public GeoSceneAbstractDataset
{
public:
- enum StorageLayout { Marble, OpenStreetMap, WebMapService, Custom };
+ enum StorageLayout { Marble, OpenStreetMap };
enum Projection { Equirectangular, Mercator };
explicit GeoSceneTexture( const QString& name );
@@ -64,6 +64,7 @@
void setStorageLayout( const StorageLayout );
void setServerLayout( const ServerLayout * );
+ const ServerLayout *serverLayout() const;
int levelZeroColumns() const;
void setLevelZeroColumns( const int );
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/dgml/DgmlTextureTagWriter.cpp #1221814:1221815
@@ -15,6 +15,7 @@
#include "GeoSceneTexture.h"
#include "DownloadPolicy.h"
#include "DgmlElementDictionary.h"
+#include "ServerLayout.h"
namespace Marble
{
@@ -44,22 +45,8 @@
writer.writeAttribute( "maximumTileLevel", QString::number( texture->maximumTileLevel() ) );
writer.writeAttribute( "levelZeroColumns", QString::number( texture->levelZeroColumns() ) );
writer.writeAttribute( "levelZeroRows", QString::number( texture->levelZeroRows() ) );
- switch( texture->storageLayout() )
- {
- case GeoSceneTexture::Custom:
- writer.writeAttribute( "mode", "Custom" );
- break;
- case GeoSceneTexture::OpenStreetMap:
- writer.writeAttribute( "mode", "OpenStreetMap" );
- break;
- case GeoSceneTexture::WebMapService:
- writer.writeAttribute( "mode", "WebMapService" );
- break;
- case GeoSceneTexture::Marble:
- writer.writeAttribute( "mode", "Marble" );
- break;
+ writer.writeAttribute( "mode", texture->serverLayout()->name() );
}
- }
writer.writeEndElement();
if ( texture->downloadUrls().size() > 0 )
More information about the Marble-commits
mailing list