@@ -480,26 +480,26 @@ QgsPalettedRasterRenderer::ClassData QgsPalettedRasterRenderer::classDataFromRas
480
480
// Collect unique values for float rasters
481
481
if ( raster->dataType ( bandNumber ) == Qgis::DataType::Float32 || raster->dataType ( bandNumber ) == Qgis::DataType::Float64 )
482
482
{
483
+ const QgsRectangle fullExtent { raster->extent () };
483
484
QList<double > values;
484
- if ( feedback )
485
- {
486
- // Start showing some progress
487
- feedback->setProgress ( 1 );
488
- }
489
- std::unique_ptr<QgsRasterBlock> block { raster->block ( bandNumber, raster->extent (), raster->xSize (), raster->ySize (), feedback ) };
485
+
490
486
if ( feedback && feedback->isCanceled () )
491
487
{
492
488
return data;
493
489
}
490
+ const double yStep { fullExtent.height () / raster->ySize () };
494
491
// Max MAX_FLOAT_CLASSES classes!
495
492
qgssize col = 0 ;
496
493
qgssize row = 0 ;
497
- for ( ; row < static_cast <qgssize>( raster->ySize () ); ++ row )
494
+ for ( row = raster->ySize () - 1 ; row >= 0 ; -- row )
498
495
{
499
496
if ( presentValues >= MAX_FLOAT_CLASSES )
500
497
{
501
498
break ;
502
499
}
500
+ raster->extent ();
501
+ const QgsRectangle rowExtent { fullExtent.xMinimum (), fullExtent.yMinimum () + yStep * row, fullExtent.xMaximum (), fullExtent.yMinimum () + yStep *( row + 1 ) };
502
+ std::unique_ptr<QgsRasterBlock> block { raster->block ( bandNumber, rowExtent, raster->xSize (), 1 , feedback ) };
503
503
for ( col = 0 ; col < static_cast <qgssize>( raster->xSize () ); ++col )
504
504
{
505
505
if ( presentValues >= MAX_FLOAT_CLASSES )
@@ -511,7 +511,7 @@ QgsPalettedRasterRenderer::ClassData QgsPalettedRasterRenderer::classDataFromRas
511
511
return data;
512
512
}
513
513
bool isNoData;
514
- const double currentValue { block->valueAndNoData ( row , col, isNoData ) };
514
+ const double currentValue { block->valueAndNoData ( 0 , col, isNoData ) };
515
515
if ( ! isNoData && !values.contains ( currentValue ) )
516
516
{
517
517
values.push_back ( currentValue );
@@ -521,8 +521,10 @@ QgsPalettedRasterRenderer::ClassData QgsPalettedRasterRenderer::classDataFromRas
521
521
}
522
522
if ( feedback )
523
523
{
524
- // Show no less than 2%, then the max between class fill and real progress
525
- feedback->setProgress ( std::max<int >( 2 , 100 * std::max<double >( ( row + 1 ) / raster->ySize (), presentValues / MAX_FLOAT_CLASSES ) ) );
524
+ // Show the max between class fill and real
525
+ const double progress { 100 * std::max<double >( ( raster->ySize () - row + 1 ) / raster->ySize (), presentValues / MAX_FLOAT_CLASSES ) };
526
+ feedback->setProgress ( progress );
527
+ // qDebug() << "Progress: " << progress;
526
528
}
527
529
}
528
530
if ( presentValues == MAX_FLOAT_CLASSES && ( col < static_cast <qgssize>( raster->xSize () ) || row < static_cast <qgssize>( raster->ySize () ) ) )
0 commit comments