Browse Source

r.geomorphon: Move ccolors[] to memory.c

Put the array into the only function that reads from it, and move the
typedef as well.
Denis Ovsienko 4 years ago
parent
commit
f954b9dd9b
3 changed files with 26 additions and 27 deletions
  1. 1 10
      raster/r.geomorphon/local_proto.h
  2. 1 16
      raster/r.geomorphon/main.c
  3. 24 1
      raster/r.geomorphon/memory.c

+ 1 - 10
raster/r.geomorphon/local_proto.h

@@ -74,15 +74,6 @@ typedef enum
     CNT				/* counter */
 } FORMS;
 
-typedef struct
-{
-    int cat;
-    int r;
-    int g;
-    int b;
-    char *label;
-} CATCOLORS;
-
 /* main */
 GLOBAL MAPS elevation;
 GLOBAL int ncols, row_radius_size, row_buffer_size;
@@ -97,7 +88,7 @@ GLOBAL unsigned int global_ternary_codes[6562];
 int open_map(MAPS * rast);
 int shift_buffers(int row);
 int free_map(FCELL ** map, int n);
-int write_form_cat_colors(char *raster, CATCOLORS * ccolors);
+int write_form_cat_colors(char *raster);
 int write_contrast_colors(char *);
 
 /* pattern */

+ 1 - 16
raster/r.geomorphon/main.c

@@ -81,21 +81,6 @@ int main(int argc, char **argv)
 	 "Geometry", FCELL_TYPE, -1, NULL}
     };				/* adding more maps change IOSIZE macro */
 
-    CATCOLORS ccolors[CNT] = {	/* colors and cats for forms */
-	{ZERO, 0, 0, 0, "forms"},
-	{FL, 220, 220, 220, "flat"},
-	{PK, 56, 0, 0, "summit"},
-	{RI, 200, 0, 0, "ridge"},
-	{SH, 255, 80, 20, "shoulder"},
-	{SP, 250, 210, 60, "spur"},
-	{SL, 255, 255, 60, "slope"},
-	{HL, 180, 230, 20, "hollow"},
-	{FS, 60, 250, 150, "footslope"},
-	{VL, 0, 0, 255, "valley"},
-	{PT, 0, 0, 56, "depression"},
-	{__, 255, 0, 255, "ERROR"}
-    };
-
     struct GModule *module;
     struct Option
 	*opt_input,
@@ -506,7 +491,7 @@ int main(int argc, char **argv)
 	    }
 
 	if (opt_output[o_forms]->answer)
-	    write_form_cat_colors(opt_output[o_forms]->answer, ccolors);
+	    write_form_cat_colors(opt_output[o_forms]->answer);
 	if (opt_output[o_intensity]->answer)
 	    write_contrast_colors(opt_output[o_intensity]->answer);
 	if (opt_output[o_exposition]->answer)

+ 24 - 1
raster/r.geomorphon/memory.c

@@ -2,6 +2,15 @@
 
 typedef struct
 {
+    int cat;
+    int r;
+    int g;
+    int b;
+    char *label;
+} CATCOLORS;
+
+typedef struct
+{
     double cat;
     int r;
     int g;
@@ -111,11 +120,25 @@ int free_map(FCELL ** map, int n)
     return 0;
 }
 
-int write_form_cat_colors(char *raster, CATCOLORS * ccolors)
+int write_form_cat_colors(char *raster)
 {
     struct Colors colors;
     struct Categories cats;
     FORMS i;
+    const CATCOLORS ccolors[CNT] = {	/* colors and cats for forms */
+	{ZERO, 0, 0, 0, "forms"},
+	{FL, 220, 220, 220, "flat"},
+	{PK, 56, 0, 0, "summit"},
+	{RI, 200, 0, 0, "ridge"},
+	{SH, 255, 80, 20, "shoulder"},
+	{SP, 250, 210, 60, "spur"},
+	{SL, 255, 255, 60, "slope"},
+	{HL, 180, 230, 20, "hollow"},
+	{FS, 60, 250, 150, "footslope"},
+	{VL, 0, 0, 255, "valley"},
+	{PT, 0, 0, 56, "depression"},
+	{__, 255, 0, 255, "ERROR"}
+    };
 
     Rast_init_colors(&colors);