[Marble-commits] KDE/kdeedu/marble/src/lib
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Sun May 23 21:46:07 CEST 2010
SVN commit 1129801 by beschow:
add LatLonBoxServerLayout
* allows usage of some WMS maps
* supports EPSG:4326 coordinates only
M +23 -0 ServerLayout.cpp
M +12 -0 ServerLayout.h
M +2 -0 geodata/handlers/dgml/DgmlStorageLayoutTagHandler.cpp
--- trunk/KDE/kdeedu/marble/src/lib/ServerLayout.cpp #1129800:1129801
@@ -15,6 +15,8 @@
#include "global.h"
#include "TileId.h"
+#include <math.h>
+
namespace Marble
{
@@ -68,4 +70,25 @@
return QUrl( urlStr );
}
+QUrl LatLonBoxServerLayout::downloadUrl( const QUrl &prototypeUrl, const Marble::TileId &tileId ) const
+{
+ const qint64 radius = ( 1 << ( tileId.zoomLevel() - 1 ) );
+ const qint64 x = tileId.x();
+ const qint64 y = tileId.y();
+
+ const qreal latBottom = atan( sinh( ( radius - y - 1 ) / (double)radius * M_PI ) ) * 180.0 / M_PI;
+ const qreal latTop = atan( sinh( ( radius - y ) / (double)radius * M_PI ) ) * 180.0 / M_PI;
+ const qreal lonLeft = ( x - radius ) / (double)radius * 180.0;
+ const qreal lonRight = ( x - radius + 1 ) / (double)radius * 180.0;
+
+ QString strUrl = prototypeUrl.toString();
+
+ strUrl.replace( "{lonLeft}", QString::number( lonLeft ) );
+ strUrl.replace( "{latBottom}", QString::number( latBottom ) );
+ strUrl.replace( "{lonRight}", QString::number( lonRight ) );
+ strUrl.replace( "{latTop}", QString::number( latTop ) );
+
+ return QUrl::fromEncoded( strUrl.toLatin1() );
}
+
+}
--- trunk/KDE/kdeedu/marble/src/lib/ServerLayout.h #1129800:1129801
@@ -75,6 +75,18 @@
virtual QUrl downloadUrl( const QUrl &prototypeUrl, const TileId &id ) const;
};
+class LatLonBoxServerLayout : public ServerLayout
+{
+public:
+ /**
+ * Replaces escape sequences in the @p prototypeUrl according to the lat-lon box
+ * covered by the given @p tileId and returns the result.
+ *
+ * Escape sequences are: {latTop}, {latBottom}, {lonLeft}, and {lonRight}.
+ */
+ virtual QUrl downloadUrl( const QUrl &prototypeUrl, const Marble::TileId &tileId ) const;
+};
+
}
#endif
--- trunk/KDE/kdeedu/marble/src/lib/geodata/handlers/dgml/DgmlStorageLayoutTagHandler.cpp #1129800:1129801
@@ -74,6 +74,8 @@
serverLayout = new OsmServerLayout( texture );
else if ( modeStr == "Custom" )
serverLayout = new CustomServerLayout();
+ else if ( modeStr == "LatLonBox" )
+ serverLayout = new LatLonBoxServerLayout();
else {
storageLayout = GeoSceneTexture::Marble;
serverLayout = new MarbleServerLayout( texture );
More information about the Marble-commits
mailing list