[Marble-commits] KDE/kdeedu/marble/src
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Sun Aug 29 21:40:24 CEST 2010
SVN commit 1169605 by beschow:
use AbstractProjection in WMSServerLayout
M +46 -21 lib/ServerLayout.cpp
M +3 -2 lib/ServerLayout.h
M +0 -4 tilecreator/CMakeLists.txt
--- trunk/KDE/kdeedu/marble/src/lib/ServerLayout.cpp #1169604:1169605
@@ -12,6 +12,8 @@
#include "ServerLayout.h"
#include "GeoSceneTexture.h"
+#include "EquirectProjection.h"
+#include "MercatorProjection.h"
#include "global.h"
#include "TileId.h"
@@ -96,12 +98,9 @@
QUrl WmsServerLayout::downloadUrl( const QUrl &prototypeUrl, const Marble::TileId &tileId ) const
{
- const qint64 radius = numTilesX( tileId ) / 2;
- const qint64 x = tileId.x();
+ const QPointF bottomLeft = this->bottomLeft( tileId );
+ const QPointF topRight = this->topRight( tileId );
- const qreal lonLeft = ( x - radius ) / (double)radius * 180.0;
- const qreal lonRight = ( x - radius + 1 ) / (double)radius * 180.0;
-
QUrl url = prototypeUrl;
url.addQueryItem( "service", "WMS" );
url.addQueryItem( "request", "GetMap" );
@@ -121,44 +120,70 @@
url.addQueryItem( "layers", m_textureLayer->name() );
url.addQueryItem( "width", QString::number( m_textureLayer->tileSize().width() ) );
url.addQueryItem( "height", QString::number( m_textureLayer->tileSize().height() ) );
- url.addQueryItem( "bbox", QString( "%1,%2,%3,%4" ).arg( QString::number( lonLeft, 'f', 12 ) )
- .arg( QString::number( latBottom( tileId ), 'f', 12 ) )
- .arg( QString::number( lonRight, 'f', 12 ) )
- .arg( QString::number( latTop( tileId ), 'f', 12 ) ) );
+ url.addQueryItem( "bbox", QString( "%1,%2,%3,%4" ).arg( QString::number( bottomLeft.x(), 'f', 14 ) )
+ .arg( QString::number( bottomLeft.y(), 'f', 14 ) )
+ .arg( QString::number( topRight.x(), 'f', 14 ) )
+ .arg( QString::number( topRight.y(), 'f', 14 ) ) );
return url;
}
-qreal WmsServerLayout::latBottom( const Marble::TileId &tileId ) const
+QPointF WmsServerLayout::bottomLeft( const Marble::TileId &tileId ) const
{
- const qint64 radius = numTilesY( tileId ) / 2;
+ static const EquirectProjection equirectangular;
+ static const MercatorProjection mercator;
+ const AbstractProjection *projection = 0;
+
switch( m_textureLayer->projection() )
{
case GeoSceneTexture::Equirectangular:
- return ( radius - tileId.y() - 1 ) / (double)radius * 90.0;
+ projection = &equirectangular;
+ break;
case GeoSceneTexture::Mercator:
- return atan( sinh( ( radius - tileId.y() - 1 ) / (double)radius * M_PI ) ) * 180.0 / M_PI;
+ projection = &mercator;
+ break;
}
- Q_ASSERT( false ); // not reached
- return 0.0;
+ Q_ASSERT( projection != 0 );
+
+ const qreal x = ( tileId.x() ) / (qreal)numTilesX( tileId );
+ const qreal y = ( tileId.y() + 1 ) / (qreal)numTilesY( tileId );
+
+ qreal lon;
+ qreal lat;
+ projection->geoCoordinates( x, y, lon, lat, GeoDataCoordinates::Degree );
+
+ return QPointF( lon, lat );
}
-qreal WmsServerLayout::latTop( const Marble::TileId &tileId ) const
+QPointF WmsServerLayout::topRight( const Marble::TileId &tileId ) const
{
- const qint64 radius = numTilesY( tileId ) / 2;
+ static const EquirectProjection equirectangular;
+ static const MercatorProjection mercator;
+ const AbstractProjection *projection = 0;
+
switch( m_textureLayer->projection() )
{
case GeoSceneTexture::Equirectangular:
- return ( radius - tileId.y() ) / (double)radius * 90.0;
+ projection = &equirectangular;
+ break;
case GeoSceneTexture::Mercator:
- return atan( sinh( ( radius - tileId.y() ) / (double)radius * M_PI ) ) * 180.0 / M_PI;
+ projection = &mercator;
+ break;
}
- Q_ASSERT( false ); // not reached
- return 0.0;
+ Q_ASSERT( projection != 0 );
+
+ const qreal x = ( tileId.x() + 1 ) / (qreal)numTilesX( tileId );
+ const qreal y = ( tileId.y() ) / (qreal)numTilesY( tileId );
+
+ qreal lon;
+ qreal lat;
+ projection->geoCoordinates( x, y, lon, lat, GeoDataCoordinates::Degree );
+
+ return QPointF( lon, lat );
}
QString WmsServerLayout::epsgCode() const
--- trunk/KDE/kdeedu/marble/src/lib/ServerLayout.h #1169604:1169605
@@ -12,6 +12,7 @@
#define MARBLE_SERVERLAYOUT_H
#include <QtCore/QUrl>
+#include <QtCore/QPointF>
namespace Marble
{
@@ -95,8 +96,8 @@
virtual QUrl downloadUrl( const QUrl &prototypeUrl, const Marble::TileId &tileId ) const;
private:
- qreal latBottom( const Marble::TileId &tileId ) const;
- qreal latTop( const Marble::TileId &tileId ) const;
+ QPointF bottomLeft( const Marble::TileId &tileId ) const;
+ QPointF topRight( const Marble::TileId &tileId ) const;
QString epsgCode() const;
};
--- trunk/KDE/kdeedu/marble/src/tilecreator/CMakeLists.txt #1169604:1169605
@@ -11,10 +11,6 @@
../lib/TileCreator.cpp
../lib/TileId.cpp
../lib/TileLoaderHelper.cpp
- ../lib/ServerLayout.cpp
- ../lib/geodata/parser/GeoDocument.cpp
- ../lib/geodata/scene/GeoSceneTexture.cpp
- ../lib/geodata/scene/GeoSceneLayer.cpp
../lib/MarbleDirs.cpp
../lib/MarbleDebug.cpp
main.cpp
More information about the Marble-commits
mailing list