Browse Source

rst/interpfl lib: change devi arg to bool (#1271)

Output deviation argument to IL_init_params_2d() and in the
interp_params struct, was defined as FILE*. In practice a char* of the
file path was given to the function in 'v.surf.rst/main.c' and this
pointer's only use was to check whether it was NULL or not. It was used
as a flag. This changes the argument to be a bool.

Addresses a -Wincompatible-pointer-types compiler warning.
nilason 3 years ago
parent
commit
5e2fd30426

+ 2 - 2
lib/rst/interp_float/init2d.c

@@ -54,7 +54,7 @@ void IL_init_params_2d(struct interp_params *params,
                        double scl,  /*!< anisotropy scaling factor */
                        FILE * t1, FILE * t2, FILE * t3, FILE * t4, FILE * t5,
                        FILE * t6,  /*!< temp files for writing interp. values (t1-t6) */
-                       FILE * dev,  /*!< pointer to deviations file */
+                       bool create_devi,  /*!< create deviations file? */
                        struct TimeStamp *ts,
                        int c,  /*!< cross validation */
                        const char *wheresql     /*!< SQL WHERE statement */
@@ -99,7 +99,7 @@ void IL_init_params_2d(struct interp_params *params,
     params->Tmp_fd_xx = t4;
     params->Tmp_fd_yy = t5;
     params->Tmp_fd_xy = t6;
-    params->fddevi = dev;
+    params->create_devi = create_devi;
     params->ts = ts;
     params->cv = c;
     params->wheresql = wheresql;

+ 2 - 2
lib/rst/interp_float/interpf.h

@@ -92,7 +92,7 @@ struct interp_params
     FILE *Tmp_fd_z, *Tmp_fd_dx,
 	*Tmp_fd_dy, *Tmp_fd_xx,
 	*Tmp_fd_yy, *Tmp_fd_xy;	/**< temp files for writing interp. values */
-    FILE *fddevi;		/**< pointer to deviations file */
+    bool create_devi;		/**< create deviations file? */
 
     grid_calc_fn *grid_calc;	/**< calculates grid for given segm */
     matrix_create_fn *matrix_create;	/**< creates matrix for a given segm */
@@ -118,7 +118,7 @@ void IL_init_params_2d(struct interp_params *, FILE *, int, int, double,
 		       double, int, int, int, int, double,
 		       char *, char *, char *, char *, char *, char *,
 		       double, double, double, int, double, double,
-		       FILE *, FILE *, FILE *, FILE *, FILE *, FILE *, FILE *,
+		       FILE *, FILE *, FILE *, FILE *, FILE *, FILE *, bool,
 		       struct TimeStamp *, int, const char *);
 
 void IL_init_func_2d(struct interp_params *, grid_calc_fn *,

+ 1 - 1
lib/rst/interp_float/point2d.c

@@ -110,7 +110,7 @@ int IL_check_at_points_2d(struct interp_params *params,
 	else
 	    inside = 0;
 
-	if (params->fddevi != NULL) {
+	if (params->create_devi) {
 
 	    if (inside) {	/* if the point is inside the region */
 		Vect_reset_line(Pnts);

+ 1 - 1
raster/r.resamp.rst/main.c

@@ -451,7 +451,7 @@ int main(int argc, char *argv[])
 		      fi, MAXPOINTS, SCIK1, SCIK2, SCIK3, smc, elev, slope,
 		      aspect, pcurv, tcurv, mcurv, dmin, inp_x_orig,
 		      inp_y_orig, deriv, theta, scalex, Tmp_fd_z, Tmp_fd_dx,
-		      Tmp_fd_dy, Tmp_fd_xx, Tmp_fd_yy, Tmp_fd_xy, NULL, NULL,
+		      Tmp_fd_dy, Tmp_fd_xx, Tmp_fd_yy, Tmp_fd_xy, false, NULL,
 		      0, NULL);
 
     /*  In the above line, the penultimate argument is supposed to be a 

+ 3 - 1
vector/v.surf.rst/main.c

@@ -88,6 +88,7 @@ static char *tcurv = NULL;
 static char *mcurv = NULL;
 static char *maskmap = NULL;
 static char *devi = NULL;
+static bool create_devi = false;
 static char *cvdev = NULL;
 static int sdisk, disk, ddisk, sddisk;
 static FILE *Tmp_fd_z = NULL;
@@ -631,6 +632,7 @@ int main(int argc, char *argv[])
 	}
 	db_begin_transaction(driver2);
 	count = 1;
+	create_devi = true;
 
     }
 
@@ -643,7 +645,7 @@ int main(int argc, char *argv[])
 		      SCIK1, SCIK2, SCIK3, rsm, elev, slope, aspect, pcurv,
 		      tcurv, mcurv, dmin, x_orig, y_orig, deriv, theta,
 		      scalex, Tmp_fd_z, Tmp_fd_dx, Tmp_fd_dy, Tmp_fd_xx,
-		      Tmp_fd_yy, Tmp_fd_xy, devi, NULL, cv,
+		      Tmp_fd_yy, Tmp_fd_xy, create_devi, NULL, cv,
 		      parm.wheresql->answer);
 
     IL_init_func_2d(&params, IL_grid_calc_2d, IL_matrix_create,