[QGIS Commit] r15221 - in branches/raster-providers/src: core core/raster providers/gdal

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Feb 20 11:37:25 EST 2011


Author: rblazek
Date: 2011-02-20 08:37:25 -0800 (Sun, 20 Feb 2011)
New Revision: 15221

Modified:
   branches/raster-providers/src/core/qgsrasterdataprovider.h
   branches/raster-providers/src/core/raster/qgsrasterlayer.cpp
   branches/raster-providers/src/providers/gdal/qgsgdalprovider.cpp
   branches/raster-providers/src/providers/gdal/qgsgdalprovider.h
Log:
avoid not necessary raster stats calc (paleted) but others broken (sigle gray); band index fix

Modified: branches/raster-providers/src/core/qgsrasterdataprovider.h
===================================================================
--- branches/raster-providers/src/core/qgsrasterdataprovider.h	2011-02-20 16:33:08 UTC (rev 15220)
+++ branches/raster-providers/src/core/qgsrasterdataprovider.h	2011-02-20 16:37:25 UTC (rev 15221)
@@ -462,7 +462,7 @@
     @note: this member has been added in version 1.2*/
     int mDpi;
 
-    /** \brief Cell value representing no data. e.g. -9999  */
+    /** \brief Cell value representing no data. e.g. -9999, indexed from 1  */
     QList<double> mNoDataValue;
 
     /** \brief Flag indicating if the nodatavalue is valid*/

Modified: branches/raster-providers/src/core/raster/qgsrasterlayer.cpp
===================================================================
--- branches/raster-providers/src/core/raster/qgsrasterlayer.cpp	2011-02-20 16:33:08 UTC (rev 15220)
+++ branches/raster-providers/src/core/raster/qgsrasterlayer.cpp	2011-02-20 16:37:25 UTC (rev 15221)
@@ -2605,7 +2605,9 @@
   //TODO hasBand is really obsolete and only used in the Palette instance, change to new function hasPalette(int)
   //else if ( hasBand( "Palette" ) ) //don't tr() this its a gdal word!
   // not sure if is worth to add colorTable capability - CT can be empty in any case
-  else if ( bandStatistics(1).colorTable.count() > 0 )  
+  // Calc bandStatistics is very slow!!!
+  //else if ( bandStatistics(1).colorTable.count() > 0 )  
+  else if ( mDataProvider->colorInterpretation(1) == QgsRasterDataProvider::PaletteIndex )
   {
     mRasterType = Palette;
   }

Modified: branches/raster-providers/src/providers/gdal/qgsgdalprovider.cpp
===================================================================
--- branches/raster-providers/src/providers/gdal/qgsgdalprovider.cpp	2011-02-20 16:33:08 UTC (rev 15220)
+++ branches/raster-providers/src/providers/gdal/qgsgdalprovider.cpp	2011-02-20 16:37:25 UTC (rev 15221)
@@ -256,7 +256,9 @@
   // Determine the nodata value and data type
   //
   mValidNoDataValue = true;
-  for ( int i = 0; i < GDALGetRasterCount( mGdalBaseDataset ); i++ )
+  mGdalDataType.append( 0 ); // not used index
+  mNoDataValue.append( 0 ); // not used index
+  for ( int i = 1; i <= GDALGetRasterCount( mGdalBaseDataset ); i++ )
   {
     GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, i );
     GDALDataType myGdalDataType = GDALGetRasterDataType( myGdalBand );
@@ -703,8 +705,8 @@
 }
 
 double  QgsGdalProvider::noDataValue() const {
-  if ( mNoDataValue.size () > 0 ) {
-    return mNoDataValue[0];
+  if ( mNoDataValue.size () > 1 ) {
+    return mNoDataValue[1];
   }
   return std::numeric_limits<int>::max(); // should not happen or be used
 }

Modified: branches/raster-providers/src/providers/gdal/qgsgdalprovider.h
===================================================================
--- branches/raster-providers/src/providers/gdal/qgsgdalprovider.h	2011-02-20 16:33:08 UTC (rev 15220)
+++ branches/raster-providers/src/providers/gdal/qgsgdalprovider.h	2011-02-20 16:37:25 UTC (rev 15221)
@@ -268,7 +268,9 @@
     bool mHasPyramids;
 
     /** \brief Gdal data types used to represent data in in QGIS, 
-               may be longer than source data type to keep nulls */
+               may be longer than source data type to keep nulls 
+               indexed from 1 
+     */
     QList<int>mGdalDataType;
 
     QgsRectangle mExtent;



More information about the QGIS-commit mailing list