Skip to content

Commit

Permalink
fix min/max random value assignment to take effect in the random rast…
Browse files Browse the repository at this point in the history
…er creation

(cherry picked from commit 2e5276d)
  • Loading branch information
root676 authored and nyalldawson committed Nov 12, 2020
1 parent 48fa119 commit 7706c23
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/analysis/processing/qgsalgorithmrandomraster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,6 @@ bool QgsRandomUniformRasterAlgorithm::prepareRandomParameters( const QVariantMap
mRandomUpperBound = parameterAsDouble( parameters, QStringLiteral( "UPPER_BOUND" ), context );
mRandomLowerBound = parameterAsDouble( parameters, QStringLiteral( "LOWER_BOUND" ), context );

mRandomUniformIntDistribution = std::uniform_int_distribution<long>( mRandomLowerBound, mRandomUpperBound );
mRandomUniformDoubleDistribution = std::uniform_real_distribution<double>( mRandomLowerBound, mRandomUpperBound );

if ( mRandomLowerBound > mRandomUpperBound )
throw QgsProcessingException( QObject::tr( "The chosen lower bound for random number range is greater than the upper bound. The lower bound value must be smaller than the upper bound value." ) );

Expand Down Expand Up @@ -346,6 +343,10 @@ bool QgsRandomUniformRasterAlgorithm::prepareRandomParameters( const QVariantMap
default:
break;
}

mRandomUniformIntDistribution = std::uniform_int_distribution<long>( mRandomLowerBound, mRandomUpperBound );
mRandomUniformDoubleDistribution = std::uniform_real_distribution<double>( mRandomLowerBound, mRandomUpperBound );

return true;
}

Expand Down

0 comments on commit 7706c23

Please sign in to comment.