[GRASS-SVN] r71231 - in grass/trunk/vector: v.lidar.correction v.lidar.edgedetection v.outlier v.surf.bspline

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jun 26 11:21:16 PDT 2017


Author: mmetz
Date: 2017-06-26 11:21:16 -0700 (Mon, 26 Jun 2017)
New Revision: 71231

Modified:
   grass/trunk/vector/v.lidar.correction/main.c
   grass/trunk/vector/v.lidar.edgedetection/main.c
   grass/trunk/vector/v.outlier/main.c
   grass/trunk/vector/v.surf.bspline/main.c
Log:
lidar vector modules: fix ns_step/ew_step option descriptions, remove shadowed variables, fix G_free() usage

Modified: grass/trunk/vector/v.lidar.correction/main.c
===================================================================
--- grass/trunk/vector/v.lidar.correction/main.c	2017-06-26 18:18:49 UTC (rev 71230)
+++ grass/trunk/vector/v.lidar.correction/main.c	2017-06-26 18:21:16 UTC (rev 71231)
@@ -96,18 +96,18 @@
     stepE_opt->key = "ew_step";
     stepE_opt->type = TYPE_DOUBLE;
     stepE_opt->required = NO;
-    stepE_opt->answer = "25";
-    stepE_opt->description =
-	_("Length of each spline step (pixels) in the east-west direction");
+    stepE_opt->label =
+	_("Length of each spline step in the east-west direction");
+    stepE_opt->description = _("Default: 25 * east-west resolution");
     stepE_opt->guisection = _("Settings");
 
     stepN_opt = G_define_option();
     stepN_opt->key = "ns_step";
     stepN_opt->type = TYPE_DOUBLE;
     stepN_opt->required = NO;
-    stepN_opt->answer = "25";
-    stepN_opt->description =
-	_("Length of each spline step (pixels) in the north-south direction");
+    stepN_opt->label =
+	_("Length of each spline step in the north-south direction");
+    stepN_opt->description = _("Default: 25 * north-south resolution");
     stepN_opt->guisection = _("Settings");
 
     lambda_f_opt = G_define_option();
@@ -141,8 +141,13 @@
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
-    stepN = atof(stepN_opt->answer);
-    stepE = atof(stepE_opt->answer);
+    G_get_set_window(&original_reg);
+    stepN = 25 * original_reg.ns_res;
+    if (stepN_opt->answer)
+	stepN = atof(stepN_opt->answer);
+    stepE = 25 * original_reg.ew_res;
+    if (stepE_opt->answer)
+	stepE = atof(stepE_opt->answer);
     lambda = atof(lambda_f_opt->answer);
     HighThresh = atof(Thresh_A_opt->answer);
     LowThresh = atof(Thresh_B_opt->answer);
@@ -246,7 +251,6 @@
     driver = db_start_driver_open_database(dvr, db);
 
     /* Setting regions and boxes */
-    G_get_set_window(&original_reg);
     G_get_set_window(&elaboration_reg);
     Vect_region_box(&elaboration_reg, &overlap_box);
     Vect_region_box(&elaboration_reg, &general_box);
@@ -369,7 +373,7 @@
 		nparameters = nsplx * nsply;
 
 		/* Mean calculation */
-		G_important_message(_("Performing mean calculation..."));
+		G_verbose_message(_("Performing mean calculation..."));
 		mean = P_Mean_Calc(&elaboration_reg, observ, npoints);
 
 		/*Least Squares system */
@@ -413,7 +417,7 @@
 		G_free_vector(Q);
 		G_free_matrix(obsVect);
 
-		G_important_message( _("Correction and creation of terrain vector..."));
+		G_verbose_message( _("Correction and creation of terrain vector..."));
 		P_Sparse_Correction(&In, &Out, &Terrain, &elaboration_reg,
 				    general_box, overlap_box, obsVect_all, lcat,
 				    parVect, lineVect, stepN, stepE,

Modified: grass/trunk/vector/v.lidar.edgedetection/main.c
===================================================================
--- grass/trunk/vector/v.lidar.edgedetection/main.c	2017-06-26 18:18:49 UTC (rev 71230)
+++ grass/trunk/vector/v.lidar.edgedetection/main.c	2017-06-26 18:21:16 UTC (rev 71231)
@@ -93,18 +93,18 @@
     stepE_opt->key = "ew_step";
     stepE_opt->type = TYPE_DOUBLE;
     stepE_opt->required = NO;
-    stepE_opt->answer = "4";
-    stepE_opt->description =
-	_("Length of each spline step (pixels) in the east-west direction");
+    stepE_opt->label =
+	_("Length of each spline step in the east-west direction");
+    stepE_opt->description = _("Default: 4 * east-west resolution");
     stepE_opt->guisection = _("Settings");
 
     stepN_opt = G_define_option();
     stepN_opt->key = "ns_step";
     stepN_opt->type = TYPE_DOUBLE;
     stepN_opt->required = NO;
-    stepN_opt->answer = "4";
-    stepN_opt->description =
-	_("Length of each spline step (pixels) in the north-south direction");
+    stepN_opt->label =
+	_("Length of each spline step in the north-south direction");
+    stepN_opt->description = _("Default: 4 * north-south resolution");
     stepN_opt->guisection = _("Settings");
 
     lambdaB_opt = G_define_option();
@@ -159,8 +159,14 @@
 	exit(EXIT_FAILURE);
 
     line_out_counter = 1;
-    stepN = atof(stepN_opt->answer);
-    stepE = atof(stepE_opt->answer);
+
+    G_get_set_window(&original_reg);
+    stepN = 4 * original_reg.ns_res;
+    if (stepN_opt->answer)
+	stepN = atof(stepN_opt->answer);
+    stepE = 4 * original_reg.ew_res;
+    if (stepE_opt->answer)
+	stepE = atof(stepE_opt->answer);
     lambda_F = atof(lambdaF_opt->answer);
     lambda_B = atof(lambdaB_opt->answer);
     grad_H = atof(gradH_opt->answer);
@@ -271,7 +277,6 @@
     driver = db_start_driver_open_database(dvr, db);
 
     /* Setting regions and boxes */
-    G_get_set_window(&original_reg);
     G_get_set_window(&elaboration_reg);
     Vect_region_box(&elaboration_reg, &overlap_box);
     Vect_region_box(&elaboration_reg, &general_box);
@@ -415,7 +420,7 @@
 
 		G_free(observ);
 
-		G_important_message(_("Performing bilinear interpolation..."));
+		G_verbose_message(_("Performing bilinear interpolation..."));
 		normalDefBilin(N, TN, Q, obsVect, stepE, stepN, nsplx,
 			       nsply, elaboration_reg.west,
 			       elaboration_reg.south, npoints, nparameters,
@@ -432,7 +437,7 @@
 		N = G_alloc_matrix(nparameters, BW);	/* Normal matrix */
 		parVect_bicub = G_alloc_vector(nparameters);	/* Bicubic parameters vector */
 
-		G_important_message(_("Performing bicubic interpolation..."));
+		G_verbose_message(_("Performing bicubic interpolation..."));
 		normalDefBicubic(N, TN, Q, obsVect, stepE, stepN, nsplx,
 				 nsply, elaboration_reg.west,
 				 elaboration_reg.south, npoints, nparameters,
@@ -444,7 +449,7 @@
 		G_free_vector(TN);
 		G_free_vector(Q);
 
-		G_important_message(_("Point classification..."));
+		G_verbose_message(_("Point classification..."));
 		classification(&Out, elaboration_reg, general_box,
 			       overlap_box, obsVect, parVect_bilin,
 			       parVect_bicub, mean, alpha, grad_H, grad_L,

Modified: grass/trunk/vector/v.outlier/main.c
===================================================================
--- grass/trunk/vector/v.outlier/main.c	2017-06-26 18:18:49 UTC (rev 71230)
+++ grass/trunk/vector/v.outlier/main.c	2017-06-26 18:21:16 UTC (rev 71231)
@@ -98,18 +98,18 @@
     stepE_opt->key = "ew_step";
     stepE_opt->type = TYPE_DOUBLE;
     stepE_opt->required = NO;
-    stepE_opt->answer = "10";
-    stepE_opt->description =
-	_("Length of each spline step (pixels) in the east-west direction");
+    stepE_opt->label =
+	_("Length of each spline step in the east-west direction");
+    stepE_opt->description = _("Default: 10 * east-west resolution");
     stepE_opt->guisection = _("Settings");
 
     stepN_opt = G_define_option();
     stepN_opt->key = "ns_step";
     stepN_opt->type = TYPE_DOUBLE;
     stepN_opt->required = NO;
-    stepN_opt->answer = "10";
-    stepN_opt->description =
-	_("Length of each spline step (pixels) in the north-south direction");
+    stepN_opt->label =
+	_("Length of each spline step in the north-south direction");
+    stepN_opt->description = _("Default: 10 * north-south resolution");
     stepN_opt->guisection = _("Settings");
 
     lambda_f_opt = G_define_option();
@@ -148,8 +148,13 @@
     if (!(dvr = G_getenv_nofatal2("DB_DRIVER", G_VAR_MAPSET)))
 	G_fatal_error(_("Unable to read name of driver"));
 
-    stepN = atof(stepN_opt->answer);
-    stepE = atof(stepE_opt->answer);
+    G_get_set_window(&original_reg);
+    stepN = 10 * original_reg.ns_res;
+    if (stepN_opt->answer)
+	stepN = atof(stepN_opt->answer);
+    stepE = 10 * original_reg.ew_res;
+    if (stepE_opt->answer)
+	stepE = atof(stepE_opt->answer);
     lambda = atof(lambda_f_opt->answer);
     Thres_Outlier = atof(Thres_O_opt->answer);
 
@@ -268,7 +273,6 @@
     driver = db_start_driver_open_database(dvr, db);
 
     /* Setting regions and boxes */
-    G_get_set_window(&original_reg);
     G_get_set_window(&elaboration_reg);
     Vect_region_box(&elaboration_reg, &overlap_box);
     Vect_region_box(&elaboration_reg, &general_box);
@@ -351,8 +355,6 @@
 	    subregion++;
 	    if (nsubregions > 1)
 		G_message(_("Processing subregion %d of %d..."), subregion, nsubregions);
-	    else /* v.outlier -e will report mean point distance: */
-		G_warning(_("No subregions found! Check values for 'ew_step' and 'ns_step' parameters"));
 
 	    P_set_regions(&elaboration_reg, &general_box, &overlap_box, dims,
 			  GENERAL_COLUMN);

Modified: grass/trunk/vector/v.surf.bspline/main.c
===================================================================
--- grass/trunk/vector/v.surf.bspline/main.c	2017-06-26 18:18:49 UTC (rev 71230)
+++ grass/trunk/vector/v.surf.bspline/main.c	2017-06-26 18:21:16 UTC (rev 71231)
@@ -144,18 +144,18 @@
     stepE_opt->key = "ew_step";
     stepE_opt->type = TYPE_DOUBLE;
     stepE_opt->required = NO;
-    stepE_opt->answer = "4";
-    stepE_opt->description =
-	_("Length of each spline step (pixels) in the east-west direction");
+    stepE_opt->label =
+	_("Length of each spline step in the east-west direction");
+    stepE_opt->description = _("Default: 4 * east-west resolution");
     stepE_opt->guisection = _("Settings");
 
     stepN_opt = G_define_option();
     stepN_opt->key = "ns_step";
     stepN_opt->type = TYPE_DOUBLE;
     stepN_opt->required = NO;
-    stepN_opt->answer = "4";
-    stepN_opt->description =
-	_("Length of each spline step (pixels) in the north-south direction");
+    stepN_opt->label =
+	_("Length of each spline step in the north-south direction");
+    stepN_opt->description = _("Default: 4 * north-south resolution");
     stepN_opt->guisection = _("Settings");
 
     type_opt = G_define_option();
@@ -214,8 +214,13 @@
     else
 	bilin = P_BICUBIC;
 
-    stepN = atof(stepN_opt->answer);
-    stepE = atof(stepE_opt->answer);
+    G_get_set_window(&original_reg);
+    stepN = 4 * original_reg.ns_res;
+    if (stepN_opt->answer)
+	stepN = atof(stepN_opt->answer);
+    stepE = 4 * original_reg.ew_res;
+    if (stepE_opt->answer)
+	stepE = atof(stepE_opt->answer);
     lambda = atof(lambda_f_opt->answer);
 
     flag_auxiliar = FALSE;
@@ -435,7 +440,6 @@
 
     /* Setting regions and boxes */
     G_debug(1, "Interpolation: Setting regions and boxes");
-    G_get_window(&original_reg);
     G_get_window(&elaboration_reg);
     Vect_region_box(&original_reg, &original_box);
     Vect_region_box(&elaboration_reg, &overlap_box);
@@ -487,8 +491,8 @@
 	G_percent(row, nrows, 2);
 
 	if (mask_opt->answer) {
-	    int row, col, maskfd;
-	    DCELL dval, *drastbuf;
+	    int col, maskfd;
+	    DCELL dval;
 	    char mask_val;
 	    
 	    G_message(_("Load masking map"));
@@ -504,7 +508,6 @@
 		G_fatal_error(_("Can not initialize temporary file"));
 
 	    maskfd = Rast_open_old(mask_opt->answer, "");
-	    drastbuf = Rast_allocate_buf(DCELL_TYPE);
 
 	    for (row = 0; row < nrows; row++) {
 		G_percent(row, nrows, 2);
@@ -521,11 +524,11 @@
 	    }
 
 	    G_percent(row, nrows, 2);
-	    G_free(drastbuf);
 	    Rast_close(maskfd);
 	    
 	    have_mask = 1;
 	}
+	G_free(drastbuf);
     }
 
     /*------------------------------------------------------------------



More information about the grass-commit mailing list