[GRASS-SVN] r74452 - grass/trunk/raster/r.watershed/front

svn_grass at osgeo.org svn_grass at osgeo.org
Thu May 2 03:33:48 PDT 2019


Author: martinl
Date: 2019-05-02 03:33:48 -0700 (Thu, 02 May 2019)
New Revision: 74452

Modified:
   grass/trunk/raster/r.watershed/front/main.c
Log:
r.watershed usage inconsistency, see #3839


Modified: grass/trunk/raster/r.watershed/front/main.c
===================================================================
--- grass/trunk/raster/r.watershed/front/main.c	2019-05-02 09:16:18 UTC (rev 74451)
+++ grass/trunk/raster/r.watershed/front/main.c	2019-05-02 10:33:48 UTC (rev 74452)
@@ -41,7 +41,7 @@
 int main(int argc, char *argv[])
 {
     char command[GPATH_MAX];
-    int err, ret;
+    int ret;
     struct Option *opt1;
     struct Option *opt2;
     struct Option *opt3;
@@ -155,7 +155,7 @@
 
     opt18 = G_define_standard_option(G_OPT_R_OUTPUT);
     opt18->key = "spi";
-    opt18->label = _("Stream power index a * tan(b)");
+    opt18->label = _("Name for output stream power index a * tan(b)");
     opt18->required = NO;
     opt18->guisection = _("Outputs");
 
@@ -245,23 +245,19 @@
     flag_flat->description =
 	_("Flow direction in flat areas is modified to look prettier");
 
+    /* Some options requires threshold */
+    G_option_requires(opt10, opt6, NULL);
+    G_option_requires(opt11, opt6, NULL);
+    G_option_requires(opt12, opt6, NULL);
+    G_option_requires(opt13, opt6, NULL);
+    G_option_requires(opt14, opt6, NULL);
+
+    /* Check for some output map */
+    G_option_required(opt8, opt17, opt18, opt9, opt10, opt11, opt12, opt13, opt14, NULL);
+      
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
-
-    /* Check option combinations */
-
-    /* Check for some output map */
-    if ((opt8->answer == NULL)
-	&& (opt9->answer == NULL)
-	&& (opt10->answer == NULL)
-	&& (opt11->answer == NULL)
-	&& (opt12->answer == NULL)
-	&& (opt14->answer == NULL)
-	&& (opt15->answer == NULL)) {
-	G_fatal_error(_("Sorry, you must choose an output map."));
-    }
-
     /* basin threshold */
     if (opt6->answer) {
 	if (atoi(opt6->answer) <= 0)
@@ -268,27 +264,6 @@
 	    G_fatal_error(_("The basin threshold must be a positive number."));
     }
 
-    err = 0;
-    /* basin and basin threshold */
-    err += (opt10->answer != NULL && opt6->answer == NULL);
-    /* stream and basin threshold */
-    err += (opt11->answer != NULL && opt6->answer == NULL);
-    /* half_basin and basin threshold */
-    err += (opt12->answer != NULL && opt6->answer == NULL);
-    /* LS factor and basin threshold */
-    err += (opt13->answer != NULL && opt6->answer == NULL);
-    /* S factor and basin threshold */
-    err += (opt14->answer != NULL && opt6->answer == NULL);
-
-    if (err) {
-	G_message(_("Sorry, if any of the following options are set:\n"
-		    "    basin, stream, half_basin, length_slope, or slope_steepness\n"
-		    "    you MUST provide a value for the basin "
-		    "threshold parameter."));
-	G_usage();
-	exit(EXIT_FAILURE);
-    }
-
     /* Build command line */
     sprintf(command, "%s/etc/r.watershed/%s",
 	    G_gisbase(), flag_seg->answer ? "seg" : "ram");



More information about the grass-commit mailing list