Browse Source

rasterlib: fns from cats.c cleaned up, see http://trac.osgeo.org/grass/wiki/Grass7/RasterLib

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@38099 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 16 years ago
parent
commit
f222d1c8b3
71 changed files with 465 additions and 625 deletions
  1. 4 4
      display/d.colors/curses.c
  2. 2 2
      display/d.histogram/bar.c
  3. 2 2
      display/d.histogram/get_stats.c
  4. 2 2
      display/d.histogram/pie.c
  5. 6 6
      display/d.legend/main.c
  6. 2 2
      display/d.what.rast/what.c
  7. 1 1
      imagery/i.gensig/get_train.c
  8. 1 1
      imagery/i.gensigset/get_train.c
  9. 15 23
      imagery/i.maxlik/main.c
  10. 4 2
      imagery/i.smap/labels.c
  11. 32 42
      include/raster.h
  12. 7 7
      lib/g3d/g3dcats.c
  13. 1 1
      lib/g3d/g3dclose.c
  14. 4 4
      lib/ogsf/Gs3.c
  15. 5 5
      lib/ogsf/gsd_legend.c
  16. 131 298
      lib/raster/cats.c
  17. 6 6
      lib/raster/sample.c
  18. 3 3
      ps/ps.map/ps_clrtbl.c
  19. 11 8
      raster/r.buffer/support.c
  20. 7 7
      raster/r.category/main.c
  21. 1 1
      raster/r.compress/main.c
  22. 2 2
      raster/r.cross/cats.c
  23. 3 3
      raster/r.digit/get_label.c
  24. 1 3
      raster/r.distance/labels.c
  25. 2 2
      raster/r.grow/Makefile
  26. 4 4
      raster/r.grow/main.c
  27. 1 1
      raster/r.in.poly/get_item.c
  28. 1 1
      raster/r.kappa/prt_label.c
  29. 7 7
      raster/r.le/r.le.patch/trace.c
  30. 1 0
      raster/r.le/r.le.pixel/cellclip.c
  31. 1 1
      raster/r.le/r.le.pixel/driver.c
  32. 1 1
      raster/r.le/r.le.pixel/texture.c
  33. 2 1
      raster/r.mapcalc/map.c
  34. 2 1
      raster/r.mapcalc/map3.c
  35. 2 2
      raster/r.mode/main.c
  36. 1 1
      raster/r.neighbors/divr_cats.c
  37. 1 1
      raster/r.neighbors/intr_cats.c
  38. 1 4
      raster/r.neighbors/null_cats.c
  39. 3 3
      raster/r.null/main.c
  40. 19 19
      raster/r.param.scale/param.h
  41. 15 8
      raster/r.param.scale/write_cats.c
  42. 1 1
      raster/r.patch/support.c
  43. 5 3
      raster/r.random.surface/save.c
  44. 3 3
      raster/r.random/support.c
  45. 1 1
      raster/r.reclass/parse.c
  46. 3 3
      raster/r.reclass/reclass.c
  47. 5 5
      raster/r.report/prt_report.c
  48. 7 7
      raster/r.resample/main.c
  49. 40 28
      raster/r.slope.aspect/main.c
  50. 1 1
      raster/r.statistics/o_adev.c
  51. 1 1
      raster/r.statistics/o_average.c
  52. 2 2
      raster/r.statistics/o_divr.c
  53. 1 1
      raster/r.statistics/o_kurt.c
  54. 2 2
      raster/r.statistics/o_max.c
  55. 2 2
      raster/r.statistics/o_median.c
  56. 2 2
      raster/r.statistics/o_min.c
  57. 2 2
      raster/r.statistics/o_mode.c
  58. 1 1
      raster/r.statistics/o_sdev.c
  59. 1 1
      raster/r.statistics/o_skew.c
  60. 1 1
      raster/r.statistics/o_sum.c
  61. 1 1
      raster/r.statistics/o_var.c
  62. 2 2
      raster/r.statistics2/main.c
  63. 3 3
      raster/r.stats/raw_stats.c
  64. 5 5
      raster/r.stats/stats.c
  65. 1 1
      raster/r.to.vect/areas_io.c
  66. 1 1
      raster/r.to.vect/util.c
  67. 2 2
      raster/r.volume/main.c
  68. 1 1
      raster/r.watershed/shed/print.c
  69. 1 1
      raster/r.what/main.c
  70. 33 33
      swig/perl/R_slope_aspect/r_slope_aspect/r_slope_aspect.c
  71. 17 16
      vector/v.to.rast/support.c

+ 4 - 4
display/d.colors/curses.c

@@ -85,18 +85,18 @@ int Write_cats(struct Categories *pcats, int current_cat)
 	if (at_cat == current_cat) {
 	if (at_cat == current_cat) {
 	    if (!at_cat)
 	    if (!at_cat)
 		sprintf(buffer, "-> %3s %s", "N",
 		sprintf(buffer, "-> %3s %s", "N",
-			Rast_get_c_raster_cat(&tmp, pcats));
+			Rast_get_c_cat(&tmp, pcats));
 	    else
 	    else
 		sprintf(buffer, "-> %3d %s", at_cat - 1,
 		sprintf(buffer, "-> %3d %s", at_cat - 1,
-			Rast_get_cat(at_cat - 1, pcats));
+			Rast_get_c_cat(at_cat - 1, pcats));
 	}
 	}
 	else {
 	else {
 	    if (!at_cat)
 	    if (!at_cat)
 		sprintf(buffer, "   %3s %s", "N",
 		sprintf(buffer, "   %3s %s", "N",
-			Rast_get_c_raster_cat(&tmp, pcats));
+			Rast_get_c_cat(&tmp, pcats));
 	    else
 	    else
 		sprintf(buffer, "   %3d %s", at_cat - 1,
 		sprintf(buffer, "   %3d %s", at_cat - 1,
-			Rast_get_cat(at_cat - 1, pcats));
+			Rast_get_c_cat(at_cat - 1, pcats));
 	}
 	}
 	wmove(CAT_WIN, at_line++, 1);
 	wmove(CAT_WIN, at_line++, 1);
 	waddstr(CAT_WIN, buffer);
 	waddstr(CAT_WIN, buffer);

+ 2 - 2
display/d.histogram/bar.c

@@ -216,7 +216,7 @@ int bar(struct stat_list *dist_stats,	/* list of distribution statistics */
 		/* draw the bar as a box */
 		/* draw the bar as a box */
 		if (!Rast_is_c_null_value(&bar_color) && is_fp) {
 		if (!Rast_is_c_null_value(&bar_color) && is_fp) {
 		    if (cat_ranges)
 		    if (cat_ranges)
-			Rast_get_ith_d_raster_cat(&cats, bar_color,
+			Rast_get_ith_d_cat(&cats, bar_color,
 					       &dmin, &dmax);
 					       &dmin, &dmax);
 		    else {
 		    else {
 			dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;
 			dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;
@@ -269,7 +269,7 @@ int bar(struct stat_list *dist_stats,	/* list of distribution statistics */
 		/* draw the bar as a line */
 		/* draw the bar as a line */
 		if (is_fp) {
 		if (is_fp) {
 		    if (cat_ranges)
 		    if (cat_ranges)
-			Rast_get_ith_d_raster_cat(&cats, bar_color,
+			Rast_get_ith_d_cat(&cats, bar_color,
 					       &dmin, &dmax);
 					       &dmin, &dmax);
 		    else {
 		    else {
 			dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;
 			dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;

+ 2 - 2
display/d.histogram/get_stats.c

@@ -54,9 +54,9 @@ int get_stats(const char *mapname, struct stat_list *dist_stats,	/* linked list
     is_fp = Rast_raster_map_is_fp(mapname, "");
     is_fp = Rast_raster_map_is_fp(mapname, "");
     if (is_fp) {
     if (is_fp) {
 	if (cat_ranges) {
 	if (cat_ranges) {
-	    if (Rast_read_raster_cats(mapname, "", &cats) < 0)
+	    if (Rast_read_cats(mapname, "", &cats) < 0)
 		G_fatal_error("Can't read category file");
 		G_fatal_error("Can't read category file");
-	    if (Rast_number_of_raster_cats(&cats) <= 0) {
+	    if (Rast_number_of_cats(&cats) <= 0) {
 		G_warning("There are no labeled cats, using nsteps argument");
 		G_warning("There are no labeled cats, using nsteps argument");
 		cat_ranges = 0;
 		cat_ranges = 0;
 	    }
 	    }

+ 2 - 2
display/d.histogram/pie.c

@@ -187,7 +187,7 @@ int pie(struct stat_list *dist_stats,	/* list of distribution statistics */
 		draw = YES;
 		draw = YES;
 		if (is_fp) {
 		if (is_fp) {
 		    if (cat_ranges)
 		    if (cat_ranges)
-			Rast_get_ith_d_raster_cat(&cats, (CELL) i, &dmin, &dmax);
+			Rast_get_ith_d_cat(&cats, (CELL) i, &dmin, &dmax);
 		    else {
 		    else {
 			dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;
 			dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;
 			dmax = range_dmin + (i + 1) * (range_dmax - range_dmin) / nsteps;
 			dmax = range_dmin + (i + 1) * (range_dmax - range_dmin) / nsteps;
@@ -227,7 +227,7 @@ int pie(struct stat_list *dist_stats,	/* list of distribution statistics */
 		    draw = YES;
 		    draw = YES;
 		    if (is_fp) {
 		    if (is_fp) {
 			if (cat_ranges)
 			if (cat_ranges)
-			    Rast_get_ith_d_raster_cat(&cats, (CELL) i, &dmin, &dmax);
+			    Rast_get_ith_d_cat(&cats, (CELL) i, &dmin, &dmax);
 			else {
 			else {
 			    dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;
 			    dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;
 			    dmax = range_dmin + (i + 1) * (range_dmax - range_dmin) / nsteps;
 			    dmax = range_dmin + (i + 1) * (range_dmax - range_dmin) / nsteps;

+ 6 - 6
display/d.legend/main.c

@@ -372,9 +372,9 @@ int main(int argc, char **argv)
 	for (i = min_ind, j = 1, k = 0; j <= do_cats && i <= max_ind;
 	for (i = min_ind, j = 1, k = 0; j <= do_cats && i <= max_ind;
 	     j++, i += thin) {
 	     j++, i += thin) {
 	    if (!flip)
 	    if (!flip)
-		cstr = Rast_get_cat(i, &cats);
+		cstr = Rast_get_c_cat(&i, &cats);
 	    else
 	    else
-		cstr = Rast_get_cat((max_ind - (i - min_ind)), &cats);
+		cstr = Rast_get_c_cat((max_ind - (i - min_ind)), &cats);
 
 
 	    if (!use_catlist)
 	    if (!use_catlist)
 		catlist[j - 1] = (double)i;
 		catlist[j - 1] = (double)i;
@@ -405,7 +405,7 @@ int main(int argc, char **argv)
 				  opt8->answers[i], min_ind, max_ind);
 				  opt8->answers[i], min_ind, max_ind);
 		}
 		}
 
 
-		cstr = Rast_get_cat(catlist[i], &cats);
+		cstr = Rast_get_c_cat(&(catlist[i]), &cats);
 		if (!cstr[0]) {	/* no cat label found, skip str output */
 		if (!cstr[0]) {	/* no cat label found, skip str output */
 		    if (hide_nodata)
 		    if (hide_nodata)
 			continue;
 			continue;
@@ -604,7 +604,7 @@ int main(int argc, char **argv)
 			max_ind - k * (double)(max_ind - min_ind) / (steps -
 			max_ind - k * (double)(max_ind - min_ind) / (steps -
 								     1);
 								     1);
 
 
-		cstr = Rast_get_cat(tcell, &cats);
+		cstr = Rast_get_c_cat(tcell, &cats);
 		if (!cstr[0])	/* no cats found, disable str output */
 		if (!cstr[0])	/* no cats found, disable str output */
 		    hide_catstr = 1;
 		    hide_catstr = 1;
 		else
 		else
@@ -780,9 +780,9 @@ int main(int argc, char **argv)
 	    /*              for(i=min_ind, j=1, k=0; j<=do_cats && i<=max_ind; j++, i+=thin)        */
 	    /*              for(i=min_ind, j=1, k=0; j<=do_cats && i<=max_ind; j++, i+=thin)        */
 	{
 	{
 	    if (!flip)
 	    if (!flip)
-		cstr = Rast_get_cat(catlist[i], &cats);
+		cstr = Rast_get_c_cat(&(catlist[i]), &cats);
 	    else
 	    else
-		cstr = Rast_get_cat(catlist[catlistCount - i - 1], &cats);
+		cstr = Rast_get_c_cat(&(catlist[catlistCount - i - 1]), &cats);
 
 
 
 
 	    if (!cstr[0]) {	/* no cat label found, skip str output */
 	    if (!cstr[0]) {	/* no cat label found, skip str output */

+ 2 - 2
display/d.what.rast/what.c

@@ -61,7 +61,7 @@ int what(int once, int terse, int colrow, char *fs, int width, int mwidth)
 			 "ERROR reading raster map", terse, fs, map_type[i]);
 			 "ERROR reading raster map", terse, fs, map_type[i]);
 	    else if (map_type[i] == CELL_TYPE) {
 	    else if (map_type[i] == CELL_TYPE) {
 		show_cat(width, mwidth, name[i], mapset[i], buf[col],
 		show_cat(width, mwidth, name[i], mapset[i], buf[col],
-			 Rast_get_c_raster_cat(&buf[col], &cats[i]), terse, fs,
+			 Rast_get_c_cat(&buf[col], &cats[i]), terse, fs,
 			 map_type[i]);
 			 map_type[i]);
 		continue;
 		continue;
 	    }
 	    }
@@ -79,7 +79,7 @@ int what(int once, int terse, int colrow, char *fs, int width, int mwidth)
 			  "ERROR reading fcell file", terse, fs);
 			  "ERROR reading fcell file", terse, fs);
 	    else
 	    else
 		show_dval(width, mwidth, name[i], mapset[i], dbuf[col],
 		show_dval(width, mwidth, name[i], mapset[i], dbuf[col],
-			  Rast_get_d_raster_cat(&dbuf[col], &cats[i]), terse,
+			  Rast_get_d_cat(&dbuf[col], &cats[i]), terse,
 			  fs);
 			  fs);
 	}
 	}
     }
     }

+ 1 - 1
imagery/i.gensig/get_train.c

@@ -48,7 +48,7 @@ int get_training_classes(struct files *files, struct Signature *S)
 	    S->sig[n].status = 1;
 	    S->sig[n].status = 1;
 	    S->sig[n].npoints = count;
 	    S->sig[n].npoints = count;
 	    strncpy(S->sig[n].desc,
 	    strncpy(S->sig[n].desc,
-		      Rast_get_cat(cat, &files->training_labels),
+		      Rast_get_c_cat(&cat, &files->training_labels),
 		      sizeof(S->sig[n].desc)
 		      sizeof(S->sig[n].desc)
 		);
 		);
 	    n++;
 	    n++;

+ 1 - 1
imagery/i.gensigset/get_train.c

@@ -48,7 +48,7 @@ int get_training_classes(struct parms *parms,
     while (Rast_next_cell_stat(&cat, &count, &cell_stats)) {
     while (Rast_next_cell_stat(&cat, &count, &cell_stats)) {
 	if (count > 1) {
 	if (count > 1) {
 	    Sig = I_NewClassSig(S);
 	    Sig = I_NewClassSig(S);
-	    I_SetClassTitle(Sig, Rast_get_cat(cat, &files->training_labels));
+	    I_SetClassTitle(Sig, Rast_get_c_cat(&cat, &files->training_labels));
 	    Sig->classnum = cat;
 	    Sig->classnum = cat;
 	    /* initialize this class with maxsubclasses (by allocating them) */
 	    /* initialize this class with maxsubclasses (by allocating them) */
 	    for (i = 0; i < parms->maxsubclasses; i++)
 	    for (i = 0; i < parms->maxsubclasses; i++)

+ 15 - 23
imagery/i.maxlik/main.c

@@ -38,6 +38,7 @@ int class_fd, reject_fd;
 char *class_name, *reject_name;
 char *class_name, *reject_name;
 double *B;
 double *B;
 double *P;
 double *P;
+CELL cat;
 
 
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 {
@@ -123,39 +124,30 @@ int main(int argc, char *argv[])
     if (reject_fd > 0)
     if (reject_fd > 0)
 	Rast_close_cell(reject_fd);
 	Rast_close_cell(reject_fd);
 
 
-    Rast_init_cats((CELL) S.nsigs, "Maximum Likelihood Classification", &cats);
+    Rast_init_cats("Maximum Likelihood Classification", &cats);
     for (i = 0; i < S.nsigs; i++) {
     for (i = 0; i < S.nsigs; i++) {
-	if (*S.sig[i].desc)
-	    Rast_set_cat((CELL) (i + 1), S.sig[i].desc, &cats);
+	if (*S.sig[i].desc) {
+	    cat = i + 1;
+	    Rast_set_c_cat(&cat, &cat, S.sig[i].desc, &cats);
+	}
     }
     }
     Rast_write_cats(class_name, &cats);
     Rast_write_cats(class_name, &cats);
     Rast_free_cats(&cats);
     Rast_free_cats(&cats);
 
 
     if (reject_fd > 0) {
     if (reject_fd > 0) {
 	char title[100];
 	char title[100];
-
+	char *label[] = { "no data", "0.1%", "0.5%",
+			  "1%", "2%", "5%", "10%",
+			  "20%", "30%", "50%", "70%",
+			  "80%", "90%", "95%", "98%",
+			  "99%", "100%", "bad" };
 	sprintf(title, "Rejection Probability for %s", class_name);
 	sprintf(title, "Rejection Probability for %s", class_name);
 
 
-	Rast_init_cats((CELL) 17, title, &cats);
+	Rast_init_cats(title, &cats);
 	Rast_set_cats_title(title, &cats);
 	Rast_set_cats_title(title, &cats);
-	Rast_set_cat((CELL) 0, "no data", &cats);
-	Rast_set_cat((CELL) 1, "0.1%", &cats);
-	Rast_set_cat((CELL) 2, "0.5%", &cats);
-	Rast_set_cat((CELL) 3, "1%", &cats);
-	Rast_set_cat((CELL) 4, "2%", &cats);
-	Rast_set_cat((CELL) 5, "5%", &cats);
-	Rast_set_cat((CELL) 6, "10%", &cats);
-	Rast_set_cat((CELL) 7, "20%", &cats);
-	Rast_set_cat((CELL) 8, "30%", &cats);
-	Rast_set_cat((CELL) 9, "50%", &cats);
-	Rast_set_cat((CELL) 10, "70%", &cats);
-	Rast_set_cat((CELL) 11, "80%", &cats);
-	Rast_set_cat((CELL) 12, "90%", &cats);
-	Rast_set_cat((CELL) 13, "95%", &cats);
-	Rast_set_cat((CELL) 14, "98%", &cats);
-	Rast_set_cat((CELL) 15, "99%", &cats);
-	Rast_set_cat((CELL) 16, "100%", &cats);
-	Rast_set_cat((CELL) 17, "bad", &cats);
+	for(i = 0; i < (int) (sizeof(label) / sizeof (char *)); i++) {
+	    Rast_set_c_cat(&i, &i, label[i], &cats);
+	}
 	Rast_write_cats(reject_name, &cats);
 	Rast_write_cats(reject_name, &cats);
 	Rast_free_cats(&cats);
 	Rast_free_cats(&cats);
 
 

+ 4 - 2
imagery/i.smap/labels.c

@@ -8,10 +8,12 @@ int create_output_labels(struct SigSet *S, struct files *files)
     int n;
     int n;
     struct ClassSig *C;
     struct ClassSig *C;
 
 
-    Rast_init_cats((CELL) 0, S->title, &files->output_labels);
+    Rast_init_cats(S->title, &files->output_labels);
     for (n = 0; n < S->nclasses; n++) {
     for (n = 0; n < S->nclasses; n++) {
 	C = &S->ClassSig[n];
 	C = &S->ClassSig[n];
-	Rast_set_cat((CELL) C->classnum, C->title, &files->output_labels);
+	Rast_set_c_cat((CELL*) &(C->classnum),
+		       (CELL*) &(C->classnum),
+		       C->title, &files->output_labels);
     }
     }
 
 
     return 0;
     return 0;

+ 32 - 42
include/raster.h

@@ -21,57 +21,47 @@ void Rast_unsuppress_masking(void);
 
 
 /* cats.c */
 /* cats.c */
 int Rast_read_cats(const char *, const char *, struct Categories *);
 int Rast_read_cats(const char *, const char *, struct Categories *);
-int Rast_read_raster_cats(const char *, const char *, struct Categories *);
 int Rast_read_vector_cats(const char *, const char *, struct Categories *);
 int Rast_read_vector_cats(const char *, const char *, struct Categories *);
-CELL Rast_number_of_cats(const char *, const char *);
+CELL Rast_get_max_c_cat(const char *, const char *);
 char *Rast_get_cats_title(const struct Categories *);
 char *Rast_get_cats_title(const struct Categories *);
-char *Rast_get_raster_cats_title(const struct Categories *);
-char *Rast_get_cat(CELL, struct Categories *);
-char *Rast_get_c_raster_cat(CELL *, struct Categories *);
-char *Rast_get_f_raster_cat(FCELL *, struct Categories *);
-char *Rast_get_d_raster_cat(DCELL *, struct Categories *);
-char *Rast_get_raster_cat(void *, struct Categories *, RASTER_MAP_TYPE);
-void Rast_unmark_raster_cats(struct Categories *);
-void Rast_mark_c_raster_cats(const CELL *, int, struct Categories *);
-void Rast_mark_f_raster_cats(const FCELL *, int, struct Categories *);
-void Rast_mark_d_raster_cats(const DCELL *, int, struct Categories *);
-int Rast_mark_raster_cats(const void *, int, struct Categories *, RASTER_MAP_TYPE);
-void Rast_rewind_raster_cats(struct Categories *);
-char *Rast_get_next_marked_d_raster_cat(struct Categories *, DCELL *, DCELL *,
+char *Rast_get_c_cat(CELL *, struct Categories *);
+char *Rast_get_f_cat(FCELL *, struct Categories *);
+char *Rast_get_d_cat(DCELL *, struct Categories *);
+char *Rast_get_cat(void *, struct Categories *, RASTER_MAP_TYPE);
+void Rast_unmark_cats(struct Categories *);
+void Rast_mark_c_cats(const CELL *, int, struct Categories *);
+void Rast_mark_f_cats(const FCELL *, int, struct Categories *);
+void Rast_mark_d_cats(const DCELL *, int, struct Categories *);
+int Rast_mark_cats(const void *, int, struct Categories *, RASTER_MAP_TYPE);
+void Rast_rewind_cats(struct Categories *);
+char *Rast_get_next_marked_d_cat(struct Categories *, DCELL *, DCELL *,
+				 long *);
+char *Rast_get_next_marked_c_cat(struct Categories *, CELL *, CELL *,
+				 long *);
+char *Rast_get_next_marked_f_cat(struct Categories *, FCELL *, FCELL *,
 				     long *);
 				     long *);
-char *Rast_get_next_marked_c_raster_cat(struct Categories *, CELL *, CELL *,
-				     long *);
-char *Rast_get_next_marked_f_raster_cat(struct Categories *, FCELL *, FCELL *,
-				     long *);
-char *Rast_get_next_marked_raster_cat(struct Categories *, void *, void *,
-				   long *, RASTER_MAP_TYPE);
-int Rast_set_cat(CELL, const char *, struct Categories *);
-int Rast_set_c_raster_cat(const CELL *, const CELL *, const char *, struct Categories *);
-int Rast_set_f_raster_cat(const FCELL *, const FCELL *, const char *, struct Categories *);
-int Rast_set_d_raster_cat(const DCELL *, const DCELL *, const char *, struct Categories *);
-int Rast_set_raster_cat(const void *, const void *, const char *, struct Categories *,
-		     RASTER_MAP_TYPE);
+char *Rast_get_next_marked_cat(struct Categories *, void *, void *,
+			       long *, RASTER_MAP_TYPE);
+int Rast_set_c_cat(const CELL *, const CELL *, const char *, struct Categories *);
+int Rast_set_f_cat(const FCELL *, const FCELL *, const char *, struct Categories *);
+int Rast_set_d_cat(const DCELL *, const DCELL *, const char *, struct Categories *);
+int Rast_set_cat(const void *, const void *, const char *, struct Categories *,
+		 RASTER_MAP_TYPE);
 int Rast_write_cats(const char *, struct Categories *);
 int Rast_write_cats(const char *, struct Categories *);
-int Rast_write_raster_cats(const char *, struct Categories *);
 int Rast_write_vector_cats(const char *, struct Categories *);
 int Rast_write_vector_cats(const char *, struct Categories *);
-char *Rast_get_ith_d_raster_cat(const struct Categories *, int, DCELL *,
-			     DCELL *);
-char *Rast_get_ith_f_raster_cat(const struct Categories *, int, void *, void *);
-char *Rast_get_ith_c_raster_cat(const struct Categories *, int, void *, void *);
-char *Rast_get_ith_raster_cat(const struct Categories *, int, void *, void *,
-			   RASTER_MAP_TYPE);
-void Rast_init_cats(CELL, const char *, struct Categories *);
-void Rast_init_raster_cats(const char *, struct Categories *);
+char *Rast_get_ith_d_cat(const struct Categories *, int, DCELL *,
+			 DCELL *);
+char *Rast_get_ith_f_cat(const struct Categories *, int, void *, void *);
+char *Rast_get_ith_c_cat(const struct Categories *, int, void *, void *);
+char *Rast_get_ith_cat(const struct Categories *, int, void *, void *,
+		       RASTER_MAP_TYPE);
+void Rast_init_cats(const char *, struct Categories *);
 void Rast_set_cats_title(const char *, struct Categories *);
 void Rast_set_cats_title(const char *, struct Categories *);
-void Rast_set_raster_cats_title(const char *, struct Categories *);
 void Rast_set_cats_fmt(const char *, double, double, double, double,
 void Rast_set_cats_fmt(const char *, double, double, double, double,
-		   struct Categories *);
-void Rast_set_raster_cats_fmt(const char *, double, double, double, double,
 			   struct Categories *);
 			   struct Categories *);
 void Rast_free_cats(struct Categories *);
 void Rast_free_cats(struct Categories *);
-void Rast_free_raster_cats(struct Categories *);
-void Rast_copy_raster_cats(struct Categories *, const struct Categories *);
-int Rast_number_of_raster_cats(struct Categories *);
+void Rast_copy_cats(struct Categories *, const struct Categories *);
+int Rast_number_of_cats(struct Categories *);
 int Rast_sort_cats(struct Categories *);
 int Rast_sort_cats(struct Categories *);
 
 
 /* cell_stats.c */
 /* cell_stats.c */

+ 7 - 7
lib/g3d/g3dcats.c

@@ -52,7 +52,7 @@ int G3d_writeCats(const char *name, struct Categories *cats)
 
 
     /* write the cat numbers:label */
     /* write the cat numbers:label */
     for (i = 0; i < Rast_quant_nof_rules(&cats->q); i++) {
     for (i = 0; i < Rast_quant_nof_rules(&cats->q); i++) {
-	descr = Rast_get_ith_d_raster_cat(cats, i, &val1, &val2);
+	descr = Rast_get_ith_d_cat(cats, i, &val1, &val2);
 	if ((cats->fmt && cats->fmt[0]) || (descr && descr[0])) {
 	if ((cats->fmt && cats->fmt[0]) || (descr && descr[0])) {
 	    if (val1 == val2) {
 	    if (val1 == val2) {
 		sprintf(str1, "%.10f", val1);
 		sprintf(str1, "%.10f", val1);
@@ -104,7 +104,7 @@ read_cats(const char *name, const char *mapset, struct Categories *pcats)
 	goto error;
 	goto error;
     G_strip(buff);
     G_strip(buff);
 
 
-    Rast_init_raster_cats(buff, pcats);
+    Rast_init_cats(buff, pcats);
     if (num >= 0)
     if (num >= 0)
 	pcats->num = num;
 	pcats->num = num;
 
 
@@ -119,7 +119,7 @@ read_cats(const char *name, const char *mapset, struct Categories *pcats)
 	    goto error;
 	    goto error;
 	if (sscanf(buff, "%f %f %f %f", &m1, &a1, &m2, &a2) != 4)
 	if (sscanf(buff, "%f %f %f %f", &m1, &a1, &m2, &a2) != 4)
 	    goto error;
 	    goto error;
-	Rast_set_raster_cats_fmt(fmt, m1, a1, m2, a2, pcats);
+	Rast_set_cats_fmt(fmt, m1, a1, m2, a2, pcats);
     }
     }
 
 
     /* Read all category names */
     /* Read all category names */
@@ -130,7 +130,7 @@ read_cats(const char *name, const char *mapset, struct Categories *pcats)
 	    break;
 	    break;
 
 
 	if (old)
 	if (old)
-	    Rast_set_cat(cat, buff, pcats);
+	    Rast_set_c_cat(&cat, &cat, buff, pcats);
 	else {
 	else {
 	    *label = 0;
 	    *label = 0;
 	    if (sscanf(buff, "%1s", label) != 1)
 	    if (sscanf(buff, "%1s", label) != 1)
@@ -141,11 +141,11 @@ read_cats(const char *name, const char *mapset, struct Categories *pcats)
 
 
 	    /* try to read a range of data */
 	    /* try to read a range of data */
 	    if (sscanf(buff, "%lf:%lf:%[^\n]", &val1, &val2, label) == 3)
 	    if (sscanf(buff, "%lf:%lf:%[^\n]", &val1, &val2, label) == 3)
-		Rast_set_raster_cat(&val1, &val2, label, pcats, DCELL_TYPE);
+		Rast_set_cat(&val1, &val2, label, pcats, DCELL_TYPE);
 	    else if (sscanf(buff, "%d:%[^\n]", &cat, label) >= 1)
 	    else if (sscanf(buff, "%d:%[^\n]", &cat, label) >= 1)
-		Rast_set_raster_cat(&cat, &cat, label, pcats, CELL_TYPE);
+		Rast_set_cat(&cat, &cat, label, pcats, CELL_TYPE);
 	    else if (sscanf(buff, "%lf:%[^\n]", &val1, label) >= 1)
 	    else if (sscanf(buff, "%lf:%[^\n]", &val1, label) >= 1)
-		Rast_set_raster_cat(&val1, &val1, label, pcats, DCELL_TYPE);
+		Rast_set_cat(&val1, &val1, label, pcats, DCELL_TYPE);
 	    else
 	    else
 		goto error;
 		goto error;
 	}
 	}

+ 1 - 1
lib/g3d/g3dclose.c

@@ -21,7 +21,7 @@ static int G3d_closeNew(G3D_Map * map)
     G3d_removeColor(map->fileName);
     G3d_removeColor(map->fileName);
 
 
     /* create empty cats file */
     /* create empty cats file */
-    Rast_init_raster_cats(NULL, &cats);
+    Rast_init_cats(NULL, &cats);
     G3d_writeCats(map->fileName, &cats);
     G3d_writeCats(map->fileName, &cats);
     Rast_free_cats(&cats);
     Rast_free_cats(&cats);
 
 

+ 4 - 4
lib/ogsf/Gs3.c

@@ -849,11 +849,11 @@ int Gs_get_cat_label(const char *filename, int drow, int dcol, char *catstr)
 	    }
 	    }
 	    else if (Rast_is_c_null_value(&buf[dcol])) {
 	    else if (Rast_is_c_null_value(&buf[dcol])) {
 		sprintf(catstr, "(NULL) %s",
 		sprintf(catstr, "(NULL) %s",
-			Rast_get_c_raster_cat(&buf[dcol], &cats));
+			Rast_get_c_cat(&buf[dcol], &cats));
 	    }
 	    }
 	    else {
 	    else {
 		sprintf(catstr, "(%d) %s", buf[dcol],
 		sprintf(catstr, "(%d) %s", buf[dcol],
-			Rast_get_c_raster_cat(&buf[dcol], &cats));
+			Rast_get_c_cat(&buf[dcol], &cats));
 	    }
 	    }
 
 
 	    G_free(buf);
 	    G_free(buf);
@@ -868,11 +868,11 @@ int Gs_get_cat_label(const char *filename, int drow, int dcol, char *catstr)
 	    }
 	    }
 	    else if (Rast_is_d_null_value(&dbuf[dcol])) {
 	    else if (Rast_is_d_null_value(&dbuf[dcol])) {
 		sprintf(catstr, "(NULL) %s",
 		sprintf(catstr, "(NULL) %s",
-			Rast_get_d_raster_cat(&dbuf[dcol], &cats));
+			Rast_get_d_cat(&dbuf[dcol], &cats));
 	    }
 	    }
 	    else {
 	    else {
 		sprintf(catstr, "(%g) %s", dbuf[dcol],
 		sprintf(catstr, "(%g) %s", dbuf[dcol],
-			Rast_get_d_raster_cat(&dbuf[dcol], &cats));
+			Rast_get_d_cat(&dbuf[dcol], &cats));
 	    }
 	    }
 
 
 	    G_free(dbuf);
 	    G_free(dbuf);

+ 5 - 5
lib/ogsf/gsd_legend.c

@@ -403,7 +403,7 @@ GLuint gsd_put_legend(const char *name, GLuint fontbase, int size, int *flags,
 		if (is_fp) {
 		if (is_fp) {
 		    tdcell = discrete ? Listcats[k] : labvals[k];
 		    tdcell = discrete ? Listcats[k] : labvals[k];
 		    if (cat_labs) {
 		    if (cat_labs) {
-			cstr = Rast_get_d_raster_cat(&tdcell, &cats);
+			cstr = Rast_get_d_cat(&tdcell, &cats);
 		    }
 		    }
 		    if (cat_labs && !cat_vals) {
 		    if (cat_labs && !cat_vals) {
 			sprintf(buff, "%s", cstr);
 			sprintf(buff, "%s", cstr);
@@ -424,10 +424,10 @@ GLuint gsd_put_legend(const char *name, GLuint fontbase, int size, int *flags,
 		    tcell = discrete ? Listnum ?
 		    tcell = discrete ? Listnum ?
 			Listcats[k] : min + k : labvals[k];
 			Listcats[k] : min + k : labvals[k];
 		    if (cat_labs && !cat_vals)
 		    if (cat_labs && !cat_vals)
-			sprintf(buff, "%s", Rast_get_cat(tcell, &cats));
+			sprintf(buff, "%s", Rast_get_c_cat(&tcell, &cats));
 		    else {
 		    else {
 			if (cat_labs && cat_vals) {
 			if (cat_labs && cat_vals) {
-			    cstr = Rast_get_cat(tcell, &cats);
+			    cstr = Rast_get_c_cat(&tcell, &cats);
 			    if (cstr[0])
 			    if (cstr[0])
 				sprintf(buff, "%*d) %s", iprec, tcell, cstr);
 				sprintf(buff, "%*d) %s", iprec, tcell, cstr);
 			    else
 			    else
@@ -635,9 +635,9 @@ GLuint gsd_put_legend(const char *name, GLuint fontbase, int size, int *flags,
 		    labpos = 1. - labpos;
 		    labpos = 1. - labpos;
 		if (cat_labs) {
 		if (cat_labs) {
 		    if (!is_fp)
 		    if (!is_fp)
-			cstr = Rast_get_cat(tcell, &cats);
+			cstr = Rast_get_c_cat(&tcell, &cats);
 		    else
 		    else
-			cstr = Rast_get_d_raster_cat(&tdcell, &cats);
+			cstr = Rast_get_d_cat(&tdcell, &cats);
 		}
 		}
 		if (cat_labs && !cat_vals)
 		if (cat_labs && !cat_vals)
 		    sprintf(buff, "%s", cstr);
 		    sprintf(buff, "%s", cstr);

+ 131 - 298
lib/raster/cats.c

@@ -89,14 +89,12 @@ static struct Categories save_cats;
 /*!
 /*!
  * \brief Read raster category file
  * \brief Read raster category file
  *
  *
- * \todo Remove, the function Rast_read_raster_cats()
- *
  * The category file for raster map <i>name</i> in <i>mapset</i> is
  * The category file for raster map <i>name</i> in <i>mapset</i> is
  * read into the <i>cats</i> structure. If there is an error reading
  * read into the <i>cats</i> structure. If there is an error reading
  * the category file, a diagnostic message is printed and -1 is
  * the category file, a diagnostic message is printed and -1 is
  * returned. Otherwise, 0 is returned.
  * returned. Otherwise, 0 is returned.
  *
  *
- * \param name map name
+ * \param name raster map name
  * \param mapset mapset name
  * \param mapset mapset name
  * \param[out] cats pointer to Cats structure
  * \param[out] cats pointer to Cats structure
  * 
  * 
@@ -104,44 +102,21 @@ static struct Categories save_cats;
  * \return 0 on success
  * \return 0 on success
  */
  */
 int Rast_read_cats(const char *name,
 int Rast_read_cats(const char *name,
-		const char *mapset, struct Categories *pcats)
+		   const char *mapset, struct Categories *pcats)
 {
 {
-    return Rast_read_raster_cats(name, mapset, pcats);
-}
-
-/*!
- * \brief Read raster category file
- *
- * The category file for raster map <i>name</i> in <i>mapset</i> is
- * read into the <i>cats</i> structure. If there is an error reading
- * the category file, a diagnostic message is printed and -1 is
- * returned. Otherwise, 0 is returned.
- *
- * \param name map name
- * \param mapset mapset name
- * \param[out] cats pointer to Cats structure
- * 
- * \return -1 on error
- * \return 0 on success
- */
-int Rast_read_raster_cats(const char *name,
-		       const char *mapset, struct Categories *pcats)
-{
-    char *type;
-
     switch (read_cats("cats", name, mapset, pcats, 1)) {
     switch (read_cats("cats", name, mapset, pcats, 1)) {
     case -2:
     case -2:
-	type = "missing";
+	G_warning(_("Category support for <%s@%s> missing"),
+		  name, mapset);
 	break;
 	break;
     case -1:
     case -1:
-	type = "invalid";
+	G_warning(_("Category support for <%s@%s> invalid"),
+		  name, mapset);
 	break;
 	break;
     default:
     default:
 	return 0;
 	return 0;
     }
     }
 
 
-    G_warning(_("Category support for <%s@%s> %s"),
-	      name, mapset, type);
     return -1;
     return -1;
 }
 }
 
 
@@ -149,13 +124,15 @@ int Rast_read_raster_cats(const char *name,
  * \brief Read vector category file
  * \brief Read vector category file
  *
  *
  * <b>Note:</b> This function works with <b>old</b> vector format.
  * <b>Note:</b> This function works with <b>old</b> vector format.
-
- * The category file for vector map <i>name</i> in <i>mapset</i> is
- * read into the <i>cats</i> structure. If there is an error reading
- * the category file, a diagnostic message is printed and -1 is
+ *
+ * \todo: To be moved to the vector library
+ *
+ * The category  file for vector  map <i>name</i> in  <i>mapset</i> is
+ * read into the  <i>cats</i> structure. If there is  an error reading
+ * the  category file,  a  diagnostic  message is  printed  and -1  is
  * returned. Otherwise, 0 is returned.
  * returned. Otherwise, 0 is returned.
  *
  *
- * \param name map name
+ * \param name vector map name
  * \param mapset mapset name
  * \param mapset mapset name
  * \param[out] cats pointer to Cats structure
  * \param[out] cats pointer to Cats structure
  * 
  * 
@@ -165,34 +142,32 @@ int Rast_read_raster_cats(const char *name,
 int Rast_read_vector_cats(const char *name,
 int Rast_read_vector_cats(const char *name,
 		       const char *mapset, struct Categories *pcats)
 		       const char *mapset, struct Categories *pcats)
 {
 {
-    char *type;
-
     switch (read_cats("dig_cats", name, mapset, pcats, 1)) {
     switch (read_cats("dig_cats", name, mapset, pcats, 1)) {
     case -2:
     case -2:
-	type = "missing";
+	G_warning(_("Category support for vector map <%s@%s> missing"),
+	      name, mapset);
 	break;
 	break;
     case -1:
     case -1:
-	type = "invalid";
+	G_warning(_("Category support for vector map <%s@%s> invalid"),
+	      name, mapset);
 	break;
 	break;
     default:
     default:
 	return 0;
 	return 0;
     }
     }
 
 
-    G_warning(_("Category support for vector map <%s@%s> %s"),
-	      name, mapset, type);
     return -1;
     return -1;
 }
 }
 
 
 /*!
 /*!
   \brief Get number of categories
   \brief Get number of categories
 
 
-  \param name map name
+  \param name raster map name
   \param mapset mapset name
   \param mapset mapset name
 
 
   \return -1 on error
   \return -1 on error
   \return number of cats
   \return number of cats
 */
 */
-CELL Rast_number_of_cats(const char *name, const char *mapset)
+CELL Rast_get_max_c_cat(const char *name, const char *mapset)
 {
 {
     struct Range range;
     struct Range range;
     CELL min, max;
     CELL min, max;
@@ -248,7 +223,7 @@ static CELL read_cats(const char *element,
     G_strip(buff);
     G_strip(buff);
     /*    G_ascii_check(buff) ; */
     /*    G_ascii_check(buff) ; */
 
 
-    Rast_init_raster_cats(buff, pcats);
+    Rast_init_cats(buff, pcats);
     if (num >= 0)
     if (num >= 0)
 	pcats->num = num;
 	pcats->num = num;
 
 
@@ -263,7 +238,7 @@ static CELL read_cats(const char *element,
 	    goto error;
 	    goto error;
 	if (sscanf(buff, "%f %f %f %f", &m1, &a1, &m2, &a2) != 4)
 	if (sscanf(buff, "%f %f %f %f", &m1, &a1, &m2, &a2) != 4)
 	    goto error;
 	    goto error;
-	Rast_set_raster_cats_fmt(fmt, m1, a1, m2, a2, pcats);
+	Rast_set_cats_fmt(fmt, m1, a1, m2, a2, pcats);
     }
     }
 
 
     /* Read all category names */
     /* Read all category names */
@@ -273,7 +248,7 @@ static CELL read_cats(const char *element,
 	if (G_getl(buff, sizeof buff, fd) == 0)
 	if (G_getl(buff, sizeof buff, fd) == 0)
 	    break;
 	    break;
 	if (old)
 	if (old)
-	    Rast_set_cat(cat, buff, pcats);
+	    Rast_set_c_cat(&cat, &cat, buff, pcats);
 	else {
 	else {
 	    *label = 0;
 	    *label = 0;
 	    if (sscanf(buff, "%1s", label) != 1)
 	    if (sscanf(buff, "%1s", label) != 1)
@@ -284,11 +259,11 @@ static CELL read_cats(const char *element,
 	    /* for fp maps try to read a range of data */
 	    /* for fp maps try to read a range of data */
 	    if (fp_map
 	    if (fp_map
 		&& sscanf(buff, "%lf:%lf:%[^\n]", &val1, &val2, label) == 3)
 		&& sscanf(buff, "%lf:%lf:%[^\n]", &val1, &val2, label) == 3)
-		Rast_set_raster_cat(&val1, &val2, label, pcats, DCELL_TYPE);
+		Rast_set_cat(&val1, &val2, label, pcats, DCELL_TYPE);
 	    else if (sscanf(buff, "%d:%[^\n]", &cat, label) >= 1)
 	    else if (sscanf(buff, "%d:%[^\n]", &cat, label) >= 1)
-		Rast_set_raster_cat(&cat, &cat, label, pcats, CELL_TYPE);
+		Rast_set_cat(&cat, &cat, label, pcats, CELL_TYPE);
 	    else if (sscanf(buff, "%lf:%[^\n]", &val1, label) >= 1)
 	    else if (sscanf(buff, "%lf:%[^\n]", &val1, label) >= 1)
-		Rast_set_raster_cat(&val1, &val1, label, pcats, DCELL_TYPE);
+		Rast_set_cat(&val1, &val1, label, pcats, DCELL_TYPE);
 	    else
 	    else
 		goto error;
 		goto error;
 	}
 	}
@@ -304,7 +279,7 @@ static CELL read_cats(const char *element,
 /*!
 /*!
  * \brief Get title from category structure struct
  * \brief Get title from category structure struct
  *
  *
- * \todo Remove from GIS Library, replace by Rast_get_raster_cats_title().
+ * \todo Remove from GIS Library, replace by Rast_get_c_cats_title().
  *
  *
  * Map layers store a one-line title in the category structure as
  * Map layers store a one-line title in the category structure as
  * well. This routine returns a pointer to the title contained in the
  * well. This routine returns a pointer to the title contained in the
@@ -317,55 +292,12 @@ static CELL read_cats(const char *element,
  * \return title
  * \return title
  * \return "" if missing
  * \return "" if missing
  */
  */
-
 char *Rast_get_cats_title(const struct Categories *pcats)
 char *Rast_get_cats_title(const struct Categories *pcats)
 {
 {
-    return Rast_get_raster_cats_title(pcats);
-}
-
-/*!
- * \brief Get raster cats title
- *
- * Returns pointer to a string with title.
- *
- * \param pcats pointer to Categories structure
- *
- * \return title
- * \return "" if missing
- */
-
-char *Rast_get_raster_cats_title(const struct Categories *pcats)
-{
     return pcats->title ? pcats->title : "";
     return pcats->title ? pcats->title : "";
 }
 }
 
 
 /*!
 /*!
- * \brief Get a raster category label
- *
- * \todo Remove from GIS Library, replaced by Rast_get_c_raster_cat().
- *
- * This routine looks up category <i>num</i> in the <i>pcats</i>
- * structure and returns a pointer to a string which is the label for
- * the category. A legal pointer is always returned. If the category
- * does not exist in <i>pcats</i>, then a pointer to the empty string
- * "" is returned.
- *
- * <b>Warning:</b> The pointer that is returned points to a hidden
- * static buffer. Successive calls to Rast_get_cat() overwrite this
- * buffer.
- *
- * \param num cell value
- * \param pcats pointer to Categories structure
- *
- * \return pointer to category label
- * \return "" if category is not found
- */
-char *Rast_get_cat(CELL num, struct Categories *pcats)
-{
-    return Rast_get_c_raster_cat(&num, pcats);
-}
-
-/*!
  * \brief Get a raster category label (CELL)
  * \brief Get a raster category label (CELL)
  *
  *
  * This routine looks up category <i>rast</i> in the <i>pcats</i>
  * This routine looks up category <i>rast</i> in the <i>pcats</i>
@@ -375,7 +307,7 @@ char *Rast_get_cat(CELL num, struct Categories *pcats)
  * "" is returned.
  * "" is returned.
  *
  *
  * <b>Warning:</b> The pointer that is returned points to a hidden
  * <b>Warning:</b> The pointer that is returned points to a hidden
- * static buffer. Successive calls to Rast_get_cat() overwrite this
+ * static buffer. Successive calls to Rast_get_c_cat() overwrite this
  * buffer.
  * buffer.
  *
  *
  * \param rast cell value
  * \param rast cell value
@@ -384,9 +316,9 @@ char *Rast_get_cat(CELL num, struct Categories *pcats)
  * \return pointer to category label
  * \return pointer to category label
  * \return "" if category is not found
  * \return "" if category is not found
  */
  */
-char *Rast_get_c_raster_cat(CELL * rast, struct Categories *pcats)
+char *Rast_get_c_cat(CELL * rast, struct Categories *pcats)
 {
 {
-    return Rast_get_raster_cat(rast, pcats, CELL_TYPE);
+    return Rast_get_cat(rast, pcats, CELL_TYPE);
 }
 }
 
 
 /*!
 /*!
@@ -399,7 +331,7 @@ char *Rast_get_c_raster_cat(CELL * rast, struct Categories *pcats)
  * "" is returned.
  * "" is returned.
  *
  *
  * <b>Warning:</b> The pointer that is returned points to a hidden
  * <b>Warning:</b> The pointer that is returned points to a hidden
- * static buffer. Successive calls to Rast_get_cat() overwrite this
+ * static buffer. Successive calls to Rast_get_c_cat() overwrite this
  * buffer.
  * buffer.
  *
  *
  * \param rast cell value
  * \param rast cell value
@@ -408,9 +340,9 @@ char *Rast_get_c_raster_cat(CELL * rast, struct Categories *pcats)
  * \return pointer to category label
  * \return pointer to category label
  * \return "" if category is not found
  * \return "" if category is not found
  */
  */
-char *Rast_get_f_raster_cat(FCELL * rast, struct Categories *pcats)
+char *Rast_get_f_cat(FCELL * rast, struct Categories *pcats)
 {
 {
-    return Rast_get_raster_cat(rast, pcats, FCELL_TYPE);
+    return Rast_get_cat(rast, pcats, FCELL_TYPE);
 }
 }
 
 
 /*!
 /*!
@@ -423,7 +355,7 @@ char *Rast_get_f_raster_cat(FCELL * rast, struct Categories *pcats)
  * "" is returned.
  * "" is returned.
  *
  *
  * <b>Warning:</b> The pointer that is returned points to a hidden
  * <b>Warning:</b> The pointer that is returned points to a hidden
- * static buffer. Successive calls to Rast_get_cat() overwrite this
+ * static buffer. Successive calls to Rast_get_c_cat() overwrite this
  * buffer.
  * buffer.
  *
  *
  * \param rast cell value
  * \param rast cell value
@@ -432,9 +364,9 @@ char *Rast_get_f_raster_cat(FCELL * rast, struct Categories *pcats)
  * \return pointer to category label
  * \return pointer to category label
  * \return "" if category is not found
  * \return "" if category is not found
  */
  */
-char *Rast_get_d_raster_cat(DCELL * rast, struct Categories *pcats)
+char *Rast_get_d_cat(DCELL * rast, struct Categories *pcats)
 {
 {
-    return Rast_get_raster_cat(rast, pcats, DCELL_TYPE);
+    return Rast_get_cat(rast, pcats, DCELL_TYPE);
 }
 }
 
 
 /*!
 /*!
@@ -447,7 +379,7 @@ char *Rast_get_d_raster_cat(DCELL * rast, struct Categories *pcats)
  * "" is returned.
  * "" is returned.
  *
  *
  * <b>Warning:</b> The pointer that is returned points to a hidden
  * <b>Warning:</b> The pointer that is returned points to a hidden
- * static buffer. Successive calls to Rast_get_cat() overwrite this
+ * static buffer. Successive calls to Rast_get_c_cat() overwrite this
  * buffer.
  * buffer.
  *
  *
  * \param rast cell value
  * \param rast cell value
@@ -457,8 +389,8 @@ char *Rast_get_d_raster_cat(DCELL * rast, struct Categories *pcats)
  * \return pointer to category label
  * \return pointer to category label
  * \return "" if category is not found
  * \return "" if category is not found
  */
  */
-char *Rast_get_raster_cat(void *rast,
-		       struct Categories *pcats, RASTER_MAP_TYPE data_type)
+char *Rast_get_cat(void *rast,
+		   struct Categories *pcats, RASTER_MAP_TYPE data_type)
 {
 {
     static char label[1024];
     static char label[1024];
     char *f, *l, *v;
     char *f, *l, *v;
@@ -477,7 +409,7 @@ char *Rast_get_raster_cat(void *rast,
     val = Rast_get_raster_value_d(rast, data_type);
     val = Rast_get_raster_value_d(rast, data_type);
     i = Rast_quant_get_cell_value(&pcats->q, val);
     i = Rast_quant_get_cell_value(&pcats->q, val);
 
 
-    G_debug(5, "Rast_get_raster_cat(): val %lf found i %d", val, i);
+    G_debug(5, "Rast_get_cat(): val %lf found i %d", val, i);
 
 
     if (!Rast_is_c_null_value(&i) && i < pcats->ncats) {
     if (!Rast_is_c_null_value(&i) && i < pcats->ncats) {
 	if (pcats->labels[i] != NULL)
 	if (pcats->labels[i] != NULL)
@@ -524,7 +456,7 @@ char *Rast_get_raster_cat(void *rast,
  * \brief Sets marks for all categories to 0.
  * \brief Sets marks for all categories to 0.
  *
  *
  * This initializes Categories structure for subsequest calls to
  * This initializes Categories structure for subsequest calls to
- * Rast_mark_raster_cats() for each row of data, where non-zero mark for
+ * Rast_mark_cats() for each row of data, where non-zero mark for
  * i-th label means that some of the cells in rast_row are labeled
  * i-th label means that some of the cells in rast_row are labeled
  * with i-th label and fall into i-th data range. These marks help
  * with i-th label and fall into i-th data range. These marks help
  * determine from the Categories structure which labels were used and
  * determine from the Categories structure which labels were used and
@@ -532,7 +464,7 @@ char *Rast_get_raster_cat(void *rast,
  *
  *
  * \param pcats pointer to Categories structure
  * \param pcats pointer to Categories structure
  */
  */
-void Rast_unmark_raster_cats(struct Categories *pcats)
+void Rast_unmark_cats(struct Categories *pcats)
 {
 {
     int i;
     int i;
 
 
@@ -555,10 +487,10 @@ void Rast_unmark_raster_cats(struct Categories *pcats)
  * \param pcats pointer to Categories structure
  * \param pcats pointer to Categories structure
  *
  *
  */
  */
-void Rast_mark_c_raster_cats(const CELL * rast_row,
-			  int ncols, struct Categories *pcats)
+void Rast_mark_c_cats(const CELL * rast_row,
+		      int ncols, struct Categories *pcats)
 {
 {
-    Rast_mark_raster_cats(rast_row, ncols, pcats, CELL_TYPE);
+    Rast_mark_cats(rast_row, ncols, pcats, CELL_TYPE);
 }
 }
 
 
 /*!
 /*!
@@ -576,10 +508,10 @@ void Rast_mark_c_raster_cats(const CELL * rast_row,
  * \param pcats pointer to Categories structure
  * \param pcats pointer to Categories structure
  *
  *
  */
  */
-void Rast_mark_f_raster_cats(const FCELL * rast_row,
-			 int ncols, struct Categories *pcats)
+void Rast_mark_f_cats(const FCELL * rast_row,
+		      int ncols, struct Categories *pcats)
 {
 {
-    Rast_mark_raster_cats(rast_row, ncols, pcats, FCELL_TYPE);
+    Rast_mark_cats(rast_row, ncols, pcats, FCELL_TYPE);
 }
 }
 
 
 /*!
 /*!
@@ -597,10 +529,10 @@ void Rast_mark_f_raster_cats(const FCELL * rast_row,
  * \param pcats pointer to Categories structure
  * \param pcats pointer to Categories structure
  *
  *
  */
  */
-void Rast_mark_d_raster_cats(const DCELL * rast_row,
-			  int ncols, struct Categories *pcats)
+void Rast_mark_d_cats(const DCELL * rast_row,
+		      int ncols, struct Categories *pcats)
 {
 {
-    Rast_mark_raster_cats(rast_row, ncols, pcats, DCELL_TYPE);
+    Rast_mark_cats(rast_row, ncols, pcats, DCELL_TYPE);
 }
 }
 
 
 /*!
 /*!
@@ -620,9 +552,9 @@ void Rast_mark_d_raster_cats(const DCELL * rast_row,
  * \return -1 on error
  * \return -1 on error
  * \return 1 on success
  * \return 1 on success
  */
  */
-int Rast_mark_raster_cats(const void *rast_row,
-		       int ncols, struct Categories *pcats,
-		       RASTER_MAP_TYPE data_type)
+int Rast_mark_cats(const void *rast_row,
+		   int ncols, struct Categories *pcats,
+		   RASTER_MAP_TYPE data_type)
 {
 {
     CELL i;
     CELL i;
 
 
@@ -642,12 +574,12 @@ int Rast_mark_raster_cats(const void *rast_row,
 /*!
 /*!
  * \brief Rewind raster categories
  * \brief Rewind raster categories
  *
  *
- * After call to this function Rast_get_next_marked_raster_cat() returns
+ * After call to this function Rast_get_next_marked_cat() returns
  * the first marked cat label.
  * the first marked cat label.
  *
  *
  * \param pcats pointer to Categories structure
  * \param pcats pointer to Categories structure
  */
  */
-void Rast_rewind_raster_cats(struct Categories *pcats)
+void Rast_rewind_cats(struct Categories *pcats)
 {
 {
     pcats->last_marked_rule = -1;
     pcats->last_marked_rule = -1;
 }
 }
@@ -662,9 +594,9 @@ void Rast_rewind_raster_cats(struct Categories *pcats)
   \return NULL if not found
   \return NULL if not found
   \return description if found
   \return description if found
 */
 */
-char *Rast_get_next_marked_d_raster_cat(struct Categories *pcats,
-				     DCELL * rast1, DCELL * rast2,
-				     long *count)
+char *Rast_get_next_marked_d_cat(struct Categories *pcats,
+				 DCELL * rast1, DCELL * rast2,
+				 long *count)
 {
 {
     char *descr = NULL;
     char *descr = NULL;
     int found, i;
     int found, i;
@@ -675,7 +607,7 @@ char *Rast_get_next_marked_d_raster_cat(struct Categories *pcats,
     G_debug(3, "last marked %d nrules %d\n", pcats->last_marked_rule, Rast_quant_nof_rules(&pcats->q));
     G_debug(3, "last marked %d nrules %d\n", pcats->last_marked_rule, Rast_quant_nof_rules(&pcats->q));
 
 
     for (i = pcats->last_marked_rule + 1; i < Rast_quant_nof_rules(&pcats->q); i++) {
     for (i = pcats->last_marked_rule + 1; i < Rast_quant_nof_rules(&pcats->q); i++) {
-	descr = Rast_get_ith_d_raster_cat(pcats, i, rast1, rast2);
+	descr = Rast_get_ith_d_cat(pcats, i, rast1, rast2);
 	G_debug(5, "%d %d", i, pcats->marks[i]);
 	G_debug(5, "%d %d", i, pcats->marks[i]);
 	if (pcats->marks[i]) {
 	if (pcats->marks[i]) {
 	    found = 1;
 	    found = 1;
@@ -701,11 +633,11 @@ char *Rast_get_next_marked_d_raster_cat(struct Categories *pcats,
   \return NULL if not found
   \return NULL if not found
   \return description if found
   \return description if found
 */
 */
-char *Rast_get_next_marked_c_raster_cat(struct Categories *pcats,
-				     CELL * rast1, CELL * rast2,
-				     long *count)
+char *Rast_get_next_marked_c_cat(struct Categories *pcats,
+				 CELL * rast1, CELL * rast2,
+				 long *count)
 {
 {
-    return Rast_get_next_marked_raster_cat(pcats, rast1, rast2, count,
+    return Rast_get_next_marked_cat(pcats, rast1, rast2, count,
 					CELL_TYPE);
 					CELL_TYPE);
 }
 }
 
 
@@ -719,11 +651,11 @@ char *Rast_get_next_marked_c_raster_cat(struct Categories *pcats,
   \return NULL if not found
   \return NULL if not found
   \return description if found
   \return description if found
 */
 */
-char *Rast_get_next_marked_f_raster_cat(struct Categories *pcats,
+char *Rast_get_next_marked_f_cat(struct Categories *pcats,
 				     FCELL * rast1, FCELL * rast2,
 				     FCELL * rast1, FCELL * rast2,
 				     long *count)
 				     long *count)
 {
 {
-    return Rast_get_next_marked_raster_cat(pcats, rast1, rast2, count,
+    return Rast_get_next_marked_cat(pcats, rast1, rast2, count,
 					FCELL_TYPE);
 					FCELL_TYPE);
 }
 }
 
 
@@ -738,14 +670,14 @@ char *Rast_get_next_marked_f_raster_cat(struct Categories *pcats,
   \return NULL if not found
   \return NULL if not found
   \return description if found
   \return description if found
 */
 */
-char *Rast_get_next_marked_raster_cat(struct Categories *pcats,
-				   void *rast1, void *rast2,
-				   long *count, RASTER_MAP_TYPE data_type)
+char *Rast_get_next_marked_cat(struct Categories *pcats,
+			       void *rast1, void *rast2,
+			       long *count, RASTER_MAP_TYPE data_type)
 {
 {
     DCELL val1, val2;
     DCELL val1, val2;
     char *lab;
     char *lab;
 
 
-    lab = Rast_get_next_marked_d_raster_cat(pcats, &val1, &val2, count);
+    lab = Rast_get_next_marked_d_cat(pcats, &val1, &val2, count);
     Rast_set_raster_value_d(rast1, val1, data_type);
     Rast_set_raster_value_d(rast1, val1, data_type);
     Rast_set_raster_value_d(rast2, val2, data_type);
     Rast_set_raster_value_d(rast2, val2, data_type);
     return lab;
     return lab;
@@ -818,29 +750,6 @@ static void get_cond(char **f, char *value, DCELL val)
     *f = ff;
     *f = ff;
 }
 }
 
 
-
-/*!
- * \brief Set a raster category label
- *
- * \todo To be removed, replaced by Rast_set_c_raster_cat().
- *
- * The <i>label</i> is copied into the <i>pcats</i> structure for
- * category <i>num</i>.
- *
- * \param num raster cell
- * \param label category label
- * \param pcats pointer to Categories structure
- *
- * \return -1 on error
- * \return 0 if null value detected
- * \return 1 on success
- */
-int Rast_set_cat(CELL num, const char *label, struct Categories *pcats)
-{
-    return Rast_set_c_raster_cat(&num, &num, label, pcats);
-}
-
-
 /*!
 /*!
  * \brief Set a raster category label (CELL)
  * \brief Set a raster category label (CELL)
  *
  *
@@ -855,10 +764,10 @@ int Rast_set_cat(CELL num, const char *label, struct Categories *pcats)
  * \return 0 if null value detected
  * \return 0 if null value detected
  * \return 1 on success
  * \return 1 on success
  */
  */
-int Rast_set_c_raster_cat(const CELL * rast1, const CELL * rast2,
-		       const char *label, struct Categories *pcats)
+int Rast_set_c_cat(const CELL * rast1, const CELL * rast2,
+		   const char *label, struct Categories *pcats)
 {
 {
-    return Rast_set_raster_cat(rast1, rast2, label, pcats, CELL_TYPE);
+    return Rast_set_cat(rast1, rast2, label, pcats, CELL_TYPE);
 }
 }
 
 
 /*!
 /*!
@@ -873,10 +782,10 @@ int Rast_set_c_raster_cat(const CELL * rast1, const CELL * rast2,
  *
  *
  * \return
  * \return
  */
  */
-int Rast_set_f_raster_cat(const FCELL * rast1, const FCELL * rast2,
-		       const char *label, struct Categories *pcats)
+int Rast_set_f_cat(const FCELL * rast1, const FCELL * rast2,
+		   const char *label, struct Categories *pcats)
 {
 {
-    return Rast_set_raster_cat(rast1, rast2, label, pcats, FCELL_TYPE);
+    return Rast_set_cat(rast1, rast2, label, pcats, FCELL_TYPE);
 }
 }
 
 
 /*!
 /*!
@@ -893,21 +802,21 @@ int Rast_set_f_raster_cat(const FCELL * rast1, const FCELL * rast2,
  * \return 0 if null value detected
  * \return 0 if null value detected
  * \return 1 on success
  * \return 1 on success
  */
  */
-int Rast_set_d_raster_cat(const DCELL * rast1, const DCELL * rast2,
-		       const char *label, struct Categories *pcats)
+int Rast_set_d_cat(const DCELL * rast1, const DCELL * rast2,
+		   const char *label, struct Categories *pcats)
 {
 {
     long len;
     long len;
     DCELL dtmp1, dtmp2;
     DCELL dtmp1, dtmp2;
     int i;
     int i;
     char *descr;
     char *descr;
 
 
-    /* DEBUG fprintf(stderr,"Rast_set_d_raster_cat(rast1 = %p,rast2 = %p,label = '%s',pcats = %p)\n",
+    /* DEBUG fprintf(stderr,"Rast_set_d_cat(rast1 = %p,rast2 = %p,label = '%s',pcats = %p)\n",
        rast1,rast2,label,pcats); */
        rast1,rast2,label,pcats); */
     if (Rast_is_d_null_value(rast1))
     if (Rast_is_d_null_value(rast1))
 	return 0;
 	return 0;
     if (Rast_is_d_null_value(rast2))
     if (Rast_is_d_null_value(rast2))
 	return 0;
 	return 0;
-    /* DEBUG fprintf (stderr, "Rast_set_d_raster_cat(): adding quant rule: %f %f %d %d\n", *rast1, *rast2, pcats->ncats, pcats->ncats); */
+    /* DEBUG fprintf (stderr, "Rast_set_d_cat(): adding quant rule: %f %f %d %d\n", *rast1, *rast2, pcats->ncats, pcats->ncats); */
     /* the set_cat() functions are used in many places to reset the labels
     /* the set_cat() functions are used in many places to reset the labels
        for the range (or cat) with existing label. In this case we don't
        for the range (or cat) with existing label. In this case we don't
        want to store both rules with identical range even though the result
        want to store both rules with identical range even though the result
@@ -917,7 +826,7 @@ int Rast_set_d_raster_cat(const DCELL * rast1, const DCELL * rast2,
        the label for this range has been sen, and if it has, overwrite it */
        the label for this range has been sen, and if it has, overwrite it */
 
 
     for (i = 0; i < pcats->ncats; i++) {
     for (i = 0; i < pcats->ncats; i++) {
-	descr = Rast_get_ith_d_raster_cat(pcats, i, &dtmp1, &dtmp2);
+	descr = Rast_get_ith_d_cat(pcats, i, &dtmp1, &dtmp2);
 	if ((dtmp1 == *rast1 && dtmp2 == *rast2)
 	if ((dtmp1 == *rast1 && dtmp2 == *rast2)
 	    || (dtmp1 == *rast2 && dtmp2 == *rast1)) {
 	    || (dtmp1 == *rast2 && dtmp2 == *rast1)) {
 	    if (pcats->labels[i] != NULL)
 	    if (pcats->labels[i] != NULL)
@@ -929,29 +838,29 @@ int Rast_set_d_raster_cat(const DCELL * rast1, const DCELL * rast2,
 	}
 	}
     }
     }
     /* when rule for this range does not exist */
     /* when rule for this range does not exist */
-    /* DEBUG fprintf (stderr, "Rast_set_d_raster_cat(): New rule: adding %d %p\n", i, pcats->labels); */
+    /* DEBUG fprintf (stderr, "Rast_set_d_cat(): New rule: adding %d %p\n", i, pcats->labels); */
     Rast_quant_add_rule(&pcats->q, *rast1, *rast2, pcats->ncats, pcats->ncats);
     Rast_quant_add_rule(&pcats->q, *rast1, *rast2, pcats->ncats, pcats->ncats);
     pcats->ncats++;
     pcats->ncats++;
     if (pcats->nalloc < pcats->ncats) {
     if (pcats->nalloc < pcats->ncats) {
-	/* DEBUG fprintf (stderr, "Rast_set_d_raster_cat(): need more space nalloc = %d ncats = %d\n", pcats->nalloc,pcats->ncats); */
+	/* DEBUG fprintf (stderr, "Rast_set_d_cat(): need more space nalloc = %d ncats = %d\n", pcats->nalloc,pcats->ncats); */
 	len = (pcats->nalloc + 256) * sizeof(char *);
 	len = (pcats->nalloc + 256) * sizeof(char *);
-	/* DEBUG fprintf (stderr, "Rast_set_d_raster_cat(): allocating %d labels(%d)\n", pcats->nalloc + 256,(int)len); */
+	/* DEBUG fprintf (stderr, "Rast_set_d_cat(): allocating %d labels(%d)\n", pcats->nalloc + 256,(int)len); */
 	if (len != (int)len) {	/* make sure len doesn't overflow int */
 	if (len != (int)len) {	/* make sure len doesn't overflow int */
 	    pcats->ncats--;
 	    pcats->ncats--;
 	    return -1;
 	    return -1;
 	}
 	}
-	/* DEBUG fprintf(stderr,"Rast_set_d_raster_cat(): pcats->nalloc = %d, pcats->labels = (%p), len = %d\n",pcats->nalloc,pcats->labels,(int)len); */
+	/* DEBUG fprintf(stderr,"Rast_set_d_cat(): pcats->nalloc = %d, pcats->labels = (%p), len = %d\n",pcats->nalloc,pcats->labels,(int)len); */
 	if (pcats->nalloc) {
 	if (pcats->nalloc) {
-	    /* DEBUG fprintf(stderr,"Rast_set_d_raster_cat(): Realloc-ing pcats->labels (%p)\n",pcats->labels); */
+	    /* DEBUG fprintf(stderr,"Rast_set_d_cat(): Realloc-ing pcats->labels (%p)\n",pcats->labels); */
 	    pcats->labels =
 	    pcats->labels =
 		(char **)G_realloc((char *)pcats->labels, (int)len);
 		(char **)G_realloc((char *)pcats->labels, (int)len);
 	}
 	}
 	else {
 	else {
-	    /* DEBUG fprintf(stderr,"Rast_set_d_raster_cat(): alloc-ing new labels pointer array\n"); */
+	    /* DEBUG fprintf(stderr,"Rast_set_d_cat(): alloc-ing new labels pointer array\n"); */
 	    pcats->labels = (char **)G_malloc((int)len);
 	    pcats->labels = (char **)G_malloc((int)len);
 	}
 	}
 	/* fflush(stderr); */
 	/* fflush(stderr); */
-	/* DEBUG fprintf (stderr, "Rast_set_d_raster_cats(): allocating %d marks(%d)\n", pcats->nalloc + 256,(int)len); */
+	/* DEBUG fprintf (stderr, "Rast_set_d_cats(): allocating %d marks(%d)\n", pcats->nalloc + 256,(int)len); */
 	len = (pcats->nalloc + 256) * sizeof(int);
 	len = (pcats->nalloc + 256) * sizeof(int);
 	if (len != (int)len) {	/* make sure len doesn't overflow int */
 	if (len != (int)len) {	/* make sure len doesn't overflow int */
 	    pcats->ncats--;
 	    pcats->ncats--;
@@ -963,7 +872,7 @@ int Rast_set_d_raster_cat(const DCELL * rast1, const DCELL * rast2,
 	    pcats->marks = (int *)G_malloc((int)len);
 	    pcats->marks = (int *)G_malloc((int)len);
 	pcats->nalloc += 256;
 	pcats->nalloc += 256;
     }
     }
-    /* DEBUG fprintf(stderr,"Rast_set_d_raster_cats(): store new label\n"); */
+    /* DEBUG fprintf(stderr,"Rast_set_d_cats(): store new label\n"); */
     pcats->labels[pcats->ncats - 1] = G_store(label);
     pcats->labels[pcats->ncats - 1] = G_store(label);
     G_newlines_to_spaces(pcats->labels[pcats->ncats - 1]);
     G_newlines_to_spaces(pcats->labels[pcats->ncats - 1]);
     G_strip(pcats->labels[pcats->ncats - 1]);
     G_strip(pcats->labels[pcats->ncats - 1]);
@@ -976,14 +885,14 @@ int Rast_set_d_raster_cat(const DCELL * rast1, const DCELL * rast2,
 	pcats->num = (CELL) * rast1;
 	pcats->num = (CELL) * rast1;
     if ((CELL) * rast2 > pcats->num)
     if ((CELL) * rast2 > pcats->num)
 	pcats->num = (CELL) * rast2;
 	pcats->num = (CELL) * rast2;
-    /* DEBUG fprintf(stderr,"Rast_set_d_raster_cat(): done\n"); */
+    /* DEBUG fprintf(stderr,"Rast_set_d_cat(): done\n"); */
     /* DEBUG fflush(stderr); */
     /* DEBUG fflush(stderr); */
     return 1;
     return 1;
 }
 }
 
 
 
 
 /*!
 /*!
- * \brief Set a raster category label (DCELL)
+ * \brief Set a raster category label
  *
  *
  * Adds the label for range <i>rast1</i> through <i>rast2</i> in
  * Adds the label for range <i>rast1</i> through <i>rast2</i> in
  * category structure <i>pcats</i>.
  * category structure <i>pcats</i>.
@@ -998,21 +907,21 @@ int Rast_set_d_raster_cat(const DCELL * rast1, const DCELL * rast2,
  * \return 1 on success
  * \return 1 on success
  */
  */
 
 
-int Rast_set_raster_cat(const void *rast1, const void *rast2,
-		     const char *label,
-		     struct Categories *pcats, RASTER_MAP_TYPE data_type)
+int Rast_set_cat(const void *rast1, const void *rast2,
+		 const char *label,
+		 struct Categories *pcats, RASTER_MAP_TYPE data_type)
 {
 {
     DCELL val1, val2;
     DCELL val1, val2;
 
 
     val1 = Rast_get_raster_value_d(rast1, data_type);
     val1 = Rast_get_raster_value_d(rast1, data_type);
     val2 = Rast_get_raster_value_d(rast2, data_type);
     val2 = Rast_get_raster_value_d(rast2, data_type);
-    return Rast_set_d_raster_cat(&val1, &val2, label, pcats);
+    return Rast_set_d_cat(&val1, &val2, label, pcats);
 }
 }
 
 
 /*!
 /*!
  * \brief Write raster category file
  * \brief Write raster category file
  *
  *
- * \todo To be removed, replaced by Rast_write_raster_cats().
+ * \todo To be removed, replaced by Rast_write_cats().
  *
  *
  * Writes the category file for the raster map <i>name</i> in the
  * Writes the category file for the raster map <i>name</i> in the
  * current mapset from the <i>cats</i> structure.
  * current mapset from the <i>cats</i> structure.
@@ -1029,29 +938,12 @@ int Rast_write_cats(const char *name, struct Categories *cats)
 }
 }
 
 
 /*!
 /*!
- * \brief Write raster category file
- *
- * \todo To be removed, replaced by Rast_write_raster_cats().
- *
- * Writes the category file for the raster map <i>name</i> in the
- * current mapset from the <i>cats</i> structure.
- *
- * \param name map name
- * \param cats pointer to Categories structure
- *
- * \return 1 on success
- * \return -1 is returned (no diagnostic is printed)
- */
-int Rast_write_raster_cats(const char *name, struct Categories *cats)
-{
-    return write_cats("cats", name, cats);
-}
-
-/*!
  * \brief Write vector category file
  * \brief Write vector category file
  *
  *
  * <b>Note:</b> Used for only old vector format!
  * <b>Note:</b> Used for only old vector format!
  *
  *
+ * \todo Move to the vector library.
+ *
  * \param name map name
  * \param name map name
  * \param cats pointer to Categories structure
  * \param cats pointer to Categories structure
  *
  *
@@ -1095,7 +987,7 @@ static int write_cats(const char *element, const char *name, struct Categories *
 
 
     /* write the cat numbers:label */
     /* write the cat numbers:label */
     for (i = 0; i < Rast_quant_nof_rules(&cats->q); i++) {
     for (i = 0; i < Rast_quant_nof_rules(&cats->q); i++) {
-	descr = Rast_get_ith_d_raster_cat(cats, i, &val1, &val2);
+	descr = Rast_get_ith_d_cat(cats, i, &val1, &val2);
 	if ((cats->fmt && cats->fmt[0])
 	if ((cats->fmt && cats->fmt[0])
 	    || (descr && descr[0])) {
 	    || (descr && descr[0])) {
 	    if (val1 == val2) {
 	    if (val1 == val2) {
@@ -1131,8 +1023,8 @@ static int write_cats(const char *element, const char *name, struct Categories *
  * \return "" on error
  * \return "" on error
  * \return pointer to category description
  * \return pointer to category description
  */
  */
-char *Rast_get_ith_d_raster_cat(const struct Categories *pcats,
-			     int i, DCELL * rast1, DCELL * rast2)
+char *Rast_get_ith_d_cat(const struct Categories *pcats,
+			 int i, DCELL * rast1, DCELL * rast2)
 {
 {
     int index;
     int index;
 
 
@@ -1159,14 +1051,14 @@ char *Rast_get_ith_d_raster_cat(const struct Categories *pcats,
  * \return "" on error
  * \return "" on error
  * \return pointer to category description
  * \return pointer to category description
  */
  */
-char *Rast_get_ith_f_raster_cat(const struct Categories *pcats,
-			     int i, void *rast1, void *rast2)
+char *Rast_get_ith_f_cat(const struct Categories *pcats,
+			 int i, void *rast1, void *rast2)
 {
 {
     RASTER_MAP_TYPE data_type = FCELL_TYPE;
     RASTER_MAP_TYPE data_type = FCELL_TYPE;
     char *tmp;
     char *tmp;
     DCELL val1, val2;
     DCELL val1, val2;
 
 
-    tmp = Rast_get_ith_d_raster_cat(pcats, i, &val1, &val2);
+    tmp = Rast_get_ith_d_cat(pcats, i, &val1, &val2);
     Rast_set_raster_value_d(rast1, val1, data_type);
     Rast_set_raster_value_d(rast1, val1, data_type);
     Rast_set_raster_value_d(rast2, val2, data_type);
     Rast_set_raster_value_d(rast2, val2, data_type);
     return tmp;
     return tmp;
@@ -1186,14 +1078,14 @@ char *Rast_get_ith_f_raster_cat(const struct Categories *pcats,
  * \return "" on error
  * \return "" on error
  * \return pointer to category description
  * \return pointer to category description
  */
  */
-char *Rast_get_ith_c_raster_cat(const struct Categories *pcats,
-			     int i, void *rast1, void *rast2)
+char *Rast_get_ith_c_cat(const struct Categories *pcats,
+			 int i, void *rast1, void *rast2)
 {
 {
     RASTER_MAP_TYPE data_type = CELL_TYPE;
     RASTER_MAP_TYPE data_type = CELL_TYPE;
     char *tmp;
     char *tmp;
     DCELL val1, val2;
     DCELL val1, val2;
 
 
-    tmp = Rast_get_ith_d_raster_cat(pcats, i, &val1, &val2);
+    tmp = Rast_get_ith_d_cat(pcats, i, &val1, &val2);
     Rast_set_raster_value_d(rast1, val1, data_type);
     Rast_set_raster_value_d(rast1, val1, data_type);
     Rast_set_raster_value_d(rast2, val2, data_type);
     Rast_set_raster_value_d(rast2, val2, data_type);
     return tmp;
     return tmp;
@@ -1214,13 +1106,13 @@ char *Rast_get_ith_c_raster_cat(const struct Categories *pcats,
  * \return "" on error
  * \return "" on error
  * \return pointer to category description
  * \return pointer to category description
  */
  */
-char *Rast_get_ith_raster_cat(const struct Categories *pcats, int i, void *rast1,
-			   void *rast2, RASTER_MAP_TYPE data_type)
+char *Rast_get_ith_cat(const struct Categories *pcats, int i, void *rast1,
+		       void *rast2, RASTER_MAP_TYPE data_type)
 {
 {
     char *tmp;
     char *tmp;
     DCELL val1, val2;
     DCELL val1, val2;
 
 
-    tmp = Rast_get_ith_d_raster_cat(pcats, i, &val1, &val2);
+    tmp = Rast_get_ith_d_cat(pcats, i, &val1, &val2);
     Rast_set_raster_value_d(rast1, val1, data_type);
     Rast_set_raster_value_d(rast1, val1, data_type);
     Rast_set_raster_value_d(rast2, val2, data_type);
     Rast_set_raster_value_d(rast2, val2, data_type);
     return tmp;
     return tmp;
@@ -1237,32 +1129,19 @@ char *Rast_get_ith_raster_cat(const struct Categories *pcats, int i, void *rast1
  * For example:
  * For example:
  \code
  \code
  struct Categories cats;
  struct Categories cats;
- Rast_init_cats ((CELL)0, * "", &cats);
+ Rast_init_cats ("", &cats);
  \endcode
  \endcode
  *
  *
- * \param num raster value
- * \param title title
- * \param pcats pointer to Categories structure
- */
-void Rast_init_cats(CELL num, const char *title, struct Categories *pcats)
-{
-    Rast_init_raster_cats(title, pcats);
-    pcats->num = num;
-}
-
-/*!
- * \brief Initialize category structure
- *
- * Same as existing Rast_init_raster_cats() only ncats argument is
- * missign. ncats has no meaning in new Categories structure and only
- * stores (int) largets data value for backwards compatibility.
+ * \todo Eliminate pcats->num. Num has no meaning in new Categories
+ * structure and only stores (int) largets data value for backwards
+ * compatibility.
  *
  *
  * \param title title
  * \param title title
  * \param pcats pointer to Categories structure
  * \param pcats pointer to Categories structure
  */
  */
-void Rast_init_raster_cats(const char *title, struct Categories *pcats)
+void Rast_init_cats(const char *title, struct Categories *pcats)
 {
 {
-    Rast_set_raster_cats_title(title, pcats);
+    Rast_set_cats_title(title, pcats);
     pcats->labels = NULL;
     pcats->labels = NULL;
     pcats->nalloc = 0;
     pcats->nalloc = 0;
     pcats->ncats = 0;
     pcats->ncats = 0;
@@ -1279,7 +1158,7 @@ void Rast_init_raster_cats(const char *title, struct Categories *pcats)
 /*!
 /*!
  * \brief Set title in category structure
  * \brief Set title in category structure
  *
  *
- * \todo To be removed, replaced by Rast_set_raster_cats_title().
+ * \todo To be removed, replaced by Rast_set_cats_title().
  *
  *
  * The <i>title</i> is copied into the <i>pcats</i> structure.
  * The <i>title</i> is copied into the <i>pcats</i> structure.
  *
  *
@@ -1288,19 +1167,6 @@ void Rast_init_raster_cats(const char *title, struct Categories *pcats)
  */
  */
 void Rast_set_cats_title(const char *title, struct Categories *pcats)
 void Rast_set_cats_title(const char *title, struct Categories *pcats)
 {
 {
-    Rast_set_raster_cats_title(title, pcats);
-}
-
-/*!
- * \brief Set title in category structure
- *
- * The <i>title</i> is copied into the <i>pcats</i> structure.
- *
- * \param title title
- * \param pcats pointer to Categories structure
- */
-void Rast_set_raster_cats_title(const char *title, struct Categories *pcats)
-{
     if (title == NULL)
     if (title == NULL)
 	title = "";
 	title = "";
     pcats->title = G_store(title);
     pcats->title = G_store(title);
@@ -1311,31 +1177,13 @@ void Rast_set_raster_cats_title(const char *title, struct Categories *pcats)
 /*!
 /*!
   \brief Set category fmt (?)
   \brief Set category fmt (?)
 
 
-  \todo To be removed, replaced by Rast_set_raster_cats_fmt().
-
   \param fmt
   \param fmt
   \param m1,
   \param m1,
   \param a1,m2,a2
   \param a1,m2,a2
   \param pcats pointer to Categories structure
   \param pcats pointer to Categories structure
 */
 */
 void Rast_set_cats_fmt(const char *fmt, double m1, double a1, double m2,
 void Rast_set_cats_fmt(const char *fmt, double m1, double a1, double m2,
-		    double a2, struct Categories *pcats)
-{
-    Rast_set_raster_cats_fmt(fmt, m1, a1, m2, a2, pcats);
-}
-
-/*!
-  \brief Set category fmt (?)
-
-  \todo To be removed, replaced by Rast_set_raster_cats_fmt().
-
-  \param fmt
-  \param m1,
-  \param a1,m2,a2
-  \param pcats pointer to Categories structure
-*/
-void Rast_set_raster_cats_fmt(const char *fmt, double m1, double a1, double m2,
-			   double a2, struct Categories *pcats)
+		       double a2, struct Categories *pcats)
 {
 {
     pcats->m1 = m1;
     pcats->m1 = m1;
     pcats->a1 = a1;
     pcats->a1 = a1;
@@ -1350,30 +1198,15 @@ void Rast_set_raster_cats_fmt(const char *fmt, double m1, double a1, double m2,
 /*!
 /*!
  * \brief Free category structure memory
  * \brief Free category structure memory
  *
  *
- * \todo To be removed, replaced by Rast_free_raster_cats().
+ * \todo To be removed, replaced by Rast_free_cats().
  *
  *
  * Frees memory allocated by Rast_read_cats(), Rast_init_cats() and
  * Frees memory allocated by Rast_read_cats(), Rast_init_cats() and
- * Rast_set_cat().
+ * Rast_set_c_cat().
  *
  *
  * \param pcats pointer to Categories structure
  * \param pcats pointer to Categories structure
  */
  */
 void Rast_free_cats(struct Categories *pcats)
 void Rast_free_cats(struct Categories *pcats)
 {
 {
-    Rast_free_raster_cats(pcats);
-}
-
-/*!
- * \brief Free category structure memory
- *
- * \todo To be removed, replaced by Rast_free_raster_cats().
- *
- * Frees memory allocated by Rast_read_cats(), Rast_init_cats() and
- * Rast_set_cat().
- *
- * \param pcats pointer to Categories structure
- */
-void Rast_free_raster_cats(struct Categories *pcats)
-{
     int i;
     int i;
 
 
     if (pcats->title != NULL) {
     if (pcats->title != NULL) {
@@ -1407,17 +1240,17 @@ void Rast_free_raster_cats(struct Categories *pcats)
  * \param pcats_to pointer to destination Categories structure
  * \param pcats_to pointer to destination Categories structure
  * \param pcats_from pointer to source Categories structure
  * \param pcats_from pointer to source Categories structure
  */
  */
-void Rast_copy_raster_cats(struct Categories *pcats_to,
-			const struct Categories *pcats_from)
+void Rast_copy_cats(struct Categories *pcats_to,
+		    const struct Categories *pcats_from)
 {
 {
     int i;
     int i;
     char *descr;
     char *descr;
     DCELL d1, d2;
     DCELL d1, d2;
 
 
-    Rast_init_raster_cats(pcats_from->title, pcats_to);
+    Rast_init_cats(pcats_from->title, pcats_to);
     for (i = 0; i < pcats_from->ncats; i++) {
     for (i = 0; i < pcats_from->ncats; i++) {
-	descr = Rast_get_ith_d_raster_cat(pcats_from, i, &d1, &d2);
-	Rast_set_d_raster_cat(&d1, &d2, descr, pcats_to);
+	descr = Rast_get_ith_d_cat(pcats_from, i, &d1, &d2);
+	Rast_set_d_cat(&d1, &d2, descr, pcats_to);
     }
     }
 }
 }
 
 
@@ -1428,7 +1261,7 @@ void Rast_copy_raster_cats(struct Categories *pcats_to,
 
 
   \return number of categories
   \return number of categories
 */
 */
-int Rast_number_of_raster_cats(struct Categories *pcats)
+int Rast_number_of_cats(struct Categories *pcats)
 {
 {
     return pcats->ncats;
     return pcats->ncats;
 }
 }
@@ -1452,22 +1285,22 @@ int Rast_sort_cats(struct Categories *pcats)
 
 
     ncats = pcats->ncats;
     ncats = pcats->ncats;
     G_debug(3, "Rast_sort_cats(): Copying to save cats buffer");
     G_debug(3, "Rast_sort_cats(): Copying to save cats buffer");
-    Rast_copy_raster_cats(&save_cats, pcats);
-    Rast_free_raster_cats(pcats);
+    Rast_copy_cats(&save_cats, pcats);
+    Rast_free_cats(pcats);
 
 
     indexes = (int *)G_malloc(sizeof(int) * ncats);
     indexes = (int *)G_malloc(sizeof(int) * ncats);
     for (i = 0; i < ncats; i++)
     for (i = 0; i < ncats; i++)
 	indexes[i] = i;
 	indexes[i] = i;
 
 
     qsort(indexes, ncats, sizeof(int), cmp);
     qsort(indexes, ncats, sizeof(int), cmp);
-    Rast_init_raster_cats(save_cats.title, pcats);
+    Rast_init_cats(save_cats.title, pcats);
     for (i = 0; i < ncats; i++) {
     for (i = 0; i < ncats; i++) {
-	descr = Rast_get_ith_d_raster_cat(&save_cats, indexes[i], &d1, &d2);
+	descr = Rast_get_ith_d_cat(&save_cats, indexes[i], &d1, &d2);
 	G_debug(4, "  Write sorted cats, pcats = %p pcats->labels = %p",
 	G_debug(4, "  Write sorted cats, pcats = %p pcats->labels = %p",
 		pcats, pcats->labels);
 		pcats, pcats->labels);
-	Rast_set_d_raster_cat(&d1, &d2, descr, pcats);
+	Rast_set_d_cat(&d1, &d2, descr, pcats);
     }
     }
-    Rast_free_raster_cats(&save_cats);
+    Rast_free_cats(&save_cats);
 
 
     return 0;
     return 0;
 }
 }

+ 6 - 6
lib/raster/sample.c

@@ -116,7 +116,7 @@ DCELL Rast_get_raster_sample_nearest(int fd,
     }
     }
 
 
     if (usedesc) {
     if (usedesc) {
-	char *buf = Rast_get_cat(maprow[col], cats);
+	char *buf = Rast_get_c_cat((CELL *) &(maprow[col]), cats);
 
 
 	G_squeeze(buf);
 	G_squeeze(buf);
 	result = scancatlabel(buf);
 	result = scancatlabel(buf);
@@ -194,13 +194,13 @@ DCELL Rast_get_raster_sample_bilinear(int fd,
     if (usedesc) {
     if (usedesc) {
 	char *buf;
 	char *buf;
 
 
-	G_squeeze(buf = Rast_get_cat((int)arow[col], cats));
+	G_squeeze(buf = Rast_get_c_cat((int*) &(arow[col]), cats));
 	grid[0][0] = scancatlabel(buf);
 	grid[0][0] = scancatlabel(buf);
-	G_squeeze(buf = Rast_get_cat((int)arow[col + 1], cats));
+	G_squeeze(buf = Rast_get_c_cat((CELL *) &(arow[col + 1]), cats));
 	grid[0][1] = scancatlabel(buf);
 	grid[0][1] = scancatlabel(buf);
-	G_squeeze(buf = Rast_get_cat((int)brow[col], cats));
+	G_squeeze(buf = Rast_get_c_cat((CELL *) &(brow[col]), cats));
 	grid[1][0] = scancatlabel(buf);
 	grid[1][0] = scancatlabel(buf);
-	G_squeeze(buf = Rast_get_cat((int)brow[col + 1], cats));
+	G_squeeze(buf = Rast_get_c_cat((CELL *) &(brow[col + 1]), cats));
 	grid[1][1] = scancatlabel(buf);
 	grid[1][1] = scancatlabel(buf);
     }
     }
     else {
     else {
@@ -289,7 +289,7 @@ DCELL Rast_get_raster_sample_cubic(int fd,
 
 
 	for (i = 0; i < 4; i++) {
 	for (i = 0; i < 4; i++) {
 	    for (j = 0; j < 4; j++) {
 	    for (j = 0; j < 4; j++) {
-		G_squeeze(buf = Rast_get_cat(rows[i][col + j], cats));
+		G_squeeze(buf = Rast_get_c_cat((CELL *) &(rows[i][col + j]), cats));
 		grid[i][j] = scancatlabel(buf);
 		grid[i][j] = scancatlabel(buf);
 	    }
 	    }
 	}
 	}

+ 3 - 3
ps/ps.map/ps_clrtbl.c

@@ -42,7 +42,7 @@ int PS_colortable(void)
     do_color = (PS.grey == 0 && PS.level == 2);
     do_color = (PS.grey == 0 && PS.level == 2);
 
 
     /* How many categories to show */
     /* How many categories to show */
-    num_cats = Rast_number_of_raster_cats(&PS.cats);
+    num_cats = Rast_number_of_cats(&PS.cats);
     G_debug(3, "clrtbl: %d categories", num_cats);
     G_debug(3, "clrtbl: %d categories", num_cats);
     if (!num_cats) {
     if (!num_cats) {
 	G_warning(_("Your cats/ file is invalid. A cats/ file with categories "
 	G_warning(_("Your cats/ file is invalid. A cats/ file with categories "
@@ -89,7 +89,7 @@ int PS_colortable(void)
 	    fprintf(PS.fp, "(%s)\n", "no data");
 	    fprintf(PS.fp, "(%s)\n", "no data");
 	else
 	else
 	    fprintf(PS.fp, "(%s)\n",
 	    fprintf(PS.fp, "(%s)\n",
-		    Rast_get_ith_d_raster_cat(&PS.cats, i - 1, &dmin, &dmax));
+		    Rast_get_ith_d_cat(&PS.cats, i - 1, &dmin, &dmax));
     }
     }
     fprintf(PS.fp, "] def\n");
     fprintf(PS.fp, "] def\n");
 
 
@@ -136,7 +136,7 @@ int PS_colortable(void)
 
 
 	    /* fill box and outline in black */
 	    /* fill box and outline in black */
 	    if (i)
 	    if (i)
-		label = Rast_get_ith_d_raster_cat(&PS.cats, i - 1, &dmin, &dmax);
+		label = Rast_get_ith_d_cat(&PS.cats, i - 1, &dmin, &dmax);
 
 
 	    x1 = l + (double)j *72.0 * col_width;
 	    x1 = l + (double)j *72.0 * col_width;
 
 

+ 11 - 8
raster/r.buffer/support.c

@@ -27,15 +27,17 @@ int make_support_files(char *output, char *units)
 {
 {
     struct Categories pcats;
     struct Categories pcats;
 
 
+    int i;
     CELL cat;
     CELL cat;
     char label[128];
     char label[128];
 
 
-    Rast_init_cats((CELL) 1, "Distance Zones", &pcats);
+    Rast_init_cats("Distance Zones", &pcats);
 
 
-    Rast_set_cat(cat = 1, "distances calculated from these locations", &pcats);
-    for (cat = 0; cat < ndist; cat++) {
-	if (cat == 0)
-	    sprintf(label, "0-%s %s", distances[cat].label, units);
+    cat = 1;
+    Rast_set_c_cat(&cat, &cat, "distances calculated from these locations", &pcats);
+    for (i = 0; i < ndist; i++) {
+	if (i == 0)
+	    sprintf(label, "0-%s %s", distances[i].label, units);
 	else {
 	else {
 	    /* improved next, but it would be perfect to achieve (example):
 	    /* improved next, but it would be perfect to achieve (example):
 	     * 0-100.55 meters
 	     * 0-100.55 meters
@@ -47,11 +49,12 @@ int make_support_files(char *output, char *units)
 	     *
 	     *
 	     *but it's better that the original code. MN 1/2002
 	     *but it's better that the original code. MN 1/2002
 	     */
 	     */
-	    sprintf(label, "%s-%s %s", distances[cat - 1].label,
-		    distances[cat].label, units);
+	    sprintf(label, "%s-%s %s", distances[i - 1].label,
+		    distances[i].label, units);
 	}
 	}
 
 
-	Rast_set_cat(cat + ZONE_INCR, label, &pcats);
+	cat = i + ZONE_INCR;
+	Rast_set_c_cat(&cat, &cat, label, &pcats);
     }
     }
 
 
     Rast_write_cats(output, &pcats);
     Rast_write_cats(output, &pcats);

+ 7 - 7
raster/r.category/main.c

@@ -150,7 +150,7 @@ int main(int argc, char *argv[])
 	    if ((fd = Rast_open_cell_old(name, mapset)) < 0)
 	    if ((fd = Rast_open_cell_old(name, mapset)) < 0)
 		G_fatal_error(_("Unable to open raster map <%s>"), name);
 		G_fatal_error(_("Unable to open raster map <%s>"), name);
 
 
-	    Rast_init_raster_cats("", &cats);
+	    Rast_init_cats("", &cats);
 
 
 	    if (0 > Rast_read_cats(parm.raster->answer, cmapset, &cats))
 	    if (0 > Rast_read_cats(parm.raster->answer, cmapset, &cats))
 		G_fatal_error(_("Unable to read category file of raster map <%s@%s>"),
 		G_fatal_error(_("Unable to read category file of raster map <%s@%s>"),
@@ -179,7 +179,7 @@ int main(int argc, char *argv[])
 				  parm.file->answer);
 				  parm.file->answer);
 	    }
 	    }
 
 
-	    Rast_init_raster_cats("", &cats);
+	    Rast_init_cats("", &cats);
 
 
 	    for (;;) {
 	    for (;;) {
 		char buf[1024], label[1024];
 		char buf[1024], label[1024];
@@ -189,9 +189,9 @@ int main(int argc, char *argv[])
 		    break;
 		    break;
 
 
 		if (sscanf(buf, "%lf:%lf:%[^\n]", &d1, &d2, label) == 3)
 		if (sscanf(buf, "%lf:%lf:%[^\n]", &d1, &d2, label) == 3)
-		    Rast_set_d_raster_cat(&d1, &d2, label, &cats);
+		    Rast_set_d_cat(&d1, &d2, label, &cats);
 		else if (sscanf(buf, "%lf:%[^\n]", &d1, label) == 2)
 		else if (sscanf(buf, "%lf:%[^\n]", &d1, label) == 2)
-		    Rast_set_d_raster_cat(&d1, &d1, label, &cats);
+		    Rast_set_d_cat(&d1, &d1, label, &cats);
 	    }
 	    }
 
 
 	    if (Rast_write_cats(name, &cats) < 0)
 	    if (Rast_write_cats(name, &cats) < 0)
@@ -208,7 +208,7 @@ int main(int argc, char *argv[])
 	    double m1, a1, m2, a2;
 	    double m1, a1, m2, a2;
 
 
 	    /* read existing values */
 	    /* read existing values */
-	    Rast_init_raster_cats("", &cats);
+	    Rast_init_cats("", &cats);
 
 
 	    if (0 > Rast_read_cats(name, G_mapset(), &cats))
 	    if (0 > Rast_read_cats(name, G_mapset(), &cats))
 		G_warning(_("Unable to read category file of raster map <%s@%s>"),
 		G_warning(_("Unable to read category file of raster map <%s@%s>"),
@@ -302,7 +302,7 @@ int print_label(long x)
 {
 {
     char *label;
     char *label;
 
 
-    G_squeeze(label = Rast_get_cat((CELL) x, &cats));
+    G_squeeze(label = Rast_get_c_cat((CELL *) &x, &cats));
     fprintf(stdout, "%ld%c%s\n", x, fs, label);
     fprintf(stdout, "%ld%c%s\n", x, fs, label);
 
 
     return 0;
     return 0;
@@ -314,7 +314,7 @@ int print_d_label(double x)
     DCELL dtmp;
     DCELL dtmp;
 
 
     dtmp = x;
     dtmp = x;
-    G_squeeze(label = Rast_get_d_raster_cat(&dtmp, &cats));
+    G_squeeze(label = Rast_get_d_cat(&dtmp, &cats));
     sprintf(tmp, "%.10f", x);
     sprintf(tmp, "%.10f", x);
     G_trim_decimal(tmp);
     G_trim_decimal(tmp);
     fprintf(stdout, "%s%c%s\n", tmp, fs, label);
     fprintf(stdout, "%s%c%s\n", tmp, fs, label);

+ 1 - 1
raster/r.compress/main.c

@@ -136,7 +136,7 @@ static int process(char *name, int uncompress)
     if (hist_ok)
     if (hist_ok)
 	Rast_write_history(name, &hist);
 	Rast_write_history(name, &hist);
     if (cats_ok) {
     if (cats_ok) {
-	cats.num = Rast_number_of_cats(name, G_mapset());
+	cats.num = Rast_get_max_c_cat(name, G_mapset());
 	Rast_write_cats(name, &cats);
 	Rast_write_cats(name, &cats);
 	Rast_free_cats(&cats);
 	Rast_free_cats(&cats);
     }
     }

+ 2 - 2
raster/r.cross/cats.c

@@ -49,7 +49,7 @@ int set_cat(CELL result, CELL * cat, struct Categories *pcats)
 	lbl = get_label(cat[i], &labels[i]);
 	lbl = get_label(cat[i], &labels[i]);
 	strcat(buf, lbl);
 	strcat(buf, lbl);
     }
     }
-    Rast_set_cat(result, buf, pcats);
+    Rast_set_c_cat(&result, &result, buf, pcats);
     return 0;
     return 0;
 }
 }
 
 
@@ -58,7 +58,7 @@ static char *get_label(CELL cat, struct Categories *labels)
     char *lbl;
     char *lbl;
     static char temp[256];
     static char temp[256];
 
 
-    lbl = Rast_get_cat(cat, labels);
+    lbl = Rast_get_c_cat(&cat, labels);
     if (*lbl == 0)
     if (*lbl == 0)
 	sprintf(lbl = temp, "category %ld", (long)cat);
 	sprintf(lbl = temp, "category %ld", (long)cat);
     return lbl;
     return lbl;

+ 3 - 3
raster/r.digit/get_label.c

@@ -44,7 +44,7 @@ char *get_label(long cat, struct Categories *labels)
 
 
     for (;;) {
     for (;;) {
 	fprintf(stdout, _("Enter a label for category %ld [%s] "),
 	fprintf(stdout, _("Enter a label for category %ld [%s] "),
-		cat, Rast_get_cat((CELL) cat, labels));
+		cat, Rast_get_c_cat((CELL *) &cat, labels));
 	if (!G_gets(buffer))
 	if (!G_gets(buffer))
 	    continue;;
 	    continue;;
 	G_strip(buffer);
 	G_strip(buffer);
@@ -64,10 +64,10 @@ int get_category(FILE * fd, char *type, struct Categories *labels)
 	cat = get_cat(type);
 	cat = get_cat(type);
 	lbl = get_label(cat, labels);
 	lbl = get_label(cat, labels);
 	fprintf(stdout, "%ld [%s]\n", cat,
 	fprintf(stdout, "%ld [%s]\n", cat,
-		*lbl ? lbl : Rast_get_cat((CELL) cat, labels));
+		*lbl ? lbl : Rast_get_c_cat((CELL) cat, labels));
     } while (!G_yes(_("Look ok? "), 1));
     } while (!G_yes(_("Look ok? "), 1));
     if (*lbl)
     if (*lbl)
-	Rast_set_cat((CELL) cat, lbl, labels);
+      Rast_set_c_cat((CELL *) &cat, (CELL *) &cat, lbl, labels);
 
 
     fprintf(fd, "= %ld %s\n", cat, lbl);
     fprintf(fd, "= %ld %s\n", cat, lbl);
     return (0);
     return (0);

+ 1 - 3
raster/r.distance/labels.c

@@ -30,7 +30,5 @@ void read_labels(struct Map *map)
 
 
 char *get_label(struct Map *map, CELL cat)
 char *get_label(struct Map *map, CELL cat)
 {
 {
-    char *Rast_get_cat();
-
-    return Rast_get_cat(cat, &map->labels);
+    return Rast_get_c_cat(&cat, &map->labels);
 }
 }

+ 2 - 2
raster/r.grow/Makefile

@@ -2,8 +2,8 @@ MODULE_TOPDIR = ../..
 
 
 PGM = r.grow
 PGM = r.grow
 
 
-LIBES = $(GISLIB)
-DEPENDENCIES = $(GISDEP)
+LIBES = $(GISLIB) $(RASTERLIB)
+DEPENDENCIES = $(GISDEP) $(RASTERDEP)
 
 
 include $(MODULE_TOPDIR)/include/Make/Module.make
 include $(MODULE_TOPDIR)/include/Make/Module.make
 
 

+ 4 - 4
raster/r.grow/main.c

@@ -21,9 +21,9 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
 #include <grass/gis.h>
 #include <grass/gis.h>
+#include <grass/raster.h>
 #include <grass/glocale.h>
 #include <grass/glocale.h>
 
 
-
 #define MAX(a, b)	((a) > (b) ? (a) : (b))
 #define MAX(a, b)	((a) > (b) ? (a) : (b))
 
 
 static int size;
 static int size;
@@ -194,7 +194,7 @@ int main(int argc, char **argv)
 
 
     if (Rast_read_cats(in_name, "", &cats) == -1) {
     if (Rast_read_cats(in_name, "", &cats) == -1) {
 	G_warning(_("Error reading category file for <%s>"), in_name);
 	G_warning(_("Error reading category file for <%s>"), in_name);
-	Rast_init_cats(0, "", &cats);
+	Rast_init_cats("", &cats);
     }
     }
 
 
     if (Rast_read_colors(in_name, "", &colr) == -1) {
     if (Rast_read_colors(in_name, "", &colr) == -1) {
@@ -205,10 +205,10 @@ int main(int argc, char **argv)
 	colrfile = 1;
 	colrfile = 1;
 
 
     if (opt.old->answer && oldval >= 0)
     if (opt.old->answer && oldval >= 0)
-	Rast_set_cat(oldval, "original cells", &cats);
+	Rast_set_c_cat(&oldval, &oldval, "original cells", &cats);
 
 
     if (opt.new->answer)
     if (opt.new->answer)
-	Rast_set_cat(newval, "grown cells", &cats);
+	Rast_set_c_cat(&newval, &newval,"grown cells", &cats);
 
 
     in_rows = G_malloc((size * 2 + 1) * sizeof(DCELL *));
     in_rows = G_malloc((size * 2 + 1) * sizeof(DCELL *));
 
 

+ 1 - 1
raster/r.in.poly/get_item.c

@@ -66,7 +66,7 @@ int get_item(FILE * fd, int *type, long *cat, double **x, double **y,
 	    /* probably change this as G_getl2() doesn't store the new line (?) */
 	    /* probably change this as G_getl2() doesn't store the new line (?) */
 	    if (sscanf(buf + 1, "%ld%[^\n]", cat, lbl) == 2) {
 	    if (sscanf(buf + 1, "%ld%[^\n]", cat, lbl) == 2) {
 		G_strip(lbl);
 		G_strip(lbl);
-		Rast_set_cat((CELL) * cat, lbl, labels);
+		Rast_set_c_cat((CELL*) cat, (CELL *) cat, lbl, labels);
 	    }
 	    }
 	    continue;
 	    continue;
 	}
 	}

+ 1 - 1
raster/r.kappa/prt_label.c

@@ -24,7 +24,7 @@ void prt_label(void)
 	fprintf(fd, "MAP%-d Category Description\n", i + 1);
 	fprintf(fd, "MAP%-d Category Description\n", i + 1);
 	for (j = 0; j < ncat; j++) {
 	for (j = 0; j < ncat; j++) {
 	    cats = rlst;
 	    cats = rlst;
-	    cl = Rast_get_cat((CELL) cats[j], &(layers[i].labels));
+	    cl = Rast_get_c_cat((CELL *) &(cats[j]), &(layers[i].labels));
 	    if (cl)
 	    if (cl)
 		G_strip(cl);
 		G_strip(cl);
 	    if (cl == NULL || *cl == 0)
 	    if (cl == NULL || *cl == 0)

+ 7 - 7
raster/r.le/r.le.patch/trace.c

@@ -180,7 +180,7 @@ void cell_clip_drv(int col0, int row0, int ncols, int nrows, double **value,
 
 
 	infd = Rast_open_cell_old(name, mapset);
 	infd = Rast_open_cell_old(name, mapset);
 	colr_ok = Rast_read_colors(name, mapset, &colr) > 0;
 	colr_ok = Rast_read_colors(name, mapset, &colr) > 0;
-	cats_ok = Rast_read_raster_cats(name, mapset, &cats) >= 0;
+	cats_ok = Rast_read_cats(name, mapset, &cats) >= 0;
 	hist_ok = Rast_read_history(name, mapset, &hist) >= 0;
 	hist_ok = Rast_read_history(name, mapset, &hist) >= 0;
 	range_ok = Rast_read_range(name, mapset, &range) >= 0;
 	range_ok = Rast_read_range(name, mapset, &range) >= 0;
 
 
@@ -198,7 +198,7 @@ void cell_clip_drv(int col0, int row0, int ncols, int nrows, double **value,
 	/* 3. initialize appropriate data structures */
 	/* 3. initialize appropriate data structures */
 
 
 	if (cats_ok)
 	if (cats_ok)
-	    Rast_init_raster_cats(Rast_get_raster_cats_title(&cats), &newcats);
+	    Rast_init_cats(Rast_get_cats_title(&cats), &newcats);
 	if (data_type == CELL_TYPE)
 	if (data_type == CELL_TYPE)
 	    Rast_init_cell_stats(&stats);
 	    Rast_init_cell_stats(&stats);
 
 
@@ -369,7 +369,7 @@ void cell_clip_drv(int col0, int row0, int ncols, int nrows, double **value,
     if (choice->coremap) {
     if (choice->coremap) {
 	Rast_close_cell(fe);
 	Rast_close_cell(fe);
 	Rast_rewind_cell_stats(&stats);
 	Rast_rewind_cell_stats(&stats);
-	Rast_rewind_raster_cats(&cats);
+	Rast_rewind_cats(&cats);
 
 
 	if (cats_ok && data_type == CELL_TYPE) {
 	if (cats_ok && data_type == CELL_TYPE) {
 	    long count;
 	    long count;
@@ -378,12 +378,12 @@ void cell_clip_drv(int col0, int row0, int ncols, int nrows, double **value,
 	    rast1 = cor_cell_buf;
 	    rast1 = cor_cell_buf;
 	    rast2 = G_incr_void_ptr(rast1, Rast_cell_size(CELL_TYPE));
 	    rast2 = G_incr_void_ptr(rast1, Rast_cell_size(CELL_TYPE));
 	    while (Rast_next_cell_stat(rast1, &count, &stats))
 	    while (Rast_next_cell_stat(rast1, &count, &stats))
-		Rast_set_raster_cat(rast1, rast2, Rast_get_raster_cat(rast1, &cats,
+		Rast_set_cat(rast1, rast2, Rast_get_cat(rast1, &cats,
 								CELL_TYPE),
 								CELL_TYPE),
 				 &newcats, CELL_TYPE);
 				 &newcats, CELL_TYPE);
-	    Rast_write_raster_cats("interior", &newcats);
-	    Rast_free_raster_cats(&cats);
-	    Rast_free_raster_cats(&newcats);
+	    Rast_write_cats("interior", &newcats);
+	    Rast_free_cats(&cats);
+	    Rast_free_cats(&newcats);
 	    Rast_free_cell_stats(&stats);
 	    Rast_free_cell_stats(&stats);
 	}
 	}
 
 

+ 1 - 0
raster/r.le/r.le.pixel/cellclip.c

@@ -21,6 +21,7 @@
 #include <grass/gis.h>
 #include <grass/gis.h>
 #include "pixel.h"
 #include "pixel.h"
 #include <grass/config.h>
 #include <grass/config.h>
+#include <grass/raster.h>
 #include "local_proto.h"
 #include "local_proto.h"
 
 
 
 

+ 1 - 1
raster/r.le/r.le.pixel/driver.c

@@ -23,7 +23,7 @@
 #include <grass/gis.h>
 #include <grass/gis.h>
 #include "pixel.h"
 #include "pixel.h"
 #include <grass/config.h>
 #include <grass/config.h>
-
+#include <grass/raster.h>
 
 
 
 
 int finput, g_scale = 1, g_unit = 1;
 int finput, g_scale = 1, g_unit = 1;

+ 1 - 1
raster/r.le/r.le.pixel/texture.c

@@ -19,6 +19,7 @@
 
 
 #include <grass/gis.h>
 #include <grass/gis.h>
 #include <grass/config.h>
 #include <grass/config.h>
+#include <grass/raster.h>
 #include "pixel.h"
 #include "pixel.h"
 
 
 
 
@@ -37,7 +38,6 @@ extern int g_scale, g_unit;
 
 
 struct Categories cats;
 struct Categories cats;
 
 
-char *Rast_get_cat();
 
 
 					/* declare a counter for the number
 					/* declare a counter for the number
 					   of pixels with non-null values
 					   of pixels with non-null values

+ 2 - 1
raster/r.mapcalc/map.c

@@ -340,7 +340,8 @@ static void translate_from_cats(struct map *m, CELL * cell, DCELL * xcell,
 	if (!btree_find(btree, &key, &ptr)) {
 	if (!btree_find(btree, &key, &ptr)) {
 	    values = vbuf;
 	    values = vbuf;
 	    for (i = 0; i < NCATS; i++) {
 	    for (i = 0; i < NCATS; i++) {
-		if ((label = Rast_get_cat((CELL) (i + key), pcats)) == NULL
+		CELL cat = i + key;
+		if ((label = Rast_get_c_cat((CELL *) cat, pcats)) == NULL
 		    || sscanf(label, "%lf", values) != 1)
 		    || sscanf(label, "%lf", values) != 1)
 		    SET_NULL_D(values);
 		    SET_NULL_D(values);
 		values++;
 		values++;

+ 2 - 1
raster/r.mapcalc/map3.c

@@ -298,8 +298,9 @@ static void translate_from_cats(map * m, CELL * cell, DCELL * xcell,
 	 */
 	 */
 	if (!btree_find(btree, &key, &ptr)) {
 	if (!btree_find(btree, &key, &ptr)) {
 	    values = vbuf;
 	    values = vbuf;
+	    int cat = i + key;
 	    for (i = 0; i < NCATS; i++) {
 	    for (i = 0; i < NCATS; i++) {
-		if ((label = Rast_get_cat((CELL) (i + key), pcats)) == NULL
+		if ((label = Rast_get_c_cat((CELL *) &cat, pcats)) == NULL
 		    || sscanf(label, "%lf", values) != 1)
 		    || sscanf(label, "%lf", values) != 1)
 		    SET_NULL_D(values);
 		    SET_NULL_D(values);
 		values++;
 		values++;

+ 2 - 2
raster/r.mode/main.c

@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
 	    max = value;
 	    max = value;
 	}
 	}
 	if (basecat != catb) {
 	if (basecat != catb) {
-	    write_reclass(reclass, catb, catc, Rast_get_cat(catc, &cover_cats));
+	  write_reclass(reclass, catb, catc, Rast_get_c_cat((CELL *) &catc, &cover_cats));
 	    catb = basecat;
 	    catb = basecat;
 	    catc = covercat;
 	    catc = covercat;
 	    max = value;
 	    max = value;
@@ -118,7 +118,7 @@ int main(int argc, char *argv[])
     if (first) {
     if (first) {
 	catb = catc = 0;
 	catb = catc = 0;
     }
     }
-    write_reclass(reclass, catb, catc, Rast_get_cat(catc, &cover_cats));
+    write_reclass(reclass, catb, catc, Rast_get_c_cat((CELL *) &catc, &cover_cats));
 
 
     pclose(stats);
     pclose(stats);
     pclose(reclass);
     pclose(reclass);

+ 1 - 1
raster/r.neighbors/divr_cats.c

@@ -4,7 +4,7 @@
 int divr_cats(void)
 int divr_cats(void)
 {
 {
     Rast_set_cats_fmt("$1 $?different categories$category$", 1.0, 0.0, 0.0, 0.0,
     Rast_set_cats_fmt("$1 $?different categories$category$", 1.0, 0.0, 0.0, 0.0,
-		   &ncb.cats);
+		      &ncb.cats);
 
 
     return 0;
     return 0;
 }
 }

+ 1 - 1
raster/r.neighbors/intr_cats.c

@@ -5,6 +5,6 @@
 int intr_cats(void)
 int intr_cats(void)
 {
 {
     Rast_set_cats_fmt("$1% dispersion", 1.0, -1.0, 0.0, 0.0, &ncb.cats);
     Rast_set_cats_fmt("$1% dispersion", 1.0, -1.0, 0.0, 0.0, &ncb.cats);
-
+    
     return 0;
     return 0;
 }
 }

+ 1 - 4
raster/r.neighbors/null_cats.c

@@ -4,10 +4,7 @@
 
 
 int null_cats(void)
 int null_cats(void)
 {
 {
-    int ncats;
-
-    ncats = Rast_number_of_cats(ncb.newcell, G_mapset());
-    Rast_init_cats(ncats, ncb.title, &ncb.cats);
+    Rast_init_cats(ncb.title, &ncb.cats);
 
 
     return 0;
     return 0;
 }
 }

+ 3 - 3
raster/r.null/main.c

@@ -279,7 +279,7 @@ int process(const char *name, const char *mapset, int change_null, RASTER_MAP_TY
     G_suppress_warnings(1);
     G_suppress_warnings(1);
     colr_ok = Rast_read_colors(name, mapset, &colr) > 0;
     colr_ok = Rast_read_colors(name, mapset, &colr) > 0;
     hist_ok = Rast_read_history(name, mapset, &hist) >= 0;
     hist_ok = Rast_read_history(name, mapset, &hist) >= 0;
-    cats_ok = Rast_read_raster_cats(name, mapset, &cats) >= 0;
+    cats_ok = Rast_read_cats(name, mapset, &cats) >= 0;
 
 
     if (map_type != CELL_TYPE) {
     if (map_type != CELL_TYPE) {
 	Rast_quant_init(&quant);
 	Rast_quant_init(&quant);
@@ -297,8 +297,8 @@ int process(const char *name, const char *mapset, int change_null, RASTER_MAP_TY
     if (hist_ok)
     if (hist_ok)
 	Rast_write_history(name, &hist);
 	Rast_write_history(name, &hist);
     if (cats_ok) {
     if (cats_ok) {
-	cats.num = Rast_number_of_cats(name, mapset);
-	Rast_write_raster_cats(name, &cats);
+	cats.num = Rast_get_max_c_cat(name, mapset);
+	Rast_write_cats(name, &cats);
 	Rast_free_cats(&cats);
 	Rast_free_cats(&cats);
     }
     }
     if (map_type != CELL_TYPE && quant_ok)
     if (map_type != CELL_TYPE && quant_ok)

+ 19 - 19
raster/r.param.scale/param.h

@@ -23,27 +23,27 @@
 #define RAD2DEG 57.29578
 #define RAD2DEG 57.29578
 #define DEG2RAD 0.017453293
 #define DEG2RAD 0.017453293
 
 
-#define TINY 1.0e-20;
+#define TINY 1.0e-20
 
 
 /* Bug? start with 1 as G_set_cats() doesn't accept 0 category */
 /* Bug? start with 1 as G_set_cats() doesn't accept 0 category */
-#define FLAT ((CELL)1)
-#define PIT ((CELL)2)
-#define CHANNEL ((CELL)3)
-#define PASS ((CELL)4)
-#define RIDGE ((CELL)5)
-#define PEAK ((CELL)6)
-
-#define NUM_CATS ((CELL)7)
-
-#define ELEV   1
-#define SLOPE  2
-#define ASPECT 3
-#define PROFC  4
-#define PLANC  5
-#define LONGC  6
-#define CROSC  7
-#define MINIC  8
-#define MAXIC  9
+#define FLAT    1
+#define PIT     2
+#define CHANNEL 3
+#define PASS    4
+#define RIDGE   5
+#define PEAK    6
+
+#define NUM_CATS 7
+
+#define ELEV    1
+#define SLOPE   2
+#define ASPECT  3
+#define PROFC   4
+#define PLANC   5
+#define LONGC   6
+#define CROSC   7
+#define MINIC   8
+#define MAXIC   9
 #define FEATURE 10
 #define FEATURE 10
 
 
 /* The six quadratic coefficients are stored in the array coeff */
 /* The six quadratic coefficients are stored in the array coeff */

+ 15 - 8
raster/r.param.scale/write_cats.c

@@ -21,24 +21,31 @@
 void write_cats(void)
 void write_cats(void)
 {
 {
     struct Categories cats;
     struct Categories cats;
+    CELL cat;
 
 
     /*------------------------------------------------------------------------*/
     /*------------------------------------------------------------------------*/
     /*                            INITIALISE                                  */
     /*                            INITIALISE                                  */
 
 
     /*------------------------------------------------------------------------*/
     /*------------------------------------------------------------------------*/
-    Rast_init_cats((CELL) 0, "", &cats);
-    Rast_set_raster_cats_title("Surface Features", &cats);
+    Rast_init_cats("", &cats);
+    Rast_set_cats_title("Surface Features", &cats);
 
 
     /*------------------------------------------------------------------------*/
     /*------------------------------------------------------------------------*/
     /*                      FILL OUT CATEGORIES STRUCTURE                     */
     /*                      FILL OUT CATEGORIES STRUCTURE                     */
 
 
     /*------------------------------------------------------------------------*/
     /*------------------------------------------------------------------------*/
-    Rast_set_cat(FLAT, " Planar", &cats);
-    Rast_set_cat(PIT, " Pit", &cats);
-    Rast_set_cat(PEAK, " Peak", &cats);
-    Rast_set_cat(RIDGE, " Ridge", &cats);
-    Rast_set_cat(CHANNEL, " Channel", &cats);
-    Rast_set_cat(PASS, " Pass (saddle)", &cats);
+    cat = FLAT;
+    Rast_set_c_cat(&cat, &cat, " Planar", &cats);
+    cat = PIT;
+    Rast_set_c_cat(&cat, &cat, " Pit", &cats);
+    cat = PEAK;
+    Rast_set_c_cat(&cat, &cat, " Peak", &cats);
+    cat = RIDGE;
+    Rast_set_c_cat(&cat, &cat, " Ridge", &cats);
+    cat = CHANNEL;
+    Rast_set_c_cat(&cat, &cat, " Channel", &cats);
+    cat = PASS;
+    Rast_set_c_cat(&cat, &cat, " Pass (saddle)", &cats);
 
 
     /*------------------------------------------------------------------------*/
     /*------------------------------------------------------------------------*/
     /*                     WRITE OUT CATEGORIES STRUCTURE                     */
     /*                     WRITE OUT CATEGORIES STRUCTURE                     */

+ 1 - 1
raster/r.patch/support.c

@@ -50,7 +50,7 @@ int support(char **names,
 		if (n && !Rast_find_cell_stat(n, &count, statf)) {
 		if (n && !Rast_find_cell_stat(n, &count, statf)) {
 		    if (do_cats) {
 		    if (do_cats) {
 			Rast_update_cell_stats(&n, 1, statf);
 			Rast_update_cell_stats(&n, 1, statf);
-			Rast_set_cat(n, Rast_get_cat(n, &pcats), cats);
+			Rast_set_c_cat(&n, &n, Rast_get_c_cat((CELL *) &n, &pcats), cats);
 		    }
 		    }
 		    if (do_colr) {
 		    if (do_colr) {
 			Rast_get_color(n, &red, &grn, &blu, &pcolr);
 			Rast_get_color(n, &red, &grn, &blu, &pcolr);

+ 5 - 3
raster/r.random.surface/save.c

@@ -15,7 +15,8 @@ void SaveMap(int NumMap, int MapSeed)
     struct Colors Colr;
     struct Colors Colr;
     char String[80], Label[240];
     char String[80], Label[240];
     struct History history;
     struct History history;
-
+    CELL cat;
+    
     G_debug(2, "SaveMap()");
     G_debug(2, "SaveMap()");
 
 
     OutFD = Rast_open_cell_new(OutNames[NumMap]);
     OutFD = Rast_open_cell_new(OutNames[NumMap]);
@@ -187,14 +188,15 @@ void SaveMap(int NumMap, int MapSeed)
        TheoryCovariance( TheoryName, Label);
        TheoryCovariance( TheoryName, Label);
      */
      */
 
 
-    Rast_init_cats(CatInfo.NumCat, Label, &Cats);
+    Rast_init_cats(Label, &Cats);
     for (Index = 0; Index < CatInfo.NumCat; Index++) {
     for (Index = 0; Index < CatInfo.NumCat; Index++) {
 	if (CatInfo.NumValue[Index] != 0) {
 	if (CatInfo.NumValue[Index] != 0) {
 	    CatInfo.Average[Index] /= CatInfo.NumValue[Index];
 	    CatInfo.Average[Index] /= CatInfo.NumValue[Index];
 	    sprintf(Label, "%+lf %+lf to %+lf",
 	    sprintf(Label, "%+lf %+lf to %+lf",
 		    CatInfo.Average[Index],
 		    CatInfo.Average[Index],
 		    CatInfo.Min[Index], CatInfo.Max[Index]);
 		    CatInfo.Min[Index], CatInfo.Max[Index]);
-	    Rast_set_cat(1 + Index, Label, &Cats);
+	    cat = Index + 1;
+	    Rast_set_c_cat(&cat, &cat, Label, &Cats);
 	}
 	}
     }
     }
 
 

+ 3 - 3
raster/r.random/support.c

@@ -24,15 +24,15 @@ int make_support(struct rr_state *theState, int percent, double percentage)
 	inraster = theState->inraster;
 	inraster = theState->inraster;
 	nulls = theState->nulls;
 	nulls = theState->nulls;
     }
     }
-    if (Rast_read_raster_cats(inraster, "", &cats) >= 0) {
+    if (Rast_read_cats(inraster, "", &cats) >= 0) {
 	sprintf(title, "Random points on <%s>", inraster);
 	sprintf(title, "Random points on <%s>", inraster);
 	Rast_set_cats_title(title, &cats);
 	Rast_set_cats_title(title, &cats);
 	if (theState->use_nulls)
 	if (theState->use_nulls)
-	    Rast_set_raster_cat(nulls.data.v,
+	    Rast_set_cat(nulls.data.v,
 			     nulls.data.v,
 			     nulls.data.v,
 			     "Points with NULL values in original",
 			     "Points with NULL values in original",
 			     &cats, nulls.type);
 			     &cats, nulls.type);
-	Rast_write_raster_cats(theState->outraster, &cats);
+	Rast_write_cats(theState->outraster, &cats);
     }
     }
 
 
     /* write history for output raster */
     /* write history for output raster */

+ 1 - 1
raster/r.reclass/parse.c

@@ -142,7 +142,7 @@ int parse(const char *line, RULE ** rules, RULE ** tail, struct Categories *cats
 	if (*rules == NULL)
 	if (*rules == NULL)
 	    *rules = *tail;
 	    *rules = *tail;
 	if (*label)
 	if (*label)
-	    Rast_set_cat(new, label, cats);
+	    Rast_set_c_cat(&new, &new, label, cats);
     }
     }
     return count;
     return count;
 }
 }

+ 3 - 3
raster/r.reclass/reclass.c

@@ -161,13 +161,13 @@ static void set_cats(struct Categories *cats, /* const */ int *is_default,
 	for (i = 0; i < rec->num; i++)
 	for (i = 0; i < rec->num; i++)
 	    if (is_default[i]) {
 	    if (is_default[i]) {
 		int x = i + rec->min;
 		int x = i + rec->min;
-		char *label = Rast_get_cat(x, &old_cats);
+		char *label = Rast_get_c_cat(&x, &old_cats);
 
 
-		Rast_set_cat(x, label, cats);
+		Rast_set_c_cat(&x, &x, label, cats);
 	    }
 	    }
     }
     }
     else if (default_rule)
     else if (default_rule)
-	Rast_set_cat(DEFAULT, default_label, cats);
+	Rast_set_c_cat(&DEFAULT, &DEFAULT, default_label, cats);
 }
 }
 
 
 static int _reclass( /* const */ RULE * rules, struct Categories *cats,
 static int _reclass( /* const */ RULE * rules, struct Categories *cats,

+ 5 - 5
raster/r.report/prt_report.c

@@ -270,7 +270,7 @@ int construct_val_str(int nl, CELL * pval, char *str)
     else {			/* find out which floating point range to print */
     else {			/* find out which floating point range to print */
 
 
 	if (cat_ranges)
 	if (cat_ranges)
-	    descr = Rast_get_ith_d_raster_cat(&layers[nl].labels, *pval,
+	    descr = Rast_get_ith_d_cat(&layers[nl].labels, *pval,
 					   &dLow, &dHigh);
 					   &dLow, &dHigh);
 	else {
 	else {
 	    dLow = (DMAX[nl] - DMIN[nl]) / nsteps *
 	    dLow = (DMAX[nl] - DMIN[nl]) / nsteps *
@@ -296,13 +296,13 @@ char *construct_cat_label(int nl, CELL cat)
     static char str[500];
     static char str[500];
 
 
     if (!is_fp[nl] || as_int)
     if (!is_fp[nl] || as_int)
-	return Rast_get_cat(cat, &layers[nl].labels);
+	return Rast_get_c_cat(&cat, &layers[nl].labels);
     else {			/* find or construct the label for
     else {			/* find or construct the label for
 				   floating point range to print */
 				   floating point range to print */
 	if (Rast_is_c_null_value(&tmp))
 	if (Rast_is_c_null_value(&tmp))
 	    return G_store("no data");
 	    return G_store("no data");
 	if (cat_ranges)
 	if (cat_ranges)
-	    return Rast_get_ith_d_raster_cat(&layers[nl].labels, cat,
+	    return Rast_get_ith_d_cat(&layers[nl].labels, cat,
 					  &dLow, &dHigh);
 					  &dLow, &dHigh);
 	else {
 	else {
 	    dLow = (DMAX[nl] - DMIN[nl]) / (double)nsteps *
 	    dLow = (DMAX[nl] - DMIN[nl]) / (double)nsteps *
@@ -310,8 +310,8 @@ char *construct_cat_label(int nl, CELL cat)
 	    dHigh = (DMAX[nl] - DMIN[nl]) / (double)nsteps *
 	    dHigh = (DMAX[nl] - DMIN[nl]) / (double)nsteps *
 		(double)cat + DMIN[nl];
 		(double)cat + DMIN[nl];
 	    sprintf(str, "from %s to %s",
 	    sprintf(str, "from %s to %s",
-		    Rast_get_d_raster_cat(&dLow, &layers[nl].labels),
-		    Rast_get_d_raster_cat(&dHigh, &layers[nl].labels));
+		    Rast_get_d_cat(&dLow, &layers[nl].labels),
+		    Rast_get_d_cat(&dHigh, &layers[nl].labels));
 	    return str;
 	    return str;
 	}
 	}
     }				/* fp label */
     }				/* fp label */

+ 7 - 7
raster/r.resample/main.c

@@ -83,8 +83,8 @@ int main(int argc, char *argv[])
     colr_ok = Rast_read_colors(name, "", &colr) > 0;
     colr_ok = Rast_read_colors(name, "", &colr) > 0;
     cats_ok = Rast_read_cats(name, "", &cats) >= 0;
     cats_ok = Rast_read_cats(name, "", &cats) >= 0;
     if (cats_ok) {
     if (cats_ok) {
-	Rast_unmark_raster_cats(&cats);
-	Rast_init_cats((CELL) 0, Rast_get_cats_title(&cats), &newcats);
+	Rast_unmark_cats(&cats);
+	Rast_init_cats(Rast_get_cats_title(&cats), &newcats);
     }
     }
 
 
     infd = Rast_open_cell_old(name, "");
     infd = Rast_open_cell_old(name, "");
@@ -122,7 +122,7 @@ int main(int argc, char *argv[])
 	    G_fatal_error(_("Error reading row %d"), row);
 	    G_fatal_error(_("Error reading row %d"), row);
 	if (Rast_put_raster_row(outfd, rast, out_type) < 0)
 	if (Rast_put_raster_row(outfd, rast, out_type) < 0)
 	    G_fatal_error(_("Error writing row %d"), row);
 	    G_fatal_error(_("Error writing row %d"), row);
-	Rast_mark_raster_cats(rast, ncols, &cats, data_type);
+	Rast_mark_cats(rast, ncols, &cats, data_type);
     }
     }
 
 
     G_percent(row, nrows, 2);
     G_percent(row, nrows, 2);
@@ -133,7 +133,7 @@ int main(int argc, char *argv[])
 
 
     Rast_close_cell(outfd);
     Rast_close_cell(outfd);
 
 
-    Rast_rewind_raster_cats(&cats);
+    Rast_rewind_cats(&cats);
 
 
     if (cats_ok) {
     if (cats_ok) {
 	long count;
 	long count;
@@ -143,10 +143,10 @@ int main(int argc, char *argv[])
 	rast2 = G_incr_void_ptr(rast, Rast_cell_size(data_type));
 	rast2 = G_incr_void_ptr(rast, Rast_cell_size(data_type));
 
 
 	G_message(_("Creating new cats file..."));
 	G_message(_("Creating new cats file..."));
-	while (Rast_get_next_marked_raster_cat(&cats,
+	while (Rast_get_next_marked_cat(&cats,
 					    rast1, rast2, &count, data_type))
 					    rast1, rast2, &count, data_type))
-	    Rast_set_raster_cat(rast1, rast2,
-			     Rast_get_raster_cat(rast1, &cats, data_type),
+	    Rast_set_cat(rast1, rast2,
+			     Rast_get_cat(rast1, &cats, data_type),
 			     &newcats, data_type);
 			     &newcats, data_type);
 
 
 	Rast_write_cats(result, &newcats);
 	Rast_write_cats(result, &newcats);

+ 40 - 28
raster/r.slope.aspect/main.c

@@ -75,6 +75,7 @@ int main(int argc, char *argv[])
     DCELL *c1, *c2, *c3, *c4, *c5, *c6, *c7, *c8, *c9;
     DCELL *c1, *c2, *c3, *c4, *c5, *c6, *c7, *c8, *c9;
     DCELL tmp1, tmp2;
     DCELL tmp1, tmp2;
     FCELL dat1, dat2;
     FCELL dat1, dat2;
+    CELL cat;
     void *asp_raster, *asp_ptr = NULL;
     void *asp_raster, *asp_ptr = NULL;
     void *slp_raster, *slp_ptr = NULL;
     void *slp_raster, *slp_ptr = NULL;
     void *pcurv_raster, *pcurv_ptr = NULL;
     void *pcurv_raster, *pcurv_ptr = NULL;
@@ -1008,8 +1009,8 @@ int main(int argc, char *argv[])
 	    Rast_quantize_fp_map_range(aspect_name, G_mapset(), 0., 360., 0,
 	    Rast_quantize_fp_map_range(aspect_name, G_mapset(), 0., 360., 0,
 				    360);
 				    360);
 
 
-	Rast_read_raster_cats(aspect_name, G_mapset(), &cats);
-	Rast_set_raster_cats_title
+	Rast_read_cats(aspect_name, G_mapset(), &cats);
+	Rast_set_cats_title
 	    ("Aspect counterclockwise in degrees from east", &cats);
 	    ("Aspect counterclockwise in degrees from east", &cats);
 
 
 	G_verbose_message(_("Min computed aspect %.4f, max computed aspect %.4f"),
 	G_verbose_message(_("Min computed aspect %.4f, max computed aspect %.4f"),
@@ -1041,22 +1042,24 @@ int main(int argc, char *argv[])
 		sprintf(buf, "%d degree%s ccw from east", i,
 		sprintf(buf, "%d degree%s ccw from east", i,
 			i == 1 ? "" : "s");
 			i == 1 ? "" : "s");
 	    if (data_type == CELL_TYPE) {
 	    if (data_type == CELL_TYPE) {
-		Rast_set_cat(i, buf, &cats);
+	      Rast_set_c_cat((CELL *) &i, (CELL *) &i, buf, &cats);
 		continue;
 		continue;
 	    }
 	    }
 	    tmp1 = (double)i - .5;
 	    tmp1 = (double)i - .5;
 	    tmp2 = (double)i + .5;
 	    tmp2 = (double)i + .5;
-	    Rast_set_d_raster_cat(&tmp1, &tmp2, buf, &cats);
+	    Rast_set_d_cat(&tmp1, &tmp2, buf, &cats);
+	}
+	if (data_type == CELL_TYPE) {
+	    cat = 0;
+	    Rast_set_c_cat(&cat, &cat, "no aspect", &cats);
 	}
 	}
-	if (data_type == CELL_TYPE)
-	    Rast_set_cat(0, "no aspect", &cats);
 	else {
 	else {
 	    tmp1 = 0.;
 	    tmp1 = 0.;
 	    tmp2 = .5;
 	    tmp2 = .5;
-	    Rast_set_d_raster_cat(&tmp1, &tmp2, "no aspect", &cats);
+	    Rast_set_d_cat(&tmp1, &tmp2, "no aspect", &cats);
 	}
 	}
-	Rast_write_raster_cats(aspect_name, &cats);
-	Rast_free_raster_cats(&cats);
+	Rast_write_cats(aspect_name, &cats);
+	Rast_free_cats(&cats);
 
 
 	/* write colors for aspect file */
 	/* write colors for aspect file */
 	Rast_init_colors(&colors);
 	Rast_init_colors(&colors);
@@ -1110,11 +1113,11 @@ int main(int argc, char *argv[])
 					(CELL) ceil(max_slp));
 					(CELL) ceil(max_slp));
 	}
 	}
 
 
-	Rast_read_raster_cats(slope_name, G_mapset(), &cats);
+	Rast_read_cats(slope_name, G_mapset(), &cats);
 	if (deg)
 	if (deg)
-	    Rast_set_raster_cats_title("slope in degrees", &cats);
+	    Rast_set_cats_title("slope in degrees", &cats);
 	else if (perc)
 	else if (perc)
-	    Rast_set_raster_cats_title("percent slope", &cats);
+	    Rast_set_cats_title("percent slope", &cats);
 
 
 	G_verbose_message(_("Min computed slope %.4f, max computed slope %.4f"),
 	G_verbose_message(_("Min computed slope %.4f, max computed slope %.4f"),
 			  min_slp, max_slp);
 			  min_slp, max_slp);
@@ -1129,9 +1132,9 @@ int main(int argc, char *argv[])
 		sprintf(buf, "%d percent", i);
 		sprintf(buf, "%d percent", i);
 	    if (data_type == CELL_TYPE) {
 	    if (data_type == CELL_TYPE) {
 		/* INCR_BY_ONE
 		/* INCR_BY_ONE
-		   Rast_set_cat(i+1, buf, &cats);
+		   Rast_set_c_cat(i+1, buf, &cats);
 		 */
 		 */
-		Rast_set_cat(i, buf, &cats);
+		Rast_set_c_cat(&i, &i, buf, &cats);
 		continue;
 		continue;
 	    }
 	    }
 	    /* INCR_BY_ONE
 	    /* INCR_BY_ONE
@@ -1140,22 +1143,24 @@ int main(int argc, char *argv[])
 	     */
 	     */
 	    tmp1 = (DCELL) i - .5;
 	    tmp1 = (DCELL) i - .5;
 	    tmp2 = (DCELL) i + .5;
 	    tmp2 = (DCELL) i + .5;
-	    Rast_set_d_raster_cat(&tmp1, &tmp2, buf, &cats);
+	    Rast_set_d_cat(&tmp1, &tmp2, buf, &cats);
+	}
+	if (data_type == CELL_TYPE) {
+	    cat = 0;
+	    Rast_set_c_cat(&cat, &cat, "zero slope", &cats);
 	}
 	}
-	if (data_type == CELL_TYPE)
-	    Rast_set_cat(0, "zero slope", &cats);
 	/* INCR_BY_ONE
 	/* INCR_BY_ONE
-	   Rast_set_cat(0, "no data", &cats);
+	   Rast_set_c_cat(0, "no data", &cats);
 	 */
 	 */
 	else {
 	else {
 	    tmp1 = 0;
 	    tmp1 = 0;
 	    tmp2 = 0.5;
 	    tmp2 = 0.5;
-	    Rast_set_d_raster_cat(&tmp1, &tmp2, "zero slope", &cats);
+	    Rast_set_d_cat(&tmp1, &tmp2, "zero slope", &cats);
 	}
 	}
 	/* INCR_BY_ONE
 	/* INCR_BY_ONE
-	   Rast_set_d_raster_cat (&tmp1, &tmp1, "no data", &cats);
+	   Rast_set_d_cat (&tmp1, &tmp1, "no data", &cats);
 	 */
 	 */
-	Rast_write_raster_cats(slope_name, &cats);
+	Rast_write_cats(slope_name, &cats);
 
 
 	/* writing history file */
 	/* writing history file */
 	Rast_short_history(slope_name, "raster", &hist);
 	Rast_short_history(slope_name, "raster", &hist);
@@ -1227,7 +1232,8 @@ int main(int argc, char *argv[])
 
 
 	Rast_read_cats(pcurv_name, G_mapset(), &cats);
 	Rast_read_cats(pcurv_name, G_mapset(), &cats);
 	Rast_set_cats_title("profile curvature", &cats);
 	Rast_set_cats_title("profile curvature", &cats);
-	Rast_set_cat((CELL) 0, "no profile curve", &cats);
+	cat = 0;
+	Rast_set_c_cat(&cat, &cat, "no profile curve", &cats);
 
 
 	/* writing history file */
 	/* writing history file */
 	Rast_short_history(pcurv_name, "raster", &hist);
 	Rast_short_history(pcurv_name, "raster", &hist);
@@ -1253,7 +1259,8 @@ int main(int argc, char *argv[])
 
 
 	Rast_read_cats(tcurv_name, G_mapset(), &cats);
 	Rast_read_cats(tcurv_name, G_mapset(), &cats);
 	Rast_set_cats_title("tangential curvature", &cats);
 	Rast_set_cats_title("tangential curvature", &cats);
-	Rast_set_cat((CELL) 0, "no tangential curve", &cats);
+	cat = 0;
+	Rast_set_c_cat(&cat, &cat, "no tangential curve", &cats);
 
 
 	/* writing history file */
 	/* writing history file */
 	Rast_short_history(tcurv_name, "raster", &hist);
 	Rast_short_history(tcurv_name, "raster", &hist);
@@ -1277,7 +1284,8 @@ int main(int argc, char *argv[])
 
 
 	Rast_read_cats(dx_name, G_mapset(), &cats);
 	Rast_read_cats(dx_name, G_mapset(), &cats);
 	Rast_set_cats_title("E-W slope", &cats);
 	Rast_set_cats_title("E-W slope", &cats);
-	Rast_set_cat((CELL) 0, "no E-W slope", &cats);
+	cat = 0;	
+	Rast_set_c_cat(&cat, &cat, "no E-W slope", &cats);
 
 
 	/* writing history file */
 	/* writing history file */
 	Rast_short_history(dx_name, "raster", &hist);
 	Rast_short_history(dx_name, "raster", &hist);
@@ -1301,7 +1309,8 @@ int main(int argc, char *argv[])
 
 
 	Rast_read_cats(dy_name, G_mapset(), &cats);
 	Rast_read_cats(dy_name, G_mapset(), &cats);
 	Rast_set_cats_title("N-S slope", &cats);
 	Rast_set_cats_title("N-S slope", &cats);
-	Rast_set_cat((CELL) 0, "no N-S slope", &cats);
+	cat = 0;
+	Rast_set_c_cat(&cat, &cat, "no N-S slope", &cats);
 
 
 	/* writing history file */
 	/* writing history file */
 	Rast_short_history(dy_name, "raster", &hist);
 	Rast_short_history(dy_name, "raster", &hist);
@@ -1325,7 +1334,8 @@ int main(int argc, char *argv[])
 
 
 	Rast_read_cats(dxx_name, G_mapset(), &cats);
 	Rast_read_cats(dxx_name, G_mapset(), &cats);
 	Rast_set_cats_title("DXX", &cats);
 	Rast_set_cats_title("DXX", &cats);
-	Rast_set_cat((CELL) 0, "DXX", &cats);
+	cat = 0;
+	Rast_set_c_cat(&cat, &cat, "DXX", &cats);
 
 
 	/* writing history file */
 	/* writing history file */
 	Rast_short_history(dxx_name, "raster", &hist);
 	Rast_short_history(dxx_name, "raster", &hist);
@@ -1349,7 +1359,8 @@ int main(int argc, char *argv[])
 
 
 	Rast_read_cats(dyy_name, G_mapset(), &cats);
 	Rast_read_cats(dyy_name, G_mapset(), &cats);
 	Rast_set_cats_title("DYY", &cats);
 	Rast_set_cats_title("DYY", &cats);
-	Rast_set_cat((CELL) 0, "DYY", &cats);
+	cat = 0;
+	Rast_set_c_cat(&cat, &cat, "DYY", &cats);
 
 
 	/* writing history file */
 	/* writing history file */
 	Rast_short_history(dyy_name, "raster", &hist);
 	Rast_short_history(dyy_name, "raster", &hist);
@@ -1373,7 +1384,8 @@ int main(int argc, char *argv[])
 
 
 	Rast_read_cats(dxy_name, G_mapset(), &cats);
 	Rast_read_cats(dxy_name, G_mapset(), &cats);
 	Rast_set_cats_title("DXY", &cats);
 	Rast_set_cats_title("DXY", &cats);
-	Rast_set_cat((CELL) 0, "DXY", &cats);
+	cat = 0;
+	Rast_set_c_cat(&cat, &cat, "DXY", &cats);
 
 
 	/* writing history file */
 	/* writing history file */
 	Rast_short_history(dxy_name, "raster", &hist);
 	Rast_short_history(dxy_name, "raster", &hist);

+ 1 - 1
raster/r.statistics/o_adev.c

@@ -54,7 +54,7 @@ o_adev(const char *basemap, const char *covermap, const char *outputmap, int use
 	}
 	}
 
 
 	if (usecats)
 	if (usecats)
-	    sscanf(Rast_get_cat((CELL) covercat, cats), "%lf", &x);
+	    sscanf(Rast_get_c_cat((CELL *) &covercat, cats), "%lf", &x);
 	else
 	else
 	    x = covercat;
 	    x = covercat;
 
 

+ 1 - 1
raster/r.statistics/o_average.c

@@ -54,7 +54,7 @@ o_average(const char *basemap, const char *covermap, const char *outputmap, int
 	    catb = basecat;
 	    catb = basecat;
 	}
 	}
 	if (usecats)
 	if (usecats)
-	    sscanf(Rast_get_cat((CELL) covercat, cats), "%lf", &x);
+	    sscanf(Rast_get_c_cat((CELL *) &covercat, cats), "%lf", &x);
 	else
 	else
 	    x = covercat;
 	    x = covercat;
 	sum1 += x * area;
 	sum1 += x * area;

+ 2 - 2
raster/r.statistics/o_divr.c

@@ -31,7 +31,7 @@ o_divr(const char *basemap, const char *covermap, const char *outputmap, int use
 	    catc = 0;
 	    catc = 0;
 	}
 	}
 	if (basecat != catb) {
 	if (basecat != catb) {
-	    write_reclass(reclass_fd, catb, catc, Rast_get_cat(catc, cats),
+	  write_reclass(reclass_fd, catb, catc, Rast_get_c_cat((CELL *) &catc, cats),
 			  usecats);
 			  usecats);
 	    catb = basecat;
 	    catb = basecat;
 	    catc = 0;
 	    catc = 0;
@@ -39,7 +39,7 @@ o_divr(const char *basemap, const char *covermap, const char *outputmap, int use
 	catc++;
 	catc++;
     }
     }
     if (!first)
     if (!first)
-	write_reclass(reclass_fd, catb, catc, Rast_get_cat(catc, cats), usecats);
+      write_reclass(reclass_fd, catb, catc, Rast_get_c_cat((CELL *) &catc, cats), usecats);
 
 
     pclose(stats_fd);
     pclose(stats_fd);
     pclose(reclass_fd);
     pclose(reclass_fd);

+ 1 - 1
raster/r.statistics/o_kurt.c

@@ -53,7 +53,7 @@ o_kurt(const char *basemap, const char *covermap, const char *outputmap, int use
 	}
 	}
 
 
 	if (usecats)
 	if (usecats)
-	    sscanf(Rast_get_cat((CELL) covercat, cats), "%lf", &x);
+	    sscanf(Rast_get_c_cat((CELL *) &covercat, cats), "%lf", &x);
 	else
 	else
 	    x = covercat;
 	    x = covercat;
 
 

+ 2 - 2
raster/r.statistics/o_max.c

@@ -30,7 +30,7 @@ o_max(const char *basemap, const char *covermap, const char *outputmap, int usec
 	}
 	}
 
 
 	if (basecat != catb) {
 	if (basecat != catb) {
-	    write_reclass(reclass, catb, catc, Rast_get_cat(catc, cats),
+	  write_reclass(reclass, catb, catc, Rast_get_c_cat((CELL *) &catc, cats),
 			  usecats);
 			  usecats);
 	    catb = basecat;
 	    catb = basecat;
 	    catc = covercat;
 	    catc = covercat;
@@ -44,7 +44,7 @@ o_max(const char *basemap, const char *covermap, const char *outputmap, int usec
 	catb = catc = 0;
 	catb = catc = 0;
     }
     }
 
 
-    write_reclass(reclass, catb, catc, Rast_get_cat(catc, cats), usecats);
+    write_reclass(reclass, catb, catc, Rast_get_c_cat((CELL *) &catc, cats), usecats);
 
 
     pclose(stats);
     pclose(stats);
     pclose(reclass);
     pclose(reclass);

+ 2 - 2
raster/r.statistics/o_median.c

@@ -42,7 +42,7 @@ o_median(const char *basemap, const char *covermap, const char *outputmap, int u
 	}
 	}
 	if (basecat != catb) {
 	if (basecat != catb) {
 	    catc = median(&stats);
 	    catc = median(&stats);
-	    write_reclass(reclass_fd, catb, catc, Rast_get_cat(catc, cats),
+	    write_reclass(reclass_fd, catb, catc, Rast_get_c_cat((CELL *) &catc, cats),
 			  usecats);
 			  usecats);
 	    catb = basecat;
 	    catb = basecat;
 	    stats.n = 0;
 	    stats.n = 0;
@@ -60,7 +60,7 @@ o_median(const char *basemap, const char *covermap, const char *outputmap, int u
     }
     }
     if (!first) {
     if (!first) {
 	catc = median(&stats);
 	catc = median(&stats);
-	write_reclass(reclass_fd, catb, catc, Rast_get_cat(catc, cats), usecats);
+	write_reclass(reclass_fd, catb, catc, Rast_get_c_cat((CELL *) &catc, cats), usecats);
     }
     }
 
 
     pclose(stats_fd);
     pclose(stats_fd);

+ 2 - 2
raster/r.statistics/o_min.c

@@ -30,7 +30,7 @@ o_min(const char *basemap, const char *covermap, const char *outputmap, int usec
 	}
 	}
 
 
 	if (basecat != catb) {
 	if (basecat != catb) {
-	    write_reclass(reclass, catb, catc, Rast_get_cat(catc, cats),
+	  write_reclass(reclass, catb, catc, Rast_get_c_cat((CELL *) &catc, cats),
 			  usecats);
 			  usecats);
 	    catb = basecat;
 	    catb = basecat;
 	    catc = covercat;
 	    catc = covercat;
@@ -44,7 +44,7 @@ o_min(const char *basemap, const char *covermap, const char *outputmap, int usec
 	catb = catc = 0;
 	catb = catc = 0;
     }
     }
 
 
-    write_reclass(reclass, catb, catc, Rast_get_cat(catc, cats), usecats);
+    write_reclass(reclass, catb, catc, Rast_get_c_cat((CELL *) &catc, cats), usecats);
 
 
     pclose(stats);
     pclose(stats);
     pclose(reclass);
     pclose(reclass);

+ 2 - 2
raster/r.statistics/o_mode.c

@@ -32,7 +32,7 @@ o_mode(const char *basemap, const char *covermap, const char *outputmap, int use
 	}
 	}
 
 
 	if (basecat != catb) {
 	if (basecat != catb) {
-	    write_reclass(reclass, catb, catc, Rast_get_cat(catc, cats),
+	  write_reclass(reclass, catb, catc, Rast_get_c_cat((CELL *) &catc, cats),
 			  usecats);
 			  usecats);
 	    catb = basecat;
 	    catb = basecat;
 	    catc = covercat;
 	    catc = covercat;
@@ -49,7 +49,7 @@ o_mode(const char *basemap, const char *covermap, const char *outputmap, int use
 	catb = catc = 0;
 	catb = catc = 0;
     }
     }
 
 
-    write_reclass(reclass, catb, catc, Rast_get_cat(catc, cats), usecats);
+    write_reclass(reclass, catb, catc, Rast_get_c_cat((CELL *) &catc, cats), usecats);
 
 
     pclose(stats);
     pclose(stats);
     pclose(reclass);
     pclose(reclass);

+ 1 - 1
raster/r.statistics/o_sdev.c

@@ -56,7 +56,7 @@ o_sdev(const char *basemap, const char *covermap, const char *outputmap, int use
 	}
 	}
 
 
 	if (usecats)
 	if (usecats)
-	    sscanf(Rast_get_cat((CELL) covercat, cats), "%lf", &x);
+	    sscanf(Rast_get_c_cat((CELL *) &covercat, cats), "%lf", &x);
 	else
 	else
 	    x = covercat;
 	    x = covercat;
 
 

+ 1 - 1
raster/r.statistics/o_skew.c

@@ -55,7 +55,7 @@ o_skew(const char *basemap, const char *covermap, const char *outputmap, int use
 	}
 	}
 
 
 	if (usecats)
 	if (usecats)
-	    sscanf(Rast_get_cat((CELL) covercat, cats), "%lf", &x);
+	    sscanf(Rast_get_c_cat((CELL *) &covercat, cats), "%lf", &x);
 	else
 	else
 	    x = covercat;
 	    x = covercat;
 
 

+ 1 - 1
raster/r.statistics/o_sum.c

@@ -56,7 +56,7 @@ o_sum(const char *basemap, const char *covermap, const char *outputmap, int usec
 	    catb = basecat;
 	    catb = basecat;
 	}
 	}
 	if (usecats)
 	if (usecats)
-	    sscanf(Rast_get_cat((CELL) covercat, cats), "%lf", &x);
+	    sscanf(Rast_get_c_cat((CELL *) &covercat, cats), "%lf", &x);
 	else
 	else
 	    x = covercat;
 	    x = covercat;
 	sum1 += x * area;
 	sum1 += x * area;

+ 1 - 1
raster/r.statistics/o_var.c

@@ -56,7 +56,7 @@ o_var(const char *basemap, const char *covermap, const char *outputmap, int usec
 	}
 	}
 
 
 	if (usecats)
 	if (usecats)
-	    sscanf(Rast_get_cat((CELL) covercat, cats), "%lf", &x);
+	    sscanf(Rast_get_c_cat((CELL *) &covercat, cats), "%lf", &x);
 	else
 	else
 	    x = covercat;
 	    x = covercat;
 
 

+ 2 - 2
raster/r.statistics2/main.c

@@ -270,7 +270,7 @@ int main(int argc, char **argv)
 
 
 	    v = cover_buf[col];
 	    v = cover_buf[col];
 	    if (usecats)
 	    if (usecats)
-		sscanf(Rast_get_cat((CELL) v, &cats), "%lf", &v);
+		sscanf(Rast_get_c_cat((CELL *) &v, &cats), "%lf", &v);
 
 
 	    if (count)
 	    if (count)
 		count[n]++;
 		count[n]++;
@@ -349,7 +349,7 @@ int main(int argc, char **argv)
 
 
 		v = cover_buf[col];
 		v = cover_buf[col];
 		if (usecats)
 		if (usecats)
-		    sscanf(Rast_get_cat((CELL) v, &cats), "%lf", &v);
+		    sscanf(Rast_get_c_cat((CELL *) &v, &cats), "%lf", &v);
 		d = v - mean[n];
 		d = v - mean[n];
 
 
 		if (sumu)
 		if (sumu)

+ 3 - 3
raster/r.stats/raw_stats.c

@@ -82,14 +82,14 @@ int raw_stats(int fd[], int with_coordinates, int with_xy, int with_labels)
 		    fprintf(stdout, "%s%s", i ? fs : "", no_data_str);
 		    fprintf(stdout, "%s%s", i ? fs : "", no_data_str);
 		    if (with_labels)
 		    if (with_labels)
 			fprintf(stdout, "%s%s", fs,
 			fprintf(stdout, "%s%s", fs,
-				Rast_get_cat(null_cell, &labels[i]));
+				Rast_get_c_cat(&null_cell, &labels[i]));
 		}
 		}
 		else if (map_type[i] == CELL_TYPE) {
 		else if (map_type[i] == CELL_TYPE) {
 		    fprintf(stdout, "%s%ld", i ? fs : "",
 		    fprintf(stdout, "%s%ld", i ? fs : "",
 			    (long)*((CELL *) rastp[i]));
 			    (long)*((CELL *) rastp[i]));
 		    if (with_labels && !is_fp[i])
 		    if (with_labels && !is_fp[i])
 			fprintf(stdout, "%s%s", fs,
 			fprintf(stdout, "%s%s", fs,
-				Rast_get_cat(*((CELL *) rastp[i]), &labels[i]));
+				Rast_get_c_cat((CELL *) rastp[i], &labels[i]));
 		}
 		}
 		else {		/* floating point cell */
 		else {		/* floating point cell */
 
 
@@ -99,7 +99,7 @@ int raw_stats(int fd[], int with_coordinates, int with_xy, int with_labels)
 		    fprintf(stdout, "%s%s", i ? fs : "", str1);
 		    fprintf(stdout, "%s%s", i ? fs : "", str1);
 		    if (with_labels)
 		    if (with_labels)
 			fprintf(stdout, "%s%s", fs,
 			fprintf(stdout, "%s%s", fs,
-				Rast_get_d_raster_cat((DCELL *) rastp[i],
+				Rast_get_d_cat((DCELL *) rastp[i],
 						   &labels[i]));
 						   &labels[i]));
 		}
 		}
 		rastp[i] =
 		rastp[i] =

+ 5 - 5
raster/r.stats/stats.c

@@ -242,7 +242,7 @@ int print_cell_stats(char *fmt, int with_percents, int with_counts,
 	if (with_percents)
 	if (with_percents)
 	    fprintf(stdout, "%s0.00%%", fs);
 	    fprintf(stdout, "%s0.00%%", fs);
 	if (with_labels)
 	if (with_labels)
-	    fprintf(stdout, "%s%s", fs, Rast_get_cat(null_cell, &labels[i]));
+	    fprintf(stdout, "%s%s", fs, Rast_get_c_cat(&null_cell, &labels[i]));
 	fprintf(stdout, "\n");
 	fprintf(stdout, "\n");
     }
     }
     else {
     else {
@@ -271,14 +271,14 @@ int print_cell_stats(char *fmt, int with_percents, int with_counts,
 		    fprintf(stdout, "%s%s", i ? fs : "", no_data_str);
 		    fprintf(stdout, "%s%s", i ? fs : "", no_data_str);
 		    if (with_labels && !(raw_output && is_fp[i]))
 		    if (with_labels && !(raw_output && is_fp[i]))
 			fprintf(stdout, "%s%s", fs,
 			fprintf(stdout, "%s%s", fs,
-				Rast_get_cat(null_cell, &labels[i]));
+				Rast_get_c_cat(&null_cell, &labels[i]));
 		}
 		}
 		else if (raw_output || !is_fp[i] || as_int) {
 		else if (raw_output || !is_fp[i] || as_int) {
 		    fprintf(stdout, "%s%ld", i ? fs : "",
 		    fprintf(stdout, "%s%ld", i ? fs : "",
 			    (long)node->values[i]);
 			    (long)node->values[i]);
 		    if (with_labels && !is_fp[i])
 		    if (with_labels && !is_fp[i])
 			fprintf(stdout, "%s%s", fs,
 			fprintf(stdout, "%s%s", fs,
-				Rast_get_cat((CELL) node->values[i],
+				Rast_get_c_cat((CELL*) &(node->values[i]),
 					  &labels[i]));
 					  &labels[i]));
 		}
 		}
 		else {		/* find out which floating point range to print */
 		else {		/* find out which floating point range to print */
@@ -316,8 +316,8 @@ int print_cell_stats(char *fmt, int with_percents, int with_counts,
 				    labels[i].labels[node->values[i]]);
 				    labels[i].labels[node->values[i]]);
 			else
 			else
 			    fprintf(stdout, "%sfrom %s to %s", fs,
 			    fprintf(stdout, "%sfrom %s to %s", fs,
-				    Rast_get_d_raster_cat(&dLow, &labels[i]),
-				    Rast_get_d_raster_cat(&dHigh, &labels[i]));
+				    Rast_get_d_cat(&dLow, &labels[i]),
+				    Rast_get_d_cat(&dHigh, &labels[i]));
 		    }
 		    }
 		}
 		}
 
 

+ 1 - 1
raster/r.to.vect/areas_io.c

@@ -357,7 +357,7 @@ int write_area(struct area_table *a_list,	/* list of areas */
 		db_append_string(&sql, buf);
 		db_append_string(&sql, buf);
 
 
 		if (has_cats) {
 		if (has_cats) {
-		    temp_buf = Rast_get_cat(p->cat, &RastCats);
+		    temp_buf = Rast_get_c_cat(&(p->cat), &RastCats);
 
 
 		    db_set_string(&label, temp_buf);
 		    db_set_string(&label, temp_buf);
 		    db_double_quote_string(&label);
 		    db_double_quote_string(&label);

+ 1 - 1
raster/r.to.vect/util.c

@@ -141,7 +141,7 @@ void insert_value(int cat, int val, double dval)
     if (has_cats) {
     if (has_cats) {
 	char *lab;
 	char *lab;
 
 
-	lab = Rast_get_cat(val, &RastCats);	/*cats are loaded only for CELL type */
+	lab = Rast_get_c_cat(&val, &RastCats);	/*cats are loaded only for CELL type */
 
 
 	db_set_string(&label, lab);
 	db_set_string(&label, lab);
 	db_double_quote_string(&label);
 	db_double_quote_string(&label);

+ 2 - 2
raster/r.volume/main.c

@@ -133,7 +133,7 @@ int main(int argc, char *argv[])
     }
     }
 
 
     /* initialize data accumulation arrays */
     /* initialize data accumulation arrays */
-    max = Rast_number_of_cats(clumpmap, clump_mapset);
+    max = Rast_get_max_c_cat(clumpmap, clump_mapset);
 
 
     sum = (double *)G_malloc((max + 1) * sizeof(double));
     sum = (double *)G_malloc((max + 1) * sizeof(double));
     count = (long int *)G_malloc((max + 1) * sizeof(long int));
     count = (long int *)G_malloc((max + 1) * sizeof(long int));
@@ -164,7 +164,7 @@ int main(int argc, char *argv[])
 	    if (i > max)
 	    if (i > max)
 		G_fatal_error(
 		G_fatal_error(
 		    "Row=%d Col=%d Cat=%d in clump map [%s]; max=%d.\n"
 		    "Row=%d Col=%d Cat=%d in clump map [%s]; max=%d.\n"
-		    "Cat value > max returned by Rast_number_of_cats.",
+		    "Cat value > max returned by Rast_get_max_c_cat.",
 		    row, col, i, clumpmap, max);
 		    row, col, i, clumpmap, max);
 	    if (i < 1)
 	    if (i < 1)
 		continue;	/* ignore zeros and negs */
 		continue;	/* ignore zeros and negs */

+ 1 - 1
raster/r.watershed/shed/print.c

@@ -67,7 +67,7 @@ int print_output(OUTPUT * output)
 	    do_cat = &(output->maps[b].basins[c].first_cat);
 	    do_cat = &(output->maps[b].basins[c].first_cat);
 	    while ((output->maps[b].do_cats != 0) && do_cat) {
 	    while ((output->maps[b].do_cats != 0) && do_cat) {
 		cat_name =
 		cat_name =
-		    Rast_get_cat(do_cat->cat_val, &(output->maps[b].cats));
+		    Rast_get_c_cat(&(do_cat->cat_val), &(output->maps[b].cats));
 		switch (output->type_area) {
 		switch (output->type_area) {
 		case 1:
 		case 1:
 		    sprintf(area, "%.3f acres",
 		    sprintf(area, "%.3f acres",

+ 1 - 1
raster/r.what/main.c

@@ -404,7 +404,7 @@ int main(int argc, char *argv[])
 		}
 		}
 		if (withcats)
 		if (withcats)
 		    fprintf(stdout, "%c%s", fs,
 		    fprintf(stdout, "%c%s", fs,
-			    Rast_get_cat(cache[point].value[i], &cats[i]));
+			    Rast_get_c_cat(&(cache[point].value[i]), &cats[i]));
 		if (flag4->answer)
 		if (flag4->answer)
 		    fprintf(stdout, "%c%s", fs, cache[point].clr_buf[i]);
 		    fprintf(stdout, "%c%s", fs, cache[point].clr_buf[i]);
 	    }
 	    }

+ 33 - 33
swig/perl/R_slope_aspect/r_slope_aspect/r_slope_aspect.c

@@ -1035,8 +1035,8 @@ int r_slope_aspect(int argc, char *argv[])
 	    Rast_quantize_fp_map_range(aspect_name, G_mapset(), 0., 360., 0,
 	    Rast_quantize_fp_map_range(aspect_name, G_mapset(), 0., 360., 0,
 				    360);
 				    360);
 
 
-	Rast_read_raster_cats(aspect_name, G_mapset(), &cats);
-	Rast_set_raster_cats_title
+	Rast_read_cats(aspect_name, G_mapset(), &cats);
+	Rast_set_cats_title
 	    ("Aspect counterclockwise in degrees from east", &cats);
 	    ("Aspect counterclockwise in degrees from east", &cats);
 
 
 	G_message(_("Min computed aspect %.4f, max computed aspect %.4f"),
 	G_message(_("Min computed aspect %.4f, max computed aspect %.4f"),
@@ -1068,22 +1068,22 @@ int r_slope_aspect(int argc, char *argv[])
 		sprintf(buf, "%d degree%s ccw from east", i,
 		sprintf(buf, "%d degree%s ccw from east", i,
 			i == 1 ? "" : "s");
 			i == 1 ? "" : "s");
 	    if (data_type == CELL_TYPE) {
 	    if (data_type == CELL_TYPE) {
-		Rast_set_cat(i, buf, &cats);
+		Rast_set_c_cat(i, buf, &cats);
 		continue;
 		continue;
 	    }
 	    }
 	    tmp1 = (double)i - .5;
 	    tmp1 = (double)i - .5;
 	    tmp2 = (double)i + .5;
 	    tmp2 = (double)i + .5;
-	    Rast_set_d_raster_cat(&tmp1, &tmp2, buf, &cats);
+	    Rast_set_d_cat(&tmp1, &tmp2, buf, &cats);
 	}
 	}
 	if (data_type == CELL_TYPE)
 	if (data_type == CELL_TYPE)
-	    Rast_set_cat(0, "no aspect", &cats);
+	    Rast_set_c_cat(0, "no aspect", &cats);
 	else {
 	else {
 	    tmp1 = 0.;
 	    tmp1 = 0.;
 	    tmp2 = .5;
 	    tmp2 = .5;
-	    Rast_set_d_raster_cat(&tmp1, &tmp2, "no aspect", &cats);
+	    Rast_set_d_cat(&tmp1, &tmp2, "no aspect", &cats);
 	}
 	}
-	Rast_write_raster_cats(aspect_name, &cats);
-	Rast_free_raster_cats(&cats);
+	Rast_write_cats(aspect_name, &cats);
+	Rast_free_cats(&cats);
 
 
 	/* write colors for aspect file */
 	/* write colors for aspect file */
 	Rast_init_colors(&colors);
 	Rast_init_colors(&colors);
@@ -1137,11 +1137,11 @@ int r_slope_aspect(int argc, char *argv[])
 					(CELL) ceil(max_slp));
 					(CELL) ceil(max_slp));
 	}
 	}
 
 
-	Rast_read_raster_cats(slope_name, G_mapset(), &cats);
+	Rast_read_cats(slope_name, G_mapset(), &cats);
 	if (deg)
 	if (deg)
-	    Rast_set_raster_cats_title("slope in degrees", &cats);
+	    Rast_set_cats_title("slope in degrees", &cats);
 	else if (perc)
 	else if (perc)
-	    Rast_set_raster_cats_title("percent slope", &cats);
+	    Rast_set_cats_title("percent slope", &cats);
 
 
 	G_message(_("Min computed slope %.4f, max computed slope %.4f"),
 	G_message(_("Min computed slope %.4f, max computed slope %.4f"),
 		  min_slp, max_slp);
 		  min_slp, max_slp);
@@ -1156,9 +1156,9 @@ int r_slope_aspect(int argc, char *argv[])
 		sprintf(buf, "%d percent", i);
 		sprintf(buf, "%d percent", i);
 	    if (data_type == CELL_TYPE) {
 	    if (data_type == CELL_TYPE) {
 		/* INCR_BY_ONE
 		/* INCR_BY_ONE
-		   Rast_set_cat(i+1, buf, &cats);
+		   Rast_set_c_cat(i+1, buf, &cats);
 		 */
 		 */
-		Rast_set_cat(i, buf, &cats);
+		Rast_set_c_cat(i, buf, &cats);
 		continue;
 		continue;
 	    }
 	    }
 	    /* INCR_BY_ONE
 	    /* INCR_BY_ONE
@@ -1167,22 +1167,22 @@ int r_slope_aspect(int argc, char *argv[])
 	     */
 	     */
 	    tmp1 = (DCELL) i - .5;
 	    tmp1 = (DCELL) i - .5;
 	    tmp2 = (DCELL) i + .5;
 	    tmp2 = (DCELL) i + .5;
-	    Rast_set_d_raster_cat(&tmp1, &tmp2, buf, &cats);
+	    Rast_set_d_cat(&tmp1, &tmp2, buf, &cats);
 	}
 	}
 	if (data_type == CELL_TYPE)
 	if (data_type == CELL_TYPE)
-	    Rast_set_cat(0, "zero slope", &cats);
+	    Rast_set_c_cat(0, "zero slope", &cats);
 	/* INCR_BY_ONE
 	/* INCR_BY_ONE
-	   Rast_set_cat(0, "no data", &cats);
+	   Rast_set_c_cat(0, "no data", &cats);
 	 */
 	 */
 	else {
 	else {
 	    tmp1 = 0;
 	    tmp1 = 0;
 	    tmp2 = 0.5;
 	    tmp2 = 0.5;
-	    Rast_set_d_raster_cat(&tmp1, &tmp2, "zero slope", &cats);
+	    Rast_set_d_cat(&tmp1, &tmp2, "zero slope", &cats);
 	}
 	}
 	/* INCR_BY_ONE
 	/* INCR_BY_ONE
-	   Rast_set_d_raster_cat (&tmp1, &tmp1, "no data", &cats);
+	   Rast_set_d_cat (&tmp1, &tmp1, "no data", &cats);
 	 */
 	 */
-	Rast_write_raster_cats(slope_name, &cats);
+	Rast_write_cats(slope_name, &cats);
 
 
 	/* writing history file */
 	/* writing history file */
 	Rast_short_history(slope_name, "raster", &hist);
 	Rast_short_history(slope_name, "raster", &hist);
@@ -1253,8 +1253,8 @@ int r_slope_aspect(int argc, char *argv[])
 	    Rast_round_fp_map(pcurv_name, G_mapset());
 	    Rast_round_fp_map(pcurv_name, G_mapset());
 
 
 	Rast_read_cats(pcurv_name, G_mapset(), &cats);
 	Rast_read_cats(pcurv_name, G_mapset(), &cats);
-	Rast_set_cats_title("profile curvature", &cats);
-	Rast_set_cat((CELL) 0, "no profile curve", &cats);
+	Rast_set_c_cats_title("profile curvature", &cats);
+	Rast_set_c_cat((CELL) 0, "no profile curve", &cats);
 
 
 	/* writing history file */
 	/* writing history file */
 	Rast_short_history(pcurv_name, "raster", &hist);
 	Rast_short_history(pcurv_name, "raster", &hist);
@@ -1279,8 +1279,8 @@ int r_slope_aspect(int argc, char *argv[])
 	    Rast_round_fp_map(tcurv_name, G_mapset());
 	    Rast_round_fp_map(tcurv_name, G_mapset());
 
 
 	Rast_read_cats(tcurv_name, G_mapset(), &cats);
 	Rast_read_cats(tcurv_name, G_mapset(), &cats);
-	Rast_set_cats_title("tangential curvature", &cats);
-	Rast_set_cat((CELL) 0, "no tangential curve", &cats);
+	Rast_set_c_cats_title("tangential curvature", &cats);
+	Rast_set_c_cat((CELL) 0, "no tangential curve", &cats);
 
 
 	/* writing history file */
 	/* writing history file */
 	Rast_short_history(tcurv_name, "raster", &hist);
 	Rast_short_history(tcurv_name, "raster", &hist);
@@ -1303,8 +1303,8 @@ int r_slope_aspect(int argc, char *argv[])
 	    Rast_round_fp_map(dx_name, G_mapset());
 	    Rast_round_fp_map(dx_name, G_mapset());
 
 
 	Rast_read_cats(dx_name, G_mapset(), &cats);
 	Rast_read_cats(dx_name, G_mapset(), &cats);
-	Rast_set_cats_title("E-W slope", &cats);
-	Rast_set_cat((CELL) 0, "no E-W slope", &cats);
+	Rast_set_c_cats_title("E-W slope", &cats);
+	Rast_set_c_cat((CELL) 0, "no E-W slope", &cats);
 
 
 	/* writing history file */
 	/* writing history file */
 	Rast_short_history(dx_name, "raster", &hist);
 	Rast_short_history(dx_name, "raster", &hist);
@@ -1327,8 +1327,8 @@ int r_slope_aspect(int argc, char *argv[])
 	    Rast_round_fp_map(dy_name, G_mapset());
 	    Rast_round_fp_map(dy_name, G_mapset());
 
 
 	Rast_read_cats(dy_name, G_mapset(), &cats);
 	Rast_read_cats(dy_name, G_mapset(), &cats);
-	Rast_set_cats_title("N-S slope", &cats);
-	Rast_set_cat((CELL) 0, "no N-S slope", &cats);
+	Rast_set_c_cats_title("N-S slope", &cats);
+	Rast_set_c_cat((CELL) 0, "no N-S slope", &cats);
 
 
 	/* writing history file */
 	/* writing history file */
 	Rast_short_history(dy_name, "raster", &hist);
 	Rast_short_history(dy_name, "raster", &hist);
@@ -1351,8 +1351,8 @@ int r_slope_aspect(int argc, char *argv[])
 	    Rast_round_fp_map(dxx_name, G_mapset());
 	    Rast_round_fp_map(dxx_name, G_mapset());
 
 
 	Rast_read_cats(dxx_name, G_mapset(), &cats);
 	Rast_read_cats(dxx_name, G_mapset(), &cats);
-	Rast_set_cats_title("DXX", &cats);
-	Rast_set_cat((CELL) 0, "DXX", &cats);
+	Rast_set_c_cats_title("DXX", &cats);
+	Rast_set_c_cat((CELL) 0, "DXX", &cats);
 
 
 	/* writing history file */
 	/* writing history file */
 	Rast_short_history(dxx_name, "raster", &hist);
 	Rast_short_history(dxx_name, "raster", &hist);
@@ -1375,8 +1375,8 @@ int r_slope_aspect(int argc, char *argv[])
 	    Rast_round_fp_map(dyy_name, G_mapset());
 	    Rast_round_fp_map(dyy_name, G_mapset());
 
 
 	Rast_read_cats(dyy_name, G_mapset(), &cats);
 	Rast_read_cats(dyy_name, G_mapset(), &cats);
-	Rast_set_cats_title("DYY", &cats);
-	Rast_set_cat((CELL) 0, "DYY", &cats);
+	Rast_set_c_cats_title("DYY", &cats);
+	Rast_set_c_cat((CELL) 0, "DYY", &cats);
 
 
 	/* writing history file */
 	/* writing history file */
 	Rast_short_history(dyy_name, "raster", &hist);
 	Rast_short_history(dyy_name, "raster", &hist);
@@ -1399,8 +1399,8 @@ int r_slope_aspect(int argc, char *argv[])
 	    Rast_round_fp_map(dxy_name, G_mapset());
 	    Rast_round_fp_map(dxy_name, G_mapset());
 
 
 	Rast_read_cats(dxy_name, G_mapset(), &cats);
 	Rast_read_cats(dxy_name, G_mapset(), &cats);
-	Rast_set_cats_title("DXY", &cats);
-	Rast_set_cat((CELL) 0, "DXY", &cats);
+	Rast_set_c_cats_title("DXY", &cats);
+	Rast_set_c_cat((CELL) 0, "DXY", &cats);
 
 
 	/* writing history file */
 	/* writing history file */
 	Rast_short_history(dxy_name, "raster", &hist);
 	Rast_short_history(dxy_name, "raster", &hist);

+ 17 - 16
vector/v.to.rast/support.c

@@ -71,11 +71,11 @@ int update_fcolors(const char *raster_name)
 int update_cats(const char *raster_name)
 int update_cats(const char *raster_name)
 {
 {
     /* TODO: maybe attribute transfer from vector map? 
     /* TODO: maybe attribute transfer from vector map? 
-       Use Rast_set_raster_cat() somewhere */
+       Use Rast_set_cat() somewhere */
 
 
     struct Categories cats;
     struct Categories cats;
 
 
-    Rast_init_cats((CELL) 0, raster_name, &cats);
+    Rast_init_cats(raster_name, &cats);
     Rast_write_cats(raster_name, &cats);
     Rast_write_cats(raster_name, &cats);
 
 
     return 0;
     return 0;
@@ -257,7 +257,7 @@ int update_labels(const char *rast_name, const char *vector_map, int field,
     } *my_labels_rules;
     } *my_labels_rules;
 
 
     /* init raster categories */
     /* init raster categories */
-    Rast_init_cats((CELL) 0, "Categories", &rast_cats);
+    Rast_init_cats("Categories", &rast_cats);
 
 
     if (!(fd = Rast_open_cell_old(rast_name, G_mapset())))
     if (!(fd = Rast_open_cell_old(rast_name, G_mapset())))
 	G_fatal_error(_("Unable to open raster map <%s>"), rast_name);
 	G_fatal_error(_("Unable to open raster map <%s>"), rast_name);
@@ -265,7 +265,7 @@ int update_labels(const char *rast_name, const char *vector_map, int field,
     switch (use) {
     switch (use) {
     case USE_ATTR:
     case USE_ATTR:
 	{
 	{
-	    Rast_set_raster_cats_title("Labels", &rast_cats);
+	    Rast_set_cats_title("Labels", &rast_cats);
 	    int is_fp = Rast_raster_map_is_fp(rast_name, G_mapset());
 	    int is_fp = Rast_raster_map_is_fp(rast_name, G_mapset());
 
 
 	    /* open vector map and database driver */
 	    /* open vector map and database driver */
@@ -362,16 +362,17 @@ int update_labels(const char *rast_name, const char *vector_map, int field,
 	    if (is_fp) {
 	    if (is_fp) {
 		/* add label */
 		/* add label */
 		for (i = 0; i < labels_n_values - 1; i++)
 		for (i = 0; i < labels_n_values - 1; i++)
-		    Rast_set_raster_cat(&my_labels_rules[i].d,
+		    Rast_set_cat(&my_labels_rules[i].d,
 				     &my_labels_rules[i + 1].d,
 				     &my_labels_rules[i + 1].d,
 				     db_get_string(&my_labels_rules[i].label),
 				     db_get_string(&my_labels_rules[i].label),
 				     &rast_cats, DCELL_TYPE);
 				     &rast_cats, DCELL_TYPE);
 	    }
 	    }
 	    else {
 	    else {
 		for (i = 0; i < labels_n_values; i++)
 		for (i = 0; i < labels_n_values; i++)
-		    Rast_set_cat(my_labels_rules[i].i,
-			      db_get_string(&my_labels_rules[i].label),
-			      &rast_cats);
+		  Rast_set_c_cat(&(my_labels_rules[i].i),
+				 &(my_labels_rules[i].i),
+				 db_get_string(&my_labels_rules[i].label),
+				 &rast_cats);
 	    }
 	    }
 	}
 	}
 	break;
 	break;
@@ -383,7 +384,7 @@ int update_labels(const char *rast_name, const char *vector_map, int field,
 	    struct Range range;
 	    struct Range range;
 
 
 	    map_type = Rast_raster_map_type(rast_name, G_mapset());
 	    map_type = Rast_raster_map_type(rast_name, G_mapset());
-	    Rast_set_raster_cats_title("Values", &rast_cats);
+	    Rast_set_cats_title("Values", &rast_cats);
 
 
 	    if (map_type == CELL_TYPE) {
 	    if (map_type == CELL_TYPE) {
 		CELL min, max;
 		CELL min, max;
@@ -392,7 +393,7 @@ int update_labels(const char *rast_name, const char *vector_map, int field,
 		Rast_get_range_min_max(&range, &min, &max);
 		Rast_get_range_min_max(&range, &min, &max);
 
 
 		sprintf(msg, "Value %d", val);
 		sprintf(msg, "Value %d", val);
-		Rast_set_raster_cat(&min, &max, msg, &rast_cats, map_type);
+		Rast_set_cat(&min, &max, msg, &rast_cats, map_type);
 	    }
 	    }
 	    else {
 	    else {
 		DCELL fmin, fmax;
 		DCELL fmin, fmax;
@@ -401,7 +402,7 @@ int update_labels(const char *rast_name, const char *vector_map, int field,
 		Rast_get_fp_range_min_max(&fprange, &fmin, &fmax);
 		Rast_get_fp_range_min_max(&fprange, &fmin, &fmax);
 
 
 		sprintf(msg, "Value %.4f", (double)val);
 		sprintf(msg, "Value %.4f", (double)val);
-		Rast_set_raster_cat(&fmin, &fmax, msg, &rast_cats, map_type);
+		Rast_set_cat(&fmin, &fmax, msg, &rast_cats, map_type);
 	    }
 	    }
 
 
 	}
 	}
@@ -424,7 +425,7 @@ int update_labels(const char *rast_name, const char *vector_map, int field,
 		G_fatal_error(_("Cannot allocate memory for row buffer"));
 		G_fatal_error(_("Cannot allocate memory for row buffer"));
 
 
 	    Rast_init_cell_stats(&stats);
 	    Rast_init_cell_stats(&stats);
-	    Rast_set_raster_cats_title("Categories", &rast_cats);
+	    Rast_set_cats_title("Categories", &rast_cats);
 
 
 	    rows = G_window_rows();
 	    rows = G_window_rows();
 
 
@@ -442,7 +443,7 @@ int update_labels(const char *rast_name, const char *vector_map, int field,
 		char msg[80];
 		char msg[80];
 
 
 		sprintf(msg, "Category %d", n);
 		sprintf(msg, "Category %d", n);
-		Rast_set_raster_cat(&n, &n, msg, &rast_cats, map_type);
+		Rast_set_cat(&n, &n, msg, &rast_cats, map_type);
 	    }
 	    }
 
 
 	    G_free(rowbuf);
 	    G_free(rowbuf);
@@ -456,7 +457,7 @@ int update_labels(const char *rast_name, const char *vector_map, int field,
 	    char msg[64];
 	    char msg[64];
 
 
 	    map_type = Rast_raster_map_type(rast_name, G_mapset());
 	    map_type = Rast_raster_map_type(rast_name, G_mapset());
-	    Rast_set_raster_cats_title("Degrees", &rast_cats);
+	    Rast_set_cats_title("Degrees", &rast_cats);
 
 
 	    for (i = 1; i <= 360; i++) {
 	    for (i = 1; i <= 360; i++) {
 		sprintf(msg, "%d degrees", i);
 		sprintf(msg, "%d degrees", i);
@@ -464,7 +465,7 @@ int update_labels(const char *rast_name, const char *vector_map, int field,
 		if (i == 360) {
 		if (i == 360) {
 		    fmin = 359.5;
 		    fmin = 359.5;
 		    fmax = 360.0;
 		    fmax = 360.0;
-		    Rast_set_raster_cat(&fmin, &fmax, msg, &rast_cats, map_type);
+		    Rast_set_cat(&fmin, &fmax, msg, &rast_cats, map_type);
 		    fmin = 0.0;
 		    fmin = 0.0;
 		    fmax = 0.5;
 		    fmax = 0.5;
 		}
 		}
@@ -473,7 +474,7 @@ int update_labels(const char *rast_name, const char *vector_map, int field,
 		    fmax = i + 0.5;
 		    fmax = i + 0.5;
 		}
 		}
 
 
-		Rast_set_raster_cat(&fmin, &fmax, msg, &rast_cats, map_type);
+		Rast_set_cat(&fmin, &fmax, msg, &rast_cats, map_type);
 	    }
 	    }
 	}
 	}
 	break;
 	break;