@@ -328,12 +328,12 @@ int QgsZonalStatistics::calculateStatistics( QgsFeedback *feedback )
328328 std::sort ( vals.begin (), vals.end () );
329329 if ( mStatistics & QgsZonalStatistics::Minority )
330330 {
331- float minorityKey = featureStats.valueCount .key ( vals.first () );
331+ double minorityKey = featureStats.valueCount .key ( vals.first () );
332332 changeAttributeMap.insert ( minorityIndex, QVariant ( minorityKey ) );
333333 }
334334 if ( mStatistics & QgsZonalStatistics::Majority )
335335 {
336- float majKey = featureStats.valueCount .key ( vals.last () );
336+ double majKey = featureStats.valueCount .key ( vals.last () );
337337 changeAttributeMap.insert ( majorityIndex, QVariant ( majKey ) );
338338 }
339339 }
@@ -422,15 +422,16 @@ void QgsZonalStatistics::statisticsFromMiddlePointTest( const QgsGeometry &poly,
422422 cellCenterX = rasterBBox.xMinimum () + pixelOffsetX * cellSizeX + cellSizeX / 2 ;
423423 for ( int j = 0 ; j < nCellsX; ++j )
424424 {
425- if ( validPixel ( block->value ( i, j ) ) )
425+ double pixelValue = block->value ( i, j );
426+ if ( validPixel ( pixelValue ) )
426427 {
427428 cellCenterCoords = GEOSCoordSeq_create_r ( geosctxt, 1 , 2 );
428429 GEOSCoordSeq_setX_r ( geosctxt, cellCenterCoords, 0 , cellCenterX );
429430 GEOSCoordSeq_setY_r ( geosctxt, cellCenterCoords, 0 , cellCenterY );
430431 currentCellCenter.reset ( GEOSGeom_createPoint_r ( geosctxt, cellCenterCoords ) );
431432 if ( GEOSPreparedContains_r ( geosctxt, polyGeosPrepared.get (), currentCellCenter.get () ) )
432433 {
433- stats.addValue ( block-> value ( i, j ) );
434+ stats.addValue ( pixelValue );
434435 }
435436 }
436437 cellCenterX += cellSizeX;
@@ -461,7 +462,8 @@ void QgsZonalStatistics::statisticsFromPreciseIntersection( const QgsGeometry &p
461462 double currentX = rasterBBox.xMinimum () + cellSizeX / 2.0 + pixelOffsetX * cellSizeX;
462463 for ( int j = 0 ; j < nCellsX; ++j )
463464 {
464- if ( !validPixel ( block->value ( i, j ) ) )
465+ double pixelValue = block->value ( i, j );
466+ if ( !validPixel ( pixelValue ) )
465467 {
466468 continue ;
467469 }
@@ -477,7 +479,7 @@ void QgsZonalStatistics::statisticsFromPreciseIntersection( const QgsGeometry &p
477479 if ( intersectionArea >= 0.0 )
478480 {
479481 weight = intersectionArea / pixelArea;
480- stats.addValue ( block-> value ( i, j ) , weight );
482+ stats.addValue ( pixelValue , weight );
481483 }
482484 }
483485 pixelRectGeometry = QgsGeometry ();
0 commit comments