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

Add configuration option for the maximum tile level.

If maximum tile level is not configured, behaviour is like before,
that is, the autodetection code is used.
For the map themes using this option Marble does not scan the filesystem
for tile level directories repeatedly anymore and also pointless HTTP requests
for non existing tiles are prevented.

Downside of using this option is that new tile levels which might be made
available on tile servers will not be used automatically anymore.

svn path=/trunk/KDE/kdeedu/marble/; revision=1081980
parent 1c29a50c
......@@ -41,6 +41,7 @@
<texture name="clouds_data" expire="10800"><!-- type="texture"-->
<sourcedir format="JPG"> earth/clouds </sourcedir>
<installmap> clouds.jpg </installmap>
<storageLayout maximumTileLevel="1"/>
</texture>
</layer>
......
......@@ -37,6 +37,7 @@
<texture name="citylights_data"><!-- type="texture"-->
<sourcedir format="JPG"> earth/citylights </sourcedir>
<installmap> citylights.jpg </installmap>
<storageLayout maximumTileLevel="3"/>
</texture>
</layer>
......
......@@ -24,7 +24,7 @@
or 604800 seconds -->
<texture name="mapnik_data" expire="604800" >
<sourcedir format="PNG"> earth/openstreetmap </sourcedir>
<storageLayout levelZeroColumns="1" levelZeroRows="1" mode="OpenStreetMap" />
<storageLayout levelZeroColumns="1" levelZeroRows="1" maximumTileLevel="18" mode="OpenStreetMap" />
<projection name="Mercator" />
<downloadUrl protocol="http" host="a.tile.openstreetmap.org" path="/" />
<downloadUrl protocol="http" host="b.tile.openstreetmap.org" path="/" />
......
......@@ -37,6 +37,7 @@
<texture name="precip-dec_data"><!-- type="texture"-->
<sourcedir format="JPG"> earth/precip-dec </sourcedir>
<installmap> precip-dec.jpg </installmap>
<storageLayout maximumTileLevel="1"/>
</texture>
</layer>
......
......@@ -37,6 +37,7 @@
<texture name="precip-july_data"><!-- type="texture"-->
<sourcedir format="JPG"> earth/precip-july </sourcedir>
<installmap> precip-july.jpg </installmap>
<storageLayout maximumTileLevel="1"/>
</texture>
</layer>
......
......@@ -37,6 +37,7 @@
<texture name="schagen1689_data"><!-- type="texture"-->
<sourcedir format="JPG"> earth/schagen1689 </sourcedir>
<installmap> schagen1689.jpg </installmap>
<storageLayout maximumTileLevel="2"/>
</texture>
</layer>
......
......@@ -39,6 +39,7 @@
<texture name="srtm_data"><!-- type="texture"-->
<sourcedir format="JPG"> earth/srtm </sourcedir>
<installmap> srtm.jpg </installmap>
<storageLayout maximumTileLevel="5"/>
</texture>
</layer>
......
......@@ -37,6 +37,7 @@
<texture name="temp-dec_data"><!-- type="texture"-->
<sourcedir format="JPG"> earth/temp-dec </sourcedir>
<installmap> temp-dec.jpg </installmap>
<storageLayout maximumTileLevel="1"/>
</texture>
</layer>
......
......@@ -37,6 +37,7 @@
<texture name="temp-july_data"><!-- type="texture"-->
<sourcedir format="JPG"> earth/temp-july </sourcedir>
<installmap> temp-july.jpg </installmap>
<storageLayout maximumTileLevel="1"/>
</texture>
</layer>
......
......@@ -592,7 +592,7 @@ void AbstractScanlineTextureMapper::notifyMapChanged()
void AbstractScanlineTextureMapper::detectMaxTileLevel()
{
m_maxTileLevel = TileLoader::maxPartialTileLevel( m_tileLoader->layer() ) + 1 ;
m_maxTileLevel = TileLoader::maximumTileLevel( m_tileLoader->layer() );
// mDebug() << "MaxTileLevel: " << m_maxTileLevel;
}
......
......@@ -281,18 +281,23 @@ QList<TileId> TileLoader::tilesOnDisplay() const
return result;
}
int TileLoader::maxPartialTileLevel( GeoSceneLayer * layer )
int TileLoader::maximumTileLevel( GeoSceneLayer * layer )
{
int maxtilelevel = -1;
if ( !layer ) return maxtilelevel;
if ( !layer )
return -1;
GeoSceneTexture * texture = static_cast<GeoSceneTexture *>( layer->groundDataset() );
if ( !texture )
return -1;
if ( !texture ) return maxtilelevel;
// if maximum tile level is configured in the DGML files,
// then use it, otherwise use old detection code.
if ( texture->maximumTileLevel() >= 0 )
return texture->maximumTileLevel();
int maximumTileLevel = -1;
QString tilepath = MarbleDirs::path( TileLoaderHelper::themeStr( texture ) );
// mDebug() << "TileLoader::maxPartialTileLevel tilepath" << tilepath;
// mDebug() << "TileLoader::maxPartialTileLevel tilepath" << tilepath;
QStringList leveldirs = QDir( tilepath ).entryList( QDir::AllDirs | QDir::NoSymLinks
| QDir::NoDotAndDotDot );
......@@ -302,17 +307,15 @@ int TileLoader::maxPartialTileLevel( GeoSceneLayer * layer )
QStringList::const_iterator const end = leveldirs.constEnd();
for (; it != end; ++it ) {
int value = (*it).toInt( &ok, 10 );
if ( ok && value > maxtilelevel )
maxtilelevel = value;
if ( ok && value > maximumTileLevel )
maximumTileLevel = value;
}
// mDebug() << "Detected maximum tile level that contains data: "
// << maxtilelevel;
return maxtilelevel;
// mDebug() << "Detected maximum tile level that contains data: "
// << maxtilelevel;
return maximumTileLevel + 1;
}
bool TileLoader::baseTilesAvailable( GeoSceneLayer * layer )
{
if ( !layer ) return false;
......
......@@ -147,10 +147,10 @@ class TileLoader : public QObject
QList<TileId> tilesOnDisplay() const;
/**
* Returns the highest level in which some tiles are available for the given @p
* texture layer.
* Returns the highest level in which some tiles are theoretically
* available for the given @p texture layer.
*/
static int maxPartialTileLevel( GeoSceneLayer * layer );
static int maximumTileLevel( GeoSceneLayer * layer );
/**
* Returns whether the mandatory most basic tile level is fully available for
......
......@@ -44,6 +44,7 @@ const char* dgmlAttr_labelColor = "labelColor";
const char* dgmlAttr_levelZeroColumns = "levelZeroColumns";
const char* dgmlAttr_levelZeroRows = "levelZeroRows";
const char* dgmlAttr_maximumConnections = "maximumConnections";
const char* dgmlAttr_maximumTileLevel = "maximumTileLevel";
const char* dgmlAttr_mode = "mode";
const char* dgmlAttr_name = "name";
const char* dgmlAttr_password = "password";
......
......@@ -46,6 +46,7 @@ namespace dgml
extern const char* dgmlAttr_levelZeroColumns;
extern const char* dgmlAttr_levelZeroRows;
extern const char* dgmlAttr_maximumConnections;
extern const char* dgmlAttr_maximumTileLevel;
extern const char* dgmlAttr_mode;
extern const char* dgmlAttr_name;
extern const char* dgmlAttr_password;
......
......@@ -53,6 +53,13 @@ GeoNode* DgmlStorageLayoutTagHandler::parse(GeoParser& parser) const
levelZeroRows = levelZeroRowsStr.toInt();
}
// Attribute maximumTileLevel
int maximumTileLevel = -1;
const QString maximumTileLevelStr = parser.attribute( dgmlAttr_maximumTileLevel ).trimmed();
if ( !maximumTileLevelStr.isEmpty() ) {
maximumTileLevel = maximumTileLevelStr.toInt();
}
// Attribute mode
GeoSceneTexture::StorageLayoutMode mode = GeoSceneTexture::Marble;
const QString modeStr = parser.attribute(dgmlAttr_mode).trimmed();
......@@ -72,6 +79,7 @@ GeoNode* DgmlStorageLayoutTagHandler::parse(GeoParser& parser) const
if (parentItem.represents(dgmlTag_Texture)) {
parentItem.nodeAs<GeoSceneTexture>()->setLevelZeroColumns( levelZeroColumns );
parentItem.nodeAs<GeoSceneTexture>()->setLevelZeroRows( levelZeroRows );
parentItem.nodeAs<GeoSceneTexture>()->setMaximumTileLevel( maximumTileLevel );
parentItem.nodeAs<GeoSceneTexture>()->setStorageLayoutMode( mode );
if ( mode == GeoSceneTexture::Custom )
parentItem.nodeAs<GeoSceneTexture>()->setCustomStorageLayout( customLayout );
......
......@@ -36,6 +36,7 @@ GeoSceneTexture::GeoSceneTexture( const QString& name )
m_customStorageLayout( "" ),
m_levelZeroColumns( defaultLevelZeroColumns ),
m_levelZeroRows( defaultLevelZeroRows ),
m_maximumTileLevel( -1 ),
m_projection( Equirectangular ),
m_downloadUrls(),
m_nextUrl( m_downloadUrls.constEnd() )
......@@ -107,6 +108,16 @@ void GeoSceneTexture::setLevelZeroRows( const int rows )
m_levelZeroRows = rows;
}
int GeoSceneTexture::maximumTileLevel() const
{
return m_maximumTileLevel;
}
void GeoSceneTexture::setMaximumTileLevel( const int maximumTileLevel )
{
m_maximumTileLevel = maximumTileLevel;
}
GeoSceneTexture::Projection GeoSceneTexture::projection() const
{
return m_projection;
......
......@@ -66,6 +66,9 @@ class GeoSceneTexture : public GeoSceneAbstractDataset
int levelZeroRows() const;
void setLevelZeroRows( const int );
int maximumTileLevel() const;
void setMaximumTileLevel( const int );
Projection projection() const;
void setProjection( const Projection );
......@@ -90,6 +93,7 @@ class GeoSceneTexture : public GeoSceneAbstractDataset
QString m_customStorageLayout;
int m_levelZeroColumns;
int m_levelZeroRows;
int m_maximumTileLevel;
Projection m_projection;
/// List of Urls which are used in a round robin fashion
......
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