Browse Source

Allow more than 255 bins

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53951 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 12 years ago
parent
commit
daf888c33a
1 changed files with 5 additions and 2 deletions
  1. 5 2
      raster/r.quantile/main.c

+ 5 - 2
raster/r.quantile/main.c

@@ -34,7 +34,7 @@ static unsigned int *slots;
 static DCELL slot_size;
 static DCELL slot_size;
 static unsigned long total;
 static unsigned long total;
 static int num_values;
 static int num_values;
-static unsigned char *slot_bins;
+static unsigned short *slot_bins;
 static int num_bins;
 static int num_bins;
 static struct bin *bins;
 static struct bin *bins;
 static DCELL *values;
 static DCELL *values;
@@ -309,13 +309,16 @@ int main(int argc, char *argv[])
 	    quants[i] = 1.0 * (i + 1) / (num_quants + 1);
 	    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, "");
     infile = Rast_open_old(opt.input->answer, "");
 
 
     Rast_read_fp_range(opt.input->answer, "", &range);
     Rast_read_fp_range(opt.input->answer, "", &range);
     Rast_get_fp_range_min_max(&range, &min, &max);
     Rast_get_fp_range_min_max(&range, &min, &max);
 
 
     slots = G_calloc(num_slots, sizeof(unsigned int));
     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;
     slot_size = (max - min) / num_slots;