[Marble-commits] KDE/kdeedu/marble/src/lib
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Sat Jul 10 10:44:34 CEST 2010
SVN commit 1148314 by beschow:
implement WMS support reusing data from the dgml file
M +39 -10 ServerLayout.cpp
M +12 -5 ServerLayout.h
M +2 -2 geodata/handlers/dgml/DgmlStorageLayoutTagHandler.cpp
--- trunk/KDE/kdeedu/marble/src/lib/ServerLayout.cpp #1148313:1148314
@@ -70,25 +70,54 @@
return QUrl( urlStr );
}
-QUrl LatLonBoxServerLayout::downloadUrl( const QUrl &prototypeUrl, const Marble::TileId &tileId ) const
+WmsServerLayout::WmsServerLayout( GeoSceneTexture *texture )
+ : m_textureLayer( texture )
{
+}
+
+QUrl WmsServerLayout::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 latBottom = ( radius - y - 1 ) / (double)radius * 90.0;
+ const qreal latTop = ( radius - y ) / (double)radius * 90.0;
const qreal lonLeft = ( x - radius ) / (double)radius * 180.0;
const qreal lonRight = ( x - radius + 1 ) / (double)radius * 180.0;
- QString strUrl = prototypeUrl.toString();
+ QUrl url = prototypeUrl;
+ url.addQueryItem( "service", "WMS" );
+ url.addQueryItem( "request", "GetMap" );
+ url.addQueryItem( "version", "1.1.1" );
+ if ( !url.hasQueryItem( "styles" ) )
+ url.addQueryItem( "styles", "" );
+ if ( !url.hasQueryItem( "format" ) ) {
+ if ( m_textureLayer->fileFormat().toLower() == "jpg" )
+ url.addQueryItem( "format", "image/jpeg" );
+ else
+ url.addQueryItem( "format", "image/" + m_textureLayer->fileFormat().toLower() );
+ }
+ if ( !url.hasQueryItem( "srs" ) ) {
+ switch ( m_textureLayer->projection() ) {
+ case GeoSceneTexture::Equirectangular:
+ url.addQueryItem( "srs", "EPSG:4326" );
+ break;
+ case GeoSceneTexture::Mercator:
+ url.addQueryItem( "srs", "EPSG:3785" );
+ break;
+ }
+ }
+ if ( !url.hasQueryItem( "layers" ) )
+ 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, 'f', 12 ) )
+ .arg( QString::number( lonRight, 'f', 12 ) )
+ .arg( QString::number( latTop, 'f', 12 ) ) );
- 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() );
+ return url;
}
}
--- trunk/KDE/kdeedu/marble/src/lib/ServerLayout.h #1148313:1148314
@@ -75,18 +75,25 @@
virtual QUrl downloadUrl( const QUrl &prototypeUrl, const TileId &id ) const;
};
-class LatLonBoxServerLayout : public ServerLayout
+class WmsServerLayout : public ServerLayout
{
public:
+ WmsServerLayout( GeoSceneTexture *texture );
+
/**
- * Replaces escape sequences in the @p prototypeUrl according to the lat-lon box
- * covered by the given @p tileId and returns the result.
+ * Adds WMS query items to the @p prototypeUrl and returns the result.
*
- * Escape sequences are: {latTop}, {latBottom}, {lonLeft}, and {lonRight}.
+ * The following items are added: service, request, version, width, height, bbox.
+ *
+ * The following items are only added if they are not already specified in the dgml file:
+ * styles, format, srs, layers.
*/
virtual QUrl downloadUrl( const QUrl &prototypeUrl, const Marble::TileId &tileId ) const;
+
+private:
+ GeoSceneTexture *const m_textureLayer;
};
}
-#endif
+#endif
\ No newline at end of file
--- trunk/KDE/kdeedu/marble/src/lib/geodata/handlers/dgml/DgmlStorageLayoutTagHandler.cpp #1148313:1148314
@@ -74,8 +74,8 @@
serverLayout = new OsmServerLayout( texture );
else if ( modeStr == "Custom" )
serverLayout = new CustomServerLayout();
- else if ( modeStr == "LatLonBox" )
- serverLayout = new LatLonBoxServerLayout();
+ else if ( modeStr == "WebMapService" )
+ serverLayout = new WmsServerLayout( texture );
else {
storageLayout = GeoSceneTexture::Marble;
serverLayout = new MarbleServerLayout( texture );
More information about the Marble-commits
mailing list