Skip to content

Commit

Permalink
fix loop variables in random raster algs
Browse files Browse the repository at this point in the history
  • Loading branch information
root676 authored and nyalldawson committed Apr 20, 2020
1 parent ace8e46 commit 9405b44
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
14 changes: 7 additions & 7 deletions src/analysis/processing/qgsalgorithmnormalraster.cpp
Expand Up @@ -142,7 +142,7 @@ QVariantMap QgsNormalRasterAlgorithm::processAlgorithm( const QVariantMap &param

double step = rows > 0 ? 100.0 / rows : 1;

for ( int i = 0; i < rows ; i++ )
for ( int row = 0; row < rows ; row++ )
{
if ( feedback->isCanceled() )
{
Expand All @@ -155,28 +155,28 @@ QVariantMap QgsNormalRasterAlgorithm::processAlgorithm( const QVariantMap &param
case ( 0 ):
{
std::vector<float> float32Row( cols );
for ( int i = 0; i < cols; i++ )
for ( int col = 0; col < cols; col++ )
{
float32Row[i] = static_cast<float>( mNormalDoubleDistribution( mRandomDevice ) );
float32Row[col] = static_cast<float>( mNormalDoubleDistribution( mRandomDevice ) );
}
block.setData( QByteArray( reinterpret_cast<const char *>( float32Row.data() ), QgsRasterBlock::typeSize( Qgis::Float32 ) * cols ) );
break;
}
case ( 1 ):
{
std::vector<double> float64Row( cols );
for ( int i = 0; i < cols; i++ )
for ( int col = 0; col < cols; col++ )
{
float64Row[i] = mNormalDoubleDistribution( mRandomDevice );
float64Row[col] = mNormalDoubleDistribution( mRandomDevice );
}
block.setData( QByteArray( reinterpret_cast<const char *>( float64Row.data() ), QgsRasterBlock::typeSize( Qgis::Float64 ) * cols ) );
break;
}
default:
break;
}
provider->writeBlock( &block, 1, 0, i );
feedback->setProgress( i * step );
provider->writeBlock( &block, 1, 0, row );
feedback->setProgress( row * step );
}

QVariantMap outputs;
Expand Down
34 changes: 17 additions & 17 deletions src/analysis/processing/qgsalgorithmrandomraster.cpp
Expand Up @@ -218,7 +218,7 @@ QVariantMap QgsRandomRasterAlgorithm::processAlgorithm( const QVariantMap &param

double step = rows > 0 ? 100.0 / rows : 1;

for ( int i = 0; i < rows ; i++ )
for ( int row = 0; row < rows ; row++ )
{
if ( feedback->isCanceled() )
{
Expand All @@ -231,78 +231,78 @@ QVariantMap QgsRandomRasterAlgorithm::processAlgorithm( const QVariantMap &param
case ( 0 ):
{
std::vector<quint8> byteRow( cols );
for ( int i = 0; i < cols; i++ )
for ( int col = 0; col < cols; col++ )
{
byteRow[i] = static_cast<quint8>( mRandomIntDistribution( mRandomDevice ) );
byteRow[col] = static_cast<quint8>( mRandomIntDistribution( mRandomDevice ) );
}
block.setData( QByteArray( reinterpret_cast<const char *>( byteRow.data() ), QgsRasterBlock::typeSize( Qgis::Byte ) * cols ) );
break;
}
case ( 1 ):
{
std::vector<qint16> int16Row( cols );
for ( int i = 0; i < cols; i++ )
for ( int col = 0; col < cols; col++ )
{
int16Row[i] = static_cast<qint16>( mRandomIntDistribution( mRandomDevice ) );
int16Row[col] = static_cast<qint16>( mRandomIntDistribution( mRandomDevice ) );
}
block.setData( QByteArray( reinterpret_cast<const char *>( int16Row.data() ), QgsRasterBlock::typeSize( Qgis::Int16 ) * cols ) );
break;
}
case ( 2 ):
{
std::vector<quint16> uInt16Row( cols );
for ( int i = 0; i < cols; i++ )
for ( int col = 0; col < cols; col++ )
{
uInt16Row[i] = static_cast<quint16>( mRandomIntDistribution( mRandomDevice ) );
uInt16Row[col] = static_cast<quint16>( mRandomIntDistribution( mRandomDevice ) );
}
block.setData( QByteArray( reinterpret_cast<const char *>( uInt16Row.data() ), QgsRasterBlock::typeSize( Qgis::UInt16 ) * cols ) );
break;
}
case ( 3 ):
{
std::vector<qint32> int32Row( cols );
for ( int i = 0; i < cols; i++ )
for ( int col = 0; col < cols; col++ )
{
int32Row[i] = static_cast<qint32>( mRandomIntDistribution( mRandomDevice ) );
int32Row[col] = static_cast<qint32>( mRandomIntDistribution( mRandomDevice ) );
}
block.setData( QByteArray( reinterpret_cast<const char *>( int32Row.data() ), QgsRasterBlock::typeSize( Qgis::Int32 ) * cols ) );
break;
}
case ( 4 ):
{
std::vector<quint32> uInt32Row( cols );
for ( int i = 0; i < cols; i++ )
for ( int col = 0; col < cols; col++ )
{
uInt32Row[i] = static_cast<quint32>( mRandomIntDistribution( mRandomDevice ) );
uInt32Row[col] = static_cast<quint32>( mRandomIntDistribution( mRandomDevice ) );
}
block.setData( QByteArray( reinterpret_cast<const char *>( uInt32Row.data() ), QgsRasterBlock::typeSize( Qgis::UInt32 ) * cols ) );
break;
}
case ( 5 ):
{
std::vector<float> float32Row( cols );
for ( int i = 0; i < cols; i++ )
for ( int col = 0; col < cols; col++ )
{
float32Row[i] = static_cast<float>( mRandomDoubleDistribution( mRandomDevice ) );
float32Row[col] = static_cast<float>( mRandomDoubleDistribution( mRandomDevice ) );
}
block.setData( QByteArray( reinterpret_cast<const char *>( float32Row.data() ), QgsRasterBlock::typeSize( Qgis::Float32 ) * cols ) );
break;
}
case ( 6 ):
{
std::vector<double> float64Row( cols );
for ( int i = 0; i < cols; i++ )
for ( int col = 0; col < cols; col++ )
{
float64Row[i] = mRandomDoubleDistribution( mRandomDevice );
float64Row[col] = mRandomDoubleDistribution( mRandomDevice );
}
block.setData( QByteArray( reinterpret_cast<const char *>( float64Row.data() ), QgsRasterBlock::typeSize( Qgis::Float64 ) * cols ) );
break;
}
default:
break;
}
provider->writeBlock( &block, 1, 0, i );
feedback->setProgress( i * step );
provider->writeBlock( &block, 1, 0, row );
feedback->setProgress( row * step );
}

QVariantMap outputs;
Expand Down

0 comments on commit 9405b44

Please sign in to comment.