[GRASS-SVN] r71036 - in grass/branches/releasebranch_7_2/vector: v.lidar.correction v.lidar.edgedetection

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 6 02:09:28 PDT 2017


Author: martinl
Date: 2017-05-06 02:09:28 -0700 (Sat, 06 May 2017)
New Revision: 71036

Modified:
   grass/branches/releasebranch_7_2/vector/v.lidar.correction/main.c
   grass/branches/releasebranch_7_2/vector/v.lidar.edgedetection/main.c
Log:
v.lidar.edgedetection+v.lidar.correction: output options not required if -e flag is given
      (merge r70777 from trunk)


Modified: grass/branches/releasebranch_7_2/vector/v.lidar.correction/main.c
===================================================================
--- grass/branches/releasebranch_7_2/vector/v.lidar.correction/main.c	2017-05-06 09:06:25 UTC (rev 71035)
+++ grass/branches/releasebranch_7_2/vector/v.lidar.correction/main.c	2017-05-06 09:09:28 UTC (rev 71036)
@@ -63,6 +63,9 @@
     dbDriver *driver;
 
 /*----------------------------------------------------------------------------------------------------------*/
+
+    G_gisinit(argv[0]);
+
     /* Options' declaration */
     module = G_define_module();
     G_add_keyword(_("vector"));
@@ -72,9 +75,10 @@
 
     spline_step_flag = G_define_flag();
     spline_step_flag->key = 'e';
-    spline_step_flag->label = _("Estimate point density and distance");
+    spline_step_flag->label = _("Estimate point density and distance and quit");
     spline_step_flag->description =
 	_("Estimate point density and distance for the input vector points within the current region extends and quit");
+    spline_step_flag->suppress_required = YES;
 
     in_opt = G_define_standard_option(G_OPT_V_INPUT);
     in_opt->description =
@@ -83,14 +87,10 @@
     out_opt = G_define_standard_option(G_OPT_V_OUTPUT);
     out_opt->description = _("Output classified vector map name");
 
-    out_terrain_opt = G_define_option();
+    out_terrain_opt = G_define_standard_option(G_OPT_V_OUTPUT);
     out_terrain_opt->key = "terrain";
-    out_terrain_opt->type = TYPE_STRING;
-    out_terrain_opt->key_desc = "name";
-    out_terrain_opt->required = YES;
-    out_terrain_opt->gisprompt = "new,vector,vector";
     out_terrain_opt->description =
-	_("Only 'terrain' points output vector map");
+	_("Name for output only 'terrain' points vector map");
 
     stepE_opt = G_define_option();
     stepE_opt->key = "ew_step";
@@ -134,9 +134,10 @@
 	_("Low threshold for terrain to object reclassification");
     Thresh_B_opt->answer = "1";
 
+    G_option_required(out_opt, out_terrain_opt, spline_step_flag, NULL);
+    G_option_requires(spline_step_flag, in_opt, out_opt, out_terrain_opt, NULL);
+
     /* Parsing */
-    G_gisinit(argv[0]);
-
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
@@ -146,6 +147,32 @@
     HighThresh = atof(Thresh_A_opt->answer);
     LowThresh = atof(Thresh_B_opt->answer);
 
+    /* Open input vector */
+    if ((mapset = G_find_vector2(in_opt->answer, "")) == NULL)
+	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
+
+    Vect_set_open_level(1);	/* without topology */
+    if (1 > Vect_open_old(&In, in_opt->answer, mapset))
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
+
+    /* Input vector must be 3D */
+    if (!Vect_is_3d(&In))
+	G_fatal_error(_("Input vector map <%s> is not 3D!"), in_opt->answer);
+
+    /* Estimate point density and mean distance for current region */
+    if (spline_step_flag->answer) {
+	double dens, dist;
+	if (P_estimate_splinestep(&In, &dens, &dist) == 0) {
+	    fprintf(stdout, _("Estimated point density: %.4g\n"), dens);
+	    fprintf(stdout, _("Estimated mean distance between points: %.4g\n"), dist);
+	}
+	else
+	    G_warning(_("No points in current region!"));
+	
+	Vect_close(&In);
+	exit(EXIT_SUCCESS);
+    }
+
     if (!(db = G_getenv_nofatal2("DB_DATABASE", G_VAR_MAPSET)))
 	G_fatal_error(_("Unable to read name of database"));
 
@@ -177,32 +204,6 @@
     Vect_check_input_output_name(in_opt->answer, out_opt->answer,
 				 G_FATAL_EXIT);
 
-    /* Open input vector */
-    if ((mapset = G_find_vector2(in_opt->answer, "")) == NULL)
-	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
-
-    Vect_set_open_level(1);	/* without topology */
-    if (1 > Vect_open_old(&In, in_opt->answer, mapset))
-	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
-
-    /* Input vector must be 3D */
-    if (!Vect_is_3d(&In))
-	G_fatal_error(_("Input vector map <%s> is not 3D!"), in_opt->answer);
-
-    /* Estimate point density and mean distance for current region */
-    if (spline_step_flag->answer) {
-	double dens, dist;
-	if (P_estimate_splinestep(&In, &dens, &dist) == 0) {
-	    G_message("Estimated point density: %.4g", dens);
-	    G_message("Estimated mean distance between points: %.4g", dist);
-	}
-	else
-	    G_warning(_("No points in current region!"));
-	
-	Vect_close(&In);
-	exit(EXIT_SUCCESS);
-    }
-
     /* Open output vector */
     if (0 > Vect_open_new(&Out, out_opt->answer, WITH_Z)) {
 	Vect_close(&In);

Modified: grass/branches/releasebranch_7_2/vector/v.lidar.edgedetection/main.c
===================================================================
--- grass/branches/releasebranch_7_2/vector/v.lidar.edgedetection/main.c	2017-05-06 09:06:25 UTC (rev 71035)
+++ grass/branches/releasebranch_7_2/vector/v.lidar.edgedetection/main.c	2017-05-06 09:09:28 UTC (rev 71036)
@@ -67,6 +67,9 @@
     dbDriver *driver;
 
 /*------------------------------------------------------------------------------------------*/
+
+    G_gisinit(argv[0]);
+
     /* Options' declaration */
     module = G_define_module();
     G_add_keyword(_("vector"));
@@ -77,9 +80,10 @@
 
     spline_step_flag = G_define_flag();
     spline_step_flag->key = 'e';
-    spline_step_flag->label = _("Estimate point density and distance");
+    spline_step_flag->label = _("Estimate point density and distance and quit");
     spline_step_flag->description =
 	_("Estimate point density and distance for the input vector points within the current region extends and quit");
+    spline_step_flag->suppress_required = YES;
 
     in_opt = G_define_standard_option(G_OPT_V_INPUT);
 
@@ -147,9 +151,10 @@
     lambdaF_opt->answer = "2";
     lambdaF_opt->guisection = _("Settings");
 
+    G_option_required(out_opt, spline_step_flag, NULL);
+    G_option_requires(spline_step_flag, in_opt, NULL);
+
     /* Parsing */
-    G_gisinit(argv[0]);
-
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
@@ -165,6 +170,33 @@
     grad_L = grad_L * grad_L;
     grad_H = grad_H * grad_H;
 
+    if ((mapset = G_find_vector2(in_opt->answer, "")) == NULL) {
+	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
+    }
+
+    Vect_set_open_level(1);
+    /* Open input vector */
+    if (1 > Vect_open_old(&In, in_opt->answer, mapset))
+	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
+
+    /* Input vector must be 3D */
+    if (!Vect_is_3d(&In))
+	G_fatal_error(_("Input vector map <%s> is not 3D!"), in_opt->answer);
+
+    /* Estimate point density and mean distance for current region */
+    if (spline_step_flag->answer) {
+	double dens, dist;
+	if (P_estimate_splinestep(&In, &dens, &dist) == 0) {
+            fprintf(stdout, _("Estimated point density: %.4g\n"), dens);
+	    fprintf(stdout, _("Estimated mean distance between points: %.4g\n"), dist);
+	}
+	else
+	    G_warning(_("No points in current region!"));
+	
+	Vect_close(&In);
+	exit(EXIT_SUCCESS);
+    }
+
     if (!(db = G_getenv_nofatal2("DB_DATABASE", G_VAR_MAPSET)))
 	G_fatal_error(_("Unable to read name of database"));
 
@@ -208,34 +240,6 @@
     /* Checking vector names */
     Vect_check_input_output_name(in_opt->answer, out_opt->answer,
 				 G_FATAL_EXIT);
-
-    if ((mapset = G_find_vector2(in_opt->answer, "")) == NULL) {
-	G_fatal_error(_("Vector map <%s> not found"), in_opt->answer);
-    }
-
-    Vect_set_open_level(1);
-    /* Open input vector */
-    if (1 > Vect_open_old(&In, in_opt->answer, mapset))
-	G_fatal_error(_("Unable to open vector map <%s>"), in_opt->answer);
-
-    /* Input vector must be 3D */
-    if (!Vect_is_3d(&In))
-	G_fatal_error(_("Input vector map <%s> is not 3D!"), in_opt->answer);
-
-    /* Estimate point density and mean distance for current region */
-    if (spline_step_flag->answer) {
-	double dens, dist;
-	if (P_estimate_splinestep(&In, &dens, &dist) == 0) {
-	    G_message("Estimated point density: %.4g", dens);
-	    G_message("Estimated mean distance between points: %.4g", dist);
-	}
-	else
-	    G_warning(_("No points in current region!"));
-	
-	Vect_close(&In);
-	exit(EXIT_SUCCESS);
-    }
-
     /* Open output vector */
     if (0 > Vect_open_new(&Out, out_opt->answer, WITH_Z))
 	G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer);



More information about the grass-commit mailing list