Skip to content

Commit 7507cfc

Browse files
committedDec 26, 2013
Safety checks for classification algorithms (Fix #9252)
1 parent b40e3c0 commit 7507cfc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ static QList<double> _calcEqualIntervalBreaks( double minimum, double maximum, i
419419

420420
static QList<double> _calcQuantileBreaks( QList<double> values, int classes )
421421
{
422-
423422
// q-th quantile of a data set:
424423
// value where q fraction of data is below and (1-q) fraction is above this value
425424
// Xq = (1 - r) * X_NI1 + r * X_NI2
@@ -433,6 +432,10 @@ static QList<double> _calcQuantileBreaks( QList<double> values, int classes )
433432

434433
QList<double> breaks;
435434

435+
// If there are no values to process: bail out
436+
if ( !values.count() )
437+
return breaks;
438+
436439
int n = values.count();
437440
double Xq = n > 0 ? values[0] : 0.0;
438441

@@ -616,6 +619,10 @@ static QList<double> _calcStdDevBreaks( QList<double> values, int classes, QList
616619
// Returns breaks based on '_calcPrettyBreaks' of the centred and scaled
617620
// values of 'values', and may have a number of classes different from 'classes'.
618621

622+
// If there are no values to process: bail out
623+
if ( !values.count() )
624+
return QList<double>();
625+
619626
double mean = 0.0;
620627
double stdDev = 0.0;
621628
int n = values.count();

0 commit comments

Comments
 (0)
Please sign in to comment.