Skip to content

Commit b40799d

Browse files
author
wonder
committed
Applied #2963 (fix crash with quantiles) from Jeremy Palmer. Thanks!
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14398 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent f43b3f2 commit b40799d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,16 +322,19 @@ static QList<double> _calcQuantileBreaks( QList<double> values, int classes )
322322
QList<double> breaks;
323323

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

332-
r = a - aa;
333-
Xq = ( 1 - r ) * values[aa] + r * values[aa+1];
327+
for ( int i = 1; i < classes; i++ )
328+
{
329+
if( n > 1 )
330+
{
331+
double q = i / ( double ) classes;
332+
double a = q * (n-1);
333+
int aa = ( int )( a );
334334

335+
double r = a - aa;
336+
Xq = ( 1 - r ) * values[aa] + r * values[aa+1];
337+
}
335338
breaks.append( Xq );
336339
}
337340

0 commit comments

Comments
 (0)