[QGIS Commit] r15534 - trunk/qgis/src/providers/gdal

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Mar 19 07:45:11 EDT 2011


Author: rblazek
Date: 2011-03-19 04:45:11 -0700 (Sat, 19 Mar 2011)
New Revision: 15534

Modified:
   trunk/qgis/src/providers/gdal/qgsgdalprovider.cpp
Log:
tmp block size calc fix

Modified: trunk/qgis/src/providers/gdal/qgsgdalprovider.cpp
===================================================================
--- trunk/qgis/src/providers/gdal/qgsgdalprovider.cpp	2011-03-18 20:37:07 UTC (rev 15533)
+++ trunk/qgis/src/providers/gdal/qgsgdalprovider.cpp	2011-03-19 11:45:11 UTC (rev 15534)
@@ -698,8 +698,17 @@
   int tmpWidth = srcWidth;
   int tmpHeight = srcHeight;
 
-  if ( xRes > srcXRes ) tmpWidth = width;
-  if ( yRes > srcYRes ) tmpHeight = height;
+  if ( xRes > srcXRes )
+  {
+    tmpWidth = static_cast<int>( qRound( srcWidth * srcXRes / xRes ) ) ;
+  }
+  if ( yRes > srcYRes )
+  {
+    tmpHeight = static_cast<int>( qRound( -1.*srcHeight * srcYRes / yRes ) ) ;
+  }
+  double tmpXMin = mExtent.xMinimum() + srcLeft * srcXRes;
+  double tmpYMax = mExtent.yMaximum() + srcTop * srcYRes;
+  QgsDebugMsg( QString( "tmpXMin = %1 tmpYMax = %2 tmpWidth = %3 tmpHeight = %4" ).arg( tmpXMin ).arg( tmpYMax ).arg( tmpWidth ).arg( tmpHeight ) );
 
   // Allocate temporary block
   char *tmpBlock = ( char * )malloc( dataSize * tmpWidth * tmpHeight );
@@ -724,13 +733,9 @@
   QgsDebugMsg( QString( "GDALRasterIO time (ms): %1" ).arg( time.elapsed() ) );
   time.start();
 
-  double tmpXMin = mExtent.xMinimum() + srcLeft * srcXRes;
-  double tmpYMax = mExtent.yMaximum() + srcTop * srcYRes;
   double tmpXRes = srcWidth * srcXRes / tmpWidth;
   double tmpYRes = srcHeight * srcYRes / tmpHeight; // negative
 
-  QgsDebugMsg( QString( "tmpXMin = %1 tmpYMax = %2 tmpWidth = %3 tmpHeight = %4" ).arg( tmpXMin ).arg( tmpYMax ).arg( tmpWidth ).arg( tmpHeight ) );
-
   for ( int row = 0; row < height; row++ )
   {
     double y = myRasterExtent.yMaximum() - ( row + 0.5 ) * yRes;
@@ -744,8 +749,6 @@
       double x = myRasterExtent.xMinimum() + ( col + 0.5 ) * xRes;
       // floor() is quite slow! Use just cast to int.
       int tmpCol = static_cast<int>(( x - tmpXMin ) / tmpXRes ) ;
-      //QgsDebugMsg( QString( "row = %1 col = %2 tmpRow = %3 tmpCol = %4" ).arg(row).arg(col).arg(tmpRow).arg(tmpCol) );
-
       char *src = srcRowBlock + dataSize * tmpCol;
       char *dst = dstRowBlock + dataSize * ( left + col );
       memcpy( dst, src, dataSize );



More information about the QGIS-commit mailing list