[GRASS-SVN] r72531 - grass/branches/releasebranch_7_4/raster/r.cross

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Mar 23 10:41:02 PDT 2018


Author: neteler
Date: 2018-03-23 10:41:02 -0700 (Fri, 23 Mar 2018)
New Revision: 72531

Modified:
   grass/branches/releasebranch_7_4/raster/r.cross/cats.c
   grass/branches/releasebranch_7_4/raster/r.cross/cross.c
   grass/branches/releasebranch_7_4/raster/r.cross/main.c
Log:
r.cross: create categories for output value 0, it is a valid result (trunk, r72281)

Modified: grass/branches/releasebranch_7_4/raster/r.cross/cats.c
===================================================================
--- grass/branches/releasebranch_7_4/raster/r.cross/cats.c	2018-03-23 15:54:52 UTC (rev 72530)
+++ grass/branches/releasebranch_7_4/raster/r.cross/cats.c	2018-03-23 17:41:02 UTC (rev 72531)
@@ -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/branches/releasebranch_7_4/raster/r.cross/cross.c
===================================================================
--- grass/branches/releasebranch_7_4/raster/r.cross/cross.c	2018-03-23 15:54:52 UTC (rev 72530)
+++ grass/branches/releasebranch_7_4/raster/r.cross/cross.c	2018-03-23 17:41:02 UTC (rev 72531)
@@ -108,5 +108,5 @@
     btree_free(&btree);
     for (i = 0; i < nfiles; i++)
 	G_free(cell[i]);
-    return result - 1;
+    return result;
 }

Modified: grass/branches/releasebranch_7_4/raster/r.cross/main.c
===================================================================
--- grass/branches/releasebranch_7_4/raster/r.cross/main.c	2018-03-23 15:54:52 UTC (rev 72530)
+++ grass/branches/releasebranch_7_4/raster/r.cross/main.c	2018-03-23 17:41:02 UTC (rev 72531)
@@ -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