Skip to content

Commit 4ce50ee

Browse files
root676nyalldawson
authored andcommittedApr 20, 2020
fix equal bound parameter input control
1 parent 3fea270 commit 4ce50ee

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed
 

‎src/analysis/processing/qgsalgorithmrandomraster.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ bool QgsRandomRasterAlgorithm::prepareAlgorithm( const QVariantMap &parameters,
120120
mRasterDataType = Qgis::Byte;
121121
if ( mRandomLowerBound < std::numeric_limits<quint8>::min() || mRandomUpperBound > std::numeric_limits<quint8>::max() )
122122
throw QgsProcessingException( QObject::tr( "Raster datasets of type Byte only accept positive values between %1 and %2. Please choose other bounds for random values." ).arg( std::numeric_limits<quint8>::min() ).arg( std::numeric_limits<quint8>::max() ) );
123-
if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || ( mRandomUpperBound == mRandomLowerBound ) )
123+
if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
124124
{
125125
//if parameters unset (=both are 0 or equal) --> use the whole value range
126126
mRandomUpperBound = std::numeric_limits<quint8>::max();
@@ -131,7 +131,7 @@ bool QgsRandomRasterAlgorithm::prepareAlgorithm( const QVariantMap &parameters,
131131
mRasterDataType = Qgis::Int16;
132132
if ( mRandomLowerBound < std::numeric_limits<qint16>::min() || mRandomUpperBound > std::numeric_limits<qint16>::max() )
133133
throw QgsProcessingException( QObject::tr( "Raster datasets of type Integer16 only accept values between %1 and %2. Please choose other bounds for random values." ).arg( std::numeric_limits<qint16>::min() ).arg( std::numeric_limits<qint16>::max() ) );
134-
if ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) )
134+
if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
135135
{
136136
mRandomUpperBound = std::numeric_limits<qint16>::max();
137137
mRandomLowerBound = std::numeric_limits<qint16>::min();
@@ -141,7 +141,7 @@ bool QgsRandomRasterAlgorithm::prepareAlgorithm( const QVariantMap &parameters,
141141
mRasterDataType = Qgis::UInt16;
142142
if ( mRandomLowerBound < std::numeric_limits<quint16>::min() || mRandomUpperBound > std::numeric_limits<quint16>::max() )
143143
throw QgsProcessingException( QObject::tr( "Raster datasets of type Unsigned Integer16 only accept positive values between %1 and %2. Please choose other bounds for random values." ).arg( std::numeric_limits<quint16>::min() ).arg( std::numeric_limits<quint16>::max() ) );
144-
if ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) )
144+
if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
145145
{
146146
mRandomUpperBound = std::numeric_limits<quint16>::max();
147147
mRandomLowerBound = std::numeric_limits<quint16>::min();
@@ -151,7 +151,7 @@ bool QgsRandomRasterAlgorithm::prepareAlgorithm( const QVariantMap &parameters,
151151
mRasterDataType = Qgis::Int32;
152152
if ( mRandomLowerBound < std::numeric_limits<qint32>::min() || mRandomUpperBound > std::numeric_limits<qint32>::max() )
153153
throw QgsProcessingException( QObject::tr( "Raster datasets of type Integer32 only accept values between %1 and %2. Please choose other bounds for random values." ).arg( std::numeric_limits<qint32>::min() ).arg( std::numeric_limits<qint32>::max() ) );
154-
if ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) )
154+
if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
155155
{
156156
mRandomUpperBound = std::numeric_limits<qint32>::max();
157157
mRandomLowerBound = std::numeric_limits<qint32>::min();
@@ -161,23 +161,23 @@ bool QgsRandomRasterAlgorithm::prepareAlgorithm( const QVariantMap &parameters,
161161
mRasterDataType = Qgis::UInt32;
162162
if ( mRandomLowerBound < std::numeric_limits<quint32>::min() || mRandomUpperBound > std::numeric_limits<quint32>::max() )
163163
throw QgsProcessingException( QObject::tr( "Raster datasets of type Unsigned Integer32 only accept positive values between %1 and %2. Please choose other bounds for random values." ).arg( std::numeric_limits<quint32>::min() ).arg( std::numeric_limits<quint32>::max() ) );
164-
if ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) )
164+
if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
165165
{
166166
mRandomUpperBound = std::numeric_limits<quint32>::max();
167167
mRandomLowerBound = std::numeric_limits<quint32>::min();
168168
}
169169
break;
170170
case ( 5 ):
171171
mRasterDataType = Qgis::Float32;
172-
if ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) )
172+
if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
173173
{
174174
mRandomUpperBound = std::numeric_limits<float>::max();
175175
mRandomLowerBound = std::numeric_limits<float>::min();
176176
}
177177
break;
178178
case ( 6 ):
179179
mRasterDataType = Qgis::Float64;
180-
if ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) )
180+
if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
181181
{
182182
mRandomUpperBound = std::numeric_limits<double>::max();
183183
mRandomLowerBound = std::numeric_limits<double>::min();

0 commit comments

Comments
 (0)
Please sign in to comment.