Skip to content
Permalink
Browse files

Safety checks for classification algorithms (Fix #9252)

  • Loading branch information
m-kuhn committed Dec 26, 2013
1 parent b40e3c0 commit 7507cfcd3fcd57b059da7a5337bce0ff1ec6b9fe
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
@@ -419,7 +419,6 @@ static QList<double> _calcEqualIntervalBreaks( double minimum, double maximum, i

static QList<double> _calcQuantileBreaks( QList<double> values, int classes )
{

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

QList<double> breaks;

// If there are no values to process: bail out
if ( !values.count() )
return breaks;

int n = values.count();
double Xq = n > 0 ? values[0] : 0.0;

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

// If there are no values to process: bail out
if ( !values.count() )
return QList<double>();

double mean = 0.0;
double stdDev = 0.0;
int n = values.count();

0 comments on commit 7507cfc

Please sign in to comment.
You can’t perform that action at this time.