Prechádzať zdrojové kódy

r.geomorphon: Declutter local_proto.h

Remove unused macros, two variables and a typedef. Move variables that
only main() uses into main(). Move a few typedefs to the only files that
use them. Make a function static and remove declarations for functions
that do not exist.
Denis Ovsienko 4 rokov pred
rodič
commit
f1616d155a

+ 3 - 68
raster/r.geomorphon/local_proto.h

@@ -19,32 +19,10 @@
 #define PI2 (2*atan(1))
 #endif
 
-#ifndef PI4			/* PI/4 */
-#define PI4 (atan(1))
-#endif
-
 #ifndef PI
 #define PI (4*atan(1))
 #endif
 
-#ifndef M2PI			/* 2*PI */
-#define M2PI (8*atan(1))
-#endif
-
-#ifndef GRADE
-#define GRADE (atan(1)/45)
-#endif
-
-
-#ifndef PI2PERCENT
-#define PI2PERCENT (50/atan(1))
-#endif
-
-#ifndef UNKNOWN
-#define UNKNOWN -1
-#endif
-
-
 #define DEGREE2RAD(a) ((a)/(180/PI))
 #define RAD2DEGREE(a) ((a)*(180/PI))
 
@@ -59,8 +37,6 @@
 /* Number of cardinal directions. */
 #define NUM_DIRS 8
 
-typedef char *STRING;
-
 typedef struct
 {
     char elevname[150];
@@ -70,24 +46,6 @@ typedef struct
 } MAPS;
 
 typedef struct
-{				/* struct is used both for interface and output */
-    char *name;
-    int required;
-    char *description;
-    char *gui;
-    RASTER_MAP_TYPE out_data_type;
-    int fd;
-    void *buffer;
-} IO;
-
-typedef struct
-{
-    char name[100];
-    int fd;
-    CELL *forms_buffer;
-} MULTI;
-
-typedef struct
 {
     int num_positives;
     int num_negatives;
@@ -125,33 +83,19 @@ typedef struct
     char *label;
 } CATCOLORS;
 
-typedef struct
-{
-    double cat;
-    int r;
-    int g;
-    int b;
-    char *label;
-} FCOLORS;
-
 /* main */
 GLOBAL MAPS elevation;
-GLOBAL int nrows, ncols, row_radius_size, row_buffer_size;
-GLOBAL int search_cells, skip_cells, step_cells, start_cells;
-GLOBAL int num_of_steps;
-GLOBAL double search_distance, skip_distance, flat_distance;
-GLOBAL double start_distance, step_distance;	/* multiresolution mode */
+GLOBAL int ncols, row_radius_size, row_buffer_size;
+GLOBAL int skip_cells;
+GLOBAL double search_distance, flat_distance;
 GLOBAL double flat_threshold, flat_threshold_height;
-GLOBAL double H, V;
 GLOBAL struct Cell_head window;
 GLOBAL int cell_step;
 GLOBAL unsigned int global_ternary_codes[6562];
 
 /* memory */
 int open_map(MAPS * rast);
-int create_maps(void);
 int shift_buffers(int row);
-int get_cell(int col, float *buf_row, void *buf, RASTER_MAP_TYPE raster_type);
 int free_map(FCELL ** map, int n);
 int write_form_cat_colors(char *raster, CATCOLORS * ccolors);
 int write_contrast_colors(char *);
@@ -173,13 +117,4 @@ int shape(PATTERN * pattern, int pattern_size, float *azimuth,
 	  float *elongation, float *width);
 float extends(PATTERN * pattern, int pattern_size);
 int radial2cartesian(PATTERN *);
-
-/* multires */
-int reset_multi_patterns(void);
-int calc_multi_patterns(int row, int cur_row, int col);
-int update_pattern(int k, int i,
-		   double zenith_height, double zenith_distance,
-		   double zenith_angle, double nadir_height,
-		   double nadir_distance, double nadir_angle);
-
 #endif

+ 26 - 0
raster/r.geomorphon/main.c

@@ -21,12 +21,33 @@
 
 #define MAIN
 #include "local_proto.h"
+
+#define UNKNOWN -1
+
 typedef enum
 { i_dem, o_forms, o_ternary, o_positive, o_negative, o_intensity,
 	o_exposition,
     o_range, o_variance, o_elongation, o_azimuth, o_extend, o_width, io_size
 } outputs;
 
+typedef struct
+{				/* struct is used both for interface and output */
+    char *name;
+    int required;
+    char *description;
+    char *gui;
+    RASTER_MAP_TYPE out_data_type;
+    int fd;
+    void *buffer;
+} IO;
+
+typedef struct
+{
+    char name[100];
+    int fd;
+    CELL *forms_buffer;
+} MULTI;
+
 int main(int argc, char **argv)
 {
     IO rasters[] = {		/* rasters stores output buffers */
@@ -91,7 +112,12 @@ int main(int argc, char **argv)
     int i;
     int meters = 0, multires = 0, extended = 0;	/* flags */
     int row, cur_row, col;
+    int nrows;
     int pattern_size;
+    int search_cells, step_cells, start_cells;
+    int num_of_steps;
+    double start_distance, step_distance;	/* multiresolution mode */
+    double skip_distance;
     double max_resolution;
     char prefix[20];
 

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

@@ -1,5 +1,16 @@
 #include "local_proto.h"
 
+typedef struct
+{
+    double cat;
+    int r;
+    int g;
+    int b;
+    char *label;
+} FCOLORS;
+
+static int get_cell(int, float *, void *, RASTER_MAP_TYPE);
+
 int open_map(MAPS * rast)
 {
 
@@ -35,7 +46,7 @@ int open_map(MAPS * rast)
     return 0;
 }
 
-int get_cell(int col, float *buf_row, void *buf, RASTER_MAP_TYPE raster_type)
+static int get_cell(int col, float *buf_row, void *buf, RASTER_MAP_TYPE raster_type)
 {
 
     switch (raster_type) {