[GRASS-SVN] r72281 - grass/trunk/raster/r.cross
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Feb 26 04:01:02 PST 2018
Author: mmetz
Date: 2018-02-26 04:01:02 -0800 (Mon, 26 Feb 2018)
New Revision: 72281
Modified:
grass/trunk/raster/r.cross/cats.c
grass/trunk/raster/r.cross/cross.c
grass/trunk/raster/r.cross/main.c
Log:
r.cross: create categories for output value 0, it is a valid result
Modified: grass/trunk/raster/r.cross/cats.c
===================================================================
--- grass/trunk/raster/r.cross/cats.c 2018-02-26 10:14:11 UTC (rev 72280)
+++ grass/trunk/raster/r.cross/cats.c 2018-02-26 12:01:02 UTC (rev 72281)
@@ -30,10 +30,6 @@
static int len = 0;
char *lbl;
-
- if (result == 0)
- return 1;
-
n = 0;
for (i = 0; i < nfiles; i++) {
lbl = get_label(cat[i], &labels[i]);
Modified: grass/trunk/raster/r.cross/cross.c
===================================================================
--- grass/trunk/raster/r.cross/cross.c 2018-02-26 10:14:11 UTC (rev 72280)
+++ grass/trunk/raster/r.cross/cross.c 2018-02-26 12:01:02 UTC (rev 72281)
@@ -108,5 +108,5 @@
btree_free(&btree);
for (i = 0; i < nfiles; i++)
G_free(cell[i]);
- return result - 1;
+ return result;
}
Modified: grass/trunk/raster/r.cross/main.c
===================================================================
--- grass/trunk/raster/r.cross/main.c 2018-02-26 10:14:11 UTC (rev 72280)
+++ grass/trunk/raster/r.cross/main.c 2018-02-26 12:01:02 UTC (rev 72281)
@@ -143,16 +143,15 @@
if (result <= 0)
exit(0);
-
/* build the renumbering/reclass and the new cats file */
- qsort(reclass, result + 1, sizeof(RECLASS), cmp);
- table = (CELL *) G_calloc(result + 1, sizeof(CELL));
+ qsort(reclass, result, sizeof(RECLASS), cmp);
+ table = (CELL *) G_calloc(result, sizeof(CELL));
for (i = 0; i < nfiles; i++) {
mapset = G_find_raster2(names[i], "");
Rast_read_cats(names[i], mapset, &labels[i]);
}
- for (ncats = 0; ncats <= result; ncats++) {
+ for (ncats = 0; ncats < result; ncats++) {
table[reclass[ncats].result] = ncats;
set_cat(ncats, reclass[ncats].cat, &pcats);
}
@@ -176,7 +175,7 @@
Rast_write_colors(output, G_mapset(), &pcolr);
}
- G_message(_("%ld categories"), (long)result);
+ G_message(_("%d categories"), result);
exit(EXIT_SUCCESS);
}
More information about the grass-commit
mailing list