Commit fdd0a947 authored by Jens-Michael Hoffmann's avatar Jens-Michael Hoffmann
Browse files

Implement round robin algorithm for fetching tiles.

    This was brought up by the OpenStreetMap tile server admins
    and should go into 4.1 as well.


svn path=/trunk/KDE/kdeedu/marble/; revision=832990
parent 3ffa63f7
2008-07-16 Jens-Michael Hoffmann <jensmh@gmx.de>
* src/lib/geodata/handlers/dgml/DgmlDownloadUrlTagHandler.cpp:
* src/lib/geodata/scene/GeoSceneTexture.cpp:
* src/lib/geodata/scene/GeoSceneTexture.h:
* data/maps/earth/openstreetmap/openstreetmap.dgml:
Implement round robin algorithm for fetching tiles.
This was brought up by the OpenStreetMap tile server admins
and should go into 4.1 as well.
2008-07-07 Patrick Spendrin <ps_ml@gmx.de>
* src/lib/geodata/data/GeoDataPoint.{cpp,h}:
......
......@@ -26,7 +26,9 @@
<sourcedir format="PNG"> earth/openstreetmap </sourcedir>
<storageLayout levelZeroColumns="1" levelZeroRows="1" mode="OpenStreetMap" />
<projection name="Mercator" />
<downloadUrl protocol="http" host="tile.openstreetmap.org" path="/" />
<downloadUrl protocol="http" host="a.tile.openstreetmap.org" path="/" />
<downloadUrl protocol="http" host="b.tile.openstreetmap.org" path="/" />
<downloadUrl protocol="http" host="c.tile.openstreetmap.org" path="/" />
</texture>
</layer>
</map>
......
......@@ -78,6 +78,6 @@ GeoNode* DgmlDownloadUrlTagHandler::parse( GeoParser& parser ) const
if ( !pathStr.isEmpty() )
url.setPath( pathStr );
parentItem.nodeAs<GeoSceneTexture>()->setDownloadUrl( url );
parentItem.nodeAs<GeoSceneTexture>()->addDownloadUrl( url );
return 0;
}
......@@ -35,14 +35,13 @@ GeoSceneTexture::GeoSceneTexture( const QString& name )
m_levelZeroColumns( defaultLevelZeroColumns ),
m_levelZeroRows( defaultLevelZeroRows ),
m_projection( Equirectangular ),
m_downloadUrl( "http://download.kde.org/apps/marble/" )
m_downloadUrls(),
m_nextUrl( m_downloadUrls.end() )
{
/* NOOP */
}
GeoSceneTexture::~GeoSceneTexture()
{
/* NOOP */
}
QString GeoSceneTexture::sourceDir() const
......@@ -115,14 +114,25 @@ void GeoSceneTexture::setProjection( const Projection projection )
m_projection = projection;
}
QUrl GeoSceneTexture::downloadUrl() const
QUrl GeoSceneTexture::downloadUrl()
{
return m_downloadUrl;
// default download url
if ( m_downloadUrls.empty() )
return QUrl( "http://download.kde.org/apps/marble/" );
if ( m_nextUrl == m_downloadUrls.end() )
m_nextUrl = m_downloadUrls.begin();
QUrl url = *m_nextUrl;
++m_nextUrl;
return url;
}
void GeoSceneTexture::setDownloadUrl( const QUrl & url )
void GeoSceneTexture::addDownloadUrl( const QUrl & url )
{
m_downloadUrl = url;
m_downloadUrls.append( url );
// FIXME: this could be done only once
m_nextUrl = m_downloadUrls.begin();
}
QString GeoSceneTexture::type()
......
......@@ -61,8 +61,11 @@ class GeoSceneTexture : public GeoSceneAbstractDataset {
Projection projection() const;
void setProjection( const Projection );
QUrl downloadUrl() const;
void setDownloadUrl( const QUrl & );
// this method is a little more than just a stupid getter,
// it implements the round robin for the tile servers.
// on each invocation the next url is returned
QUrl downloadUrl();
void addDownloadUrl( const QUrl & );
virtual QString type();
......@@ -74,7 +77,12 @@ class GeoSceneTexture : public GeoSceneAbstractDataset {
int m_levelZeroColumns;
int m_levelZeroRows;
Projection m_projection;
QUrl m_downloadUrl;
/// List of Urls which are used in a round robin fashion
QVector<QUrl> m_downloadUrls;
/// Points to next Url for the round robin algorithm
QVector<QUrl>::const_iterator m_nextUrl;
};
#endif // GEOSCENETEXTURE_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment