Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Applied #2963 (fix crash with quantiles) from Jeremy Palmer. Thanks!
git-svn-id: http://svn.osgeo.org/qgis/trunk@14398 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Oct 18, 2010
1 parent f3c7dc0 commit 9b287ce
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
Expand Up @@ -322,16 +322,19 @@ static QList<double> _calcQuantileBreaks( QList<double> values, int classes )
QList<double> breaks;

int n = values.count();
double q, a, aa, r, Xq;
for ( int i = 0; i < ( classes - 1 ); i++ )
{
q = ( i + 1 ) / ( double ) classes;
a = q * n;
aa = ( int )( q * n );
double Xq = n > 0 ? values[0] : 0.0;

r = a - aa;
Xq = ( 1 - r ) * values[aa] + r * values[aa+1];
for ( int i = 1; i < classes; i++ )
{
if( n > 1 )
{
double q = i / ( double ) classes;
double a = q * (n-1);
int aa = ( int )( a );

double r = a - aa;
Xq = ( 1 - r ) * values[aa] + r * values[aa+1];
}
breaks.append( Xq );
}

Expand Down

0 comments on commit 9b287ce

Please sign in to comment.