@@ -226,13 +226,35 @@ QVector<QgsReclassifyUtils::RasterClass> QgsReclassifyByLayerAlgorithm::createCl
226
226
while ( mTableIterator .nextFeature ( f ) )
227
227
{
228
228
bool ok = false ;
229
- double minValue = f.attribute ( mMinFieldIdx ).toDouble ( &ok );
230
- if ( !ok )
231
- throw QgsProcessingException ( QObject::tr ( " Invalid value for minimum: %1" ).arg ( f.attribute ( mMinFieldIdx ).toString () ) );
232
- double maxValue = f.attribute ( mMaxFieldIdx ).toDouble ( &ok );
233
- if ( !ok )
234
- throw QgsProcessingException ( QObject::tr ( " Invalid value for maximum: %1" ).arg ( f.attribute ( mMaxFieldIdx ).toString () ) );
235
- double value = f.attribute ( mValueFieldIdx ).toDouble ( &ok );
229
+
230
+ // null values map to nan, which corresponds to a range extended to +/- infinity....
231
+ const QVariant minVariant = f.attribute ( mMinFieldIdx );
232
+ double minValue;
233
+ if ( minVariant.isNull () || minVariant.toString ().isEmpty () )
234
+ {
235
+ minValue = std::numeric_limits<double >::quiet_NaN ();
236
+ }
237
+ else
238
+ {
239
+ minValue = minVariant.toDouble ( &ok );
240
+ if ( !ok )
241
+ throw QgsProcessingException ( QObject::tr ( " Invalid value for minimum: %1" ).arg ( minVariant.toString () ) );
242
+ }
243
+ const QVariant maxVariant = f.attribute ( mMaxFieldIdx );
244
+ double maxValue;
245
+ if ( maxVariant.isNull () || maxVariant.toString ().isEmpty () )
246
+ {
247
+ maxValue = std::numeric_limits<double >::quiet_NaN ();
248
+ ok = true ;
249
+ }
250
+ else
251
+ {
252
+ maxValue = maxVariant.toDouble ( &ok );
253
+ if ( !ok )
254
+ throw QgsProcessingException ( QObject::tr ( " Invalid value for maximum: %1" ).arg ( maxVariant.toString () ) );
255
+ }
256
+
257
+ const double value = f.attribute ( mValueFieldIdx ).toDouble ( &ok );
236
258
if ( !ok )
237
259
throw QgsProcessingException ( QObject::tr ( " Invalid output value: %1" ).arg ( f.attribute ( mValueFieldIdx ).toString () ) );
238
260
@@ -296,12 +318,34 @@ QVector<QgsReclassifyUtils::RasterClass> QgsReclassifyByTableAlgorithm::createCl
296
318
for ( int row = 0 ; row < rows; ++row )
297
319
{
298
320
bool ok = false ;
299
- const double minValue = table.at ( row * 3 ).toDouble ( &ok );
300
- if ( !ok )
301
- throw QgsProcessingException ( QObject::tr ( " Invalid value for minimum: %1" ).arg ( table.at ( row * 3 ).toString () ) );
302
- const double maxValue = table.at ( row * 3 + 1 ).toDouble ( &ok );
303
- if ( !ok )
304
- throw QgsProcessingException ( QObject::tr ( " Invalid value for maximum: %1" ).arg ( table.at ( row * 3 + 1 ).toString () ) );
321
+
322
+ // null values map to nan, which corresponds to a range extended to +/- infinity....
323
+ const QVariant minVariant = table.at ( row * 3 );
324
+ double minValue;
325
+ if ( minVariant.isNull () || minVariant.toString ().isEmpty () )
326
+ {
327
+ minValue = std::numeric_limits<double >::quiet_NaN ();
328
+ }
329
+ else
330
+ {
331
+ minValue = minVariant.toDouble ( &ok );
332
+ if ( !ok )
333
+ throw QgsProcessingException ( QObject::tr ( " Invalid value for minimum: %1" ).arg ( table.at ( row * 3 ).toString () ) );
334
+ }
335
+ const QVariant maxVariant = table.at ( row * 3 + 1 );
336
+ double maxValue;
337
+ if ( maxVariant.isNull () || maxVariant.toString ().isEmpty () )
338
+ {
339
+ maxValue = std::numeric_limits<double >::quiet_NaN ();
340
+ ok = true ;
341
+ }
342
+ else
343
+ {
344
+ maxValue = maxVariant.toDouble ( &ok );
345
+ if ( !ok )
346
+ throw QgsProcessingException ( QObject::tr ( " Invalid value for maximum: %1" ).arg ( table.at ( row * 3 + 1 ).toString () ) );
347
+ }
348
+
305
349
const double value = table.at ( row * 3 + 2 ).toDouble ( &ok );
306
350
if ( !ok )
307
351
throw QgsProcessingException ( QObject::tr ( " Invalid output value: %1" ).arg ( table.at ( row * 3 + 2 ).toString () ) );
0 commit comments