Skip to content

Commit

Permalink
Safety checks for classification algorithms (Fix #9252)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Dec 26, 2013
1 parent b40e3c0 commit 7507cfc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
Expand Up @@ -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
Expand All @@ -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;

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7507cfc

Please sign in to comment.