[QGIS Commit] r14398 - trunk/qgis/src/core/symbology-ng

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Oct 18 14:59:52 EDT 2010


Author: wonder
Date: 2010-10-18 11:59:52 -0700 (Mon, 18 Oct 2010)
New Revision: 14398

Modified:
   trunk/qgis/src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
Log:
Applied #2963 (fix crash with quantiles) from Jeremy Palmer. Thanks!


Modified: trunk/qgis/src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp	2010-10-18 18:58:02 UTC (rev 14397)
+++ trunk/qgis/src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp	2010-10-18 18:59:52 UTC (rev 14398)
@@ -322,16 +322,19 @@
   QList<double> breaks;
 
   int n = values.count();
-  double q, a, aa, r, Xq;
-  for ( int i = 0; i < ( classes - 1 ); i++ )
+  double Xq = n > 0 ? values[0] : 0.0;
+
+  for ( int i = 1; i < classes; i++ )
   {
-    q = ( i + 1 ) / ( double ) classes;
-    a = q * n;
-    aa = ( int )( q * n );
+    if( n > 1 )
+    {
+      double q = i  / ( double ) classes;
+      double a = q * (n-1);
+      int aa = ( int )( a );
 
-    r = a - aa;
-    Xq = ( 1 - r ) * values[aa] + r * values[aa+1];
-
+      double r = a - aa;
+      Xq = ( 1 - r ) * values[aa] + r * values[aa+1];
+    }
     breaks.append( Xq );
   }
 



More information about the QGIS-commit mailing list