[GRASS-SVN] r53951 - grass/trunk/raster/r.quantile

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Nov 21 07:26:02 PST 2012


Author: glynn
Date: 2012-11-21 07:26:01 -0800 (Wed, 21 Nov 2012)
New Revision: 53951

Modified:
   grass/trunk/raster/r.quantile/main.c
Log:
Allow more than 255 bins


Modified: grass/trunk/raster/r.quantile/main.c
===================================================================
--- grass/trunk/raster/r.quantile/main.c	2012-11-21 12:38:16 UTC (rev 53950)
+++ grass/trunk/raster/r.quantile/main.c	2012-11-21 15:26:01 UTC (rev 53951)
@@ -34,7 +34,7 @@
 static DCELL slot_size;
 static unsigned long total;
 static int num_values;
-static unsigned char *slot_bins;
+static unsigned short *slot_bins;
 static int num_bins;
 static struct bin *bins;
 static DCELL *values;
@@ -309,13 +309,16 @@
 	    quants[i] = 1.0 * (i + 1) / (num_quants + 1);
     }
 
+    if (num_quants > 65535)
+	G_fatal_error(_("Too many quantiles"));
+
     infile = Rast_open_old(opt.input->answer, "");
 
     Rast_read_fp_range(opt.input->answer, "", &range);
     Rast_get_fp_range_min_max(&range, &min, &max);
 
     slots = G_calloc(num_slots, sizeof(unsigned int));
-    slot_bins = G_calloc(num_slots, sizeof(unsigned char));
+    slot_bins = G_calloc(num_slots, sizeof(unsigned short));
 
     slot_size = (max - min) / num_slots;
 



More information about the grass-commit mailing list