[Marble-commits] KDE/kdeedu/marble

Jens-Michael Hoffmann jensmh at gmx.de
Fri Jan 29 14:32:51 CET 2010


SVN commit 1081980 by jmhoffmann:

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.

 M  +1 -0      data/maps/earth/bluemarble/bluemarble.dgml  
 M  +1 -0      data/maps/earth/citylights/citylights.dgml  
 M  +1 -1      data/maps/earth/openstreetmap/openstreetmap.dgml  
 M  +1 -0      data/maps/earth/precip-dec/precip-dec.dgml  
 M  +1 -0      data/maps/earth/precip-july/precip-july.dgml  
 M  +1 -0      data/maps/earth/schagen1689/schagen1689.dgml  
 M  +1 -0      data/maps/earth/srtm/srtm.dgml  
 M  +1 -0      data/maps/earth/temp-dec/temp-dec.dgml  
 M  +1 -0      data/maps/earth/temp-july/temp-july.dgml  
 M  +1 -1      src/lib/AbstractScanlineTextureMapper.cpp  
 M  +16 -13    src/lib/TileLoader.cpp  
 M  +3 -3      src/lib/TileLoader.h  
 M  +1 -0      src/lib/geodata/handlers/dgml/DgmlAttributeDictionary.cpp  
 M  +1 -0      src/lib/geodata/handlers/dgml/DgmlAttributeDictionary.h  
 M  +8 -0      src/lib/geodata/handlers/dgml/DgmlStorageLayoutTagHandler.cpp  
 M  +11 -0     src/lib/geodata/scene/GeoSceneTexture.cpp  
 M  +4 -0      src/lib/geodata/scene/GeoSceneTexture.h  


--- trunk/KDE/kdeedu/marble/data/maps/earth/bluemarble/bluemarble.dgml #1081979:1081980
@@ -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>
                             
--- trunk/KDE/kdeedu/marble/data/maps/earth/citylights/citylights.dgml #1081979:1081980
@@ -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>
                             
--- trunk/KDE/kdeedu/marble/data/maps/earth/openstreetmap/openstreetmap.dgml #1081979:1081980
@@ -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="/" />
--- trunk/KDE/kdeedu/marble/data/maps/earth/precip-dec/precip-dec.dgml #1081979:1081980
@@ -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>
             
--- trunk/KDE/kdeedu/marble/data/maps/earth/precip-july/precip-july.dgml #1081979:1081980
@@ -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>
                     
--- trunk/KDE/kdeedu/marble/data/maps/earth/schagen1689/schagen1689.dgml #1081979:1081980
@@ -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>
 
--- trunk/KDE/kdeedu/marble/data/maps/earth/srtm/srtm.dgml #1081979:1081980
@@ -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>
             
--- trunk/KDE/kdeedu/marble/data/maps/earth/temp-dec/temp-dec.dgml #1081979:1081980
@@ -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>
             
--- trunk/KDE/kdeedu/marble/data/maps/earth/temp-july/temp-july.dgml #1081979:1081980
@@ -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>
             
--- trunk/KDE/kdeedu/marble/src/lib/AbstractScanlineTextureMapper.cpp #1081979:1081980
@@ -592,7 +592,7 @@
 
 void AbstractScanlineTextureMapper::detectMaxTileLevel()
 {
-    m_maxTileLevel = TileLoader::maxPartialTileLevel( m_tileLoader->layer() ) + 1 ;
+    m_maxTileLevel = TileLoader::maximumTileLevel( m_tileLoader->layer() );
 //    mDebug() << "MaxTileLevel: " << m_maxTileLevel;
 }
 
--- trunk/KDE/kdeedu/marble/src/lib/TileLoader.cpp #1081979:1081980
@@ -281,18 +281,23 @@
     return result;
 }
 
-int TileLoader::maxPartialTileLevel( GeoSceneLayer * layer )
+int TileLoader::maximumTileLevel( GeoSceneLayer * layer )
 {
-    int maxtilelevel = -1;
+    if ( !layer )
+        return -1;
 
-    if ( !layer ) return maxtilelevel;
-
     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 @@
     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;
--- trunk/KDE/kdeedu/marble/src/lib/TileLoader.h #1081979:1081980
@@ -147,10 +147,10 @@
         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
--- trunk/KDE/kdeedu/marble/src/lib/geodata/handlers/dgml/DgmlAttributeDictionary.cpp #1081979:1081980
@@ -44,6 +44,7 @@
 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";
--- trunk/KDE/kdeedu/marble/src/lib/geodata/handlers/dgml/DgmlAttributeDictionary.h #1081979:1081980
@@ -46,6 +46,7 @@
     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;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/handlers/dgml/DgmlStorageLayoutTagHandler.cpp #1081979:1081980
@@ -53,6 +53,13 @@
         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 @@
     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 );
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneTexture.cpp #1081979:1081980
@@ -36,6 +36,7 @@
       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 @@
     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;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneTexture.h #1081979:1081980
@@ -66,6 +66,9 @@
     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 @@
     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


More information about the Marble-commits mailing list