@@ -502,8 +502,6 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
502
502
int srcBottom = ySize () - 1 ;
503
503
int srcRight = xSize () - 1 ;
504
504
505
- QTime time ;
506
- time .start ();
507
505
// Note: original approach for xRes < srcXRes || yRes < qAbs( srcYRes ) was to avoid
508
506
// second resampling and read with GDALRasterIO to another temporary data block
509
507
// extended to fit src grid. The problem was that with src resolution much bigger
@@ -595,9 +593,6 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
595
593
return ;
596
594
}
597
595
598
- QgsDebugMsg ( QString ( " GDALRasterIO time (ms): %1" ).arg ( time .elapsed () ) );
599
- time .start ();
600
-
601
596
double tmpXRes = srcWidth * srcXRes / tmpWidth;
602
597
double tmpYRes = srcHeight * srcYRes / tmpHeight; // negative
603
598
@@ -609,25 +604,30 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
609
604
char *srcRowBlock = tmpBlock + dataSize * tmpRow * tmpWidth;
610
605
char *dstRowBlock = ( char * )theBlock + dataSize * ( top + row ) * thePixelWidth;
611
606
612
- double x = myRasterExtent.xMinimum () + 0.5 * xRes; // cell center
607
+ double x = ( myRasterExtent.xMinimum () + 0.5 * xRes - tmpXMin ) / tmpXRes; // cell center
608
+ double increment = xRes / tmpXRes;
609
+
613
610
char * dst = dstRowBlock + dataSize * left;
614
- char * src = 0 ;
611
+ char * src = srcRowBlock ;
615
612
int tmpCol = 0 ;
613
+ int lastCol = 0 ;
616
614
for ( int col = 0 ; col < width; ++col )
617
615
{
618
616
// floor() is quite slow! Use just cast to int.
619
- tmpCol = static_cast <int >(( x - tmpXMin ) / tmpXRes ) ;
620
- src = srcRowBlock + dataSize * tmpCol;
617
+ tmpCol = static_cast <int >( x ) ;
618
+ if ( tmpCol > lastCol )
619
+ {
620
+ src += ( tmpCol - lastCol ) * dataSize;
621
+ lastCol = tmpCol;
622
+ }
621
623
memcpy ( dst, src, dataSize );
622
624
dst += dataSize;
623
- x += xRes ;
625
+ x += increment ;
624
626
}
625
627
y -= yRes;
626
628
}
627
629
628
630
qgsFree ( tmpBlock );
629
- QgsDebugMsg ( QString ( " resample time (ms): %1" ).arg ( time .elapsed () ) );
630
-
631
631
return ;
632
632
}
633
633
0 commit comments