[GRASS-SVN] r54539 - grass/trunk/raster/r.drain

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jan 5 12:25:28 PST 2013


Author: martinl
Date: 2013-01-05 12:25:27 -0800 (Sat, 05 Jan 2013)
New Revision: 54539

Modified:
   grass/trunk/raster/r.drain/filldir.c
   grass/trunk/raster/r.drain/main.c
   grass/trunk/raster/r.drain/r.drain.html
Log:
r.drain: sync with r.walk, r.cost
         voutput renamed to vector_output
         coordinate renamed to start_coordinates
         vector_points renamed to start_points


Modified: grass/trunk/raster/r.drain/filldir.c
===================================================================
--- grass/trunk/raster/r.drain/filldir.c	2013-01-05 20:05:36 UTC (rev 54538)
+++ grass/trunk/raster/r.drain/filldir.c	2013-01-05 20:25:27 UTC (rev 54539)
@@ -112,11 +112,13 @@
     lseek(fe, 0, SEEK_SET);
     lseek(fd, 0, SEEK_SET);
     advance_band3(fe, bnd);
-    for (i = 0; i < nl; i += 1) {
+    for (i = 0; i < nl; i++) {
+        G_percent(i, nl, 5);
 	advance_band3(fe, bnd);
 	build_one_row(i, nl, bnd->ns, bnd, dir, m[i]);
 	write(fd, dir, bufsz);
     }
+    G_percent(1, 1, 1);
     advance_band3(fe, bnd);
     build_one_row(i, nl, bnd->ns, bnd, dir, m[i]);
     write(fd, dir, bufsz);

Modified: grass/trunk/raster/r.drain/main.c
===================================================================
--- grass/trunk/raster/r.drain/main.c	2013-01-05 20:05:36 UTC (rev 54538)
+++ grass/trunk/raster/r.drain/main.c	2013-01-05 20:25:27 UTC (rev 54539)
@@ -78,9 +78,9 @@
     struct Option *opt1, *opt2, *coordopt, *vpointopt, *opt3, *opt4;
     struct Flag *flag1, *flag2, *flag3, *flag4;
     struct GModule *module;
-    int in_type, dir_data_type;
+    int in_type;
     void *in_buf;
-	void *dir_buf;
+    void *dir_buf;
     CELL *out_buf;
     struct band3 bnd, bndC;
     struct metrics *m = NULL;
@@ -112,36 +112,29 @@
     opt1 = G_define_standard_option(G_OPT_R_ELEV);
     opt1->key = "input";
     
-    opt3 = G_define_option();
+    opt3 = G_define_standard_option(G_OPT_R_INPUT);
     opt3->key = "indir";
-    opt3->type = TYPE_STRING;
-    opt3->gisprompt = "old,cell,raster";
     opt3->description =
-	_("Name of movement direction map associated with the cost surface");
+	_("Name of input movement direction map associated with the cost surface");
     opt3->required = NO;
+    
     opt2 = G_define_standard_option(G_OPT_R_OUTPUT);
     
-    opt4 = G_define_option();
-    opt4->key = "voutput";
-    opt4->type = TYPE_STRING;
-    opt4->gisprompt = "new,vector,vector";
+    opt4 = G_define_standard_option(G_OPT_V_OUTPUT);
+    opt4->key = "vector_output";
     opt4->required = NO;
     opt4->description =
-	_("Output drain vector map (recommended for cost surface made using knight's move)");
+	_("Name for output drain vector map (recommended for cost surface made using knight's move)");
     
-    coordopt = G_define_option();
-    coordopt->key = "coordinate";
-    coordopt->type = TYPE_STRING;
-    coordopt->required = NO;
-    coordopt->multiple = YES;
-    coordopt->key_desc = "x,y";
-    coordopt->description = _("Map coordinates of starting point(s) (E,N)");
+    coordopt = G_define_standard_option(G_OPT_M_COORDS);
+    coordopt->key = "start_coordinates";
+    coordopt->description = _("Coordinates of starting point(s) (E,N)");
     coordopt->guisection = _("Start");
 
     vpointopt = G_define_standard_option(G_OPT_V_INPUTS);
-    vpointopt->key = "vector_points";
+    vpointopt->key = "start_points";
     vpointopt->required = NO;
-    vpointopt->description = _("Name of vector map(s) containing starting point(s)");
+    vpointopt->label = _("Name of starting vector points map(s)");
     vpointopt->guisection = _("Start");
 
     flag1 = G_define_flag();
@@ -170,36 +163,29 @@
 
     if (flag4->answer) {
 	costmode = 1;
-	G_message(_
-		  ("Directional drain selected... checking for direction raster"));
+	G_verbose_message(_("Directional drain selected... checking for direction raster"));
     }
     else {
-	G_message(_("Surface/Hydrology drain selected"));
+	G_verbose_message(_("Surface/Hydrology drain selected"));
     }
 
     if (costmode == 1) {
 	if (!opt3->answer) {
-	    G_fatal_error(_
-			  ("Direction raster not specified, if direction flag is on, a direction raster must be given"));
+	    G_fatal_error(_("Direction raster not specified, if direction flag is on, "
+                            "a direction raster must be given"));
 	}
 	strcpy(dir_name, opt3->answer);
-	dir_data_type = Rast_map_type(dir_name, "");
     }
     if (costmode == 0) {
 	if (opt3->answer) {
-	    G_fatal_error(_
-			  ("Direction map <%s> should not be specified for Surface/Hydrology drains"),
+	    G_fatal_error(_("Direction map <%s> should not be specified for Surface/Hydrology drains"),
 			  opt3->answer);
 	}
     }
 
     if (opt4->answer) {
-	G_message(_("Outputting a vector path"));
-	if (G_legal_filename(opt4->answer) < 0)
-	    G_fatal_error(_("<%s> is an illegal file name"), opt4->answer);
-	/*G_ask_vector_new("",vect); */
 	if (0 > Vect_open_new(&vout, opt4->answer, 0)) {
-	    G_fatal_error(_("Unable to create vector map <%s>"),
+            G_fatal_error(_("Unable to create vector map <%s>"),
 			  opt4->answer);
 	}
 	Vect_hist_command(&vout);
@@ -390,7 +376,7 @@
 
     /* only necessary for non-dir drain */
     if (costmode == 0) {
-	G_verbose_message(_("Calculating flow directions..."));
+	G_message(_("Calculating flow directions..."));
 
 	/* fill one-cell pits and take a first stab at flow directions */
 	filldir(fe, fd, nrows, &bnd, m);
@@ -459,8 +445,7 @@
 	}
 
 	/* build the output map */
-	G_message(_("Writing raster map <%s>..."),
-		  new_map_name);
+	G_message(_("Writing output raster map..."));
 	for (i = 0; i < nrows; i++) {
 	    G_percent(i, nrows, 2);
 	    Rast_set_c_null_value(out_buf, ncols);
@@ -585,7 +570,6 @@
 	unlink(tempfile3);
 	G_free(dir_buf);
     }
-    G_done_msg(" ");
     
     exit(EXIT_SUCCESS);
 }

Modified: grass/trunk/raster/r.drain/r.drain.html
===================================================================
--- grass/trunk/raster/r.drain/r.drain.html	2013-01-05 20:05:36 UTC (rev 54538)
+++ grass/trunk/raster/r.drain/r.drain.html	2013-01-05 20:25:27 UTC (rev 54539)
@@ -9,14 +9,14 @@
 <em><a href="r.slope.aspect.html">r.slope.aspect</a></em> or 
 <em><a href="r.watershed.html">r.watershed</a></em>.
 
-The <b>output</b> result (also a raster map layer) will show one or more 
-least-cost paths between each user-provided location(s) and the minima 
-(low category values) in the <b>input</b> map. If the -d flag is used the 
-output least-cost paths will be found using the direction layer.
-By default, the <b>output</b> will be an integer CELL map with <tt>1</tt> 
+The <b>output</b> raster map will show one or more least-cost paths
+between each user-provided location(s) and the minima (low category
+values) in the raster <b>input</b> map. If the -d flag is used the output
+least-cost paths will be found using the direction raster map.  By
+default, the <b>output</b> will be an integer CELL map with <tt>1</tt>
 along the least cost path, and null cells elsewhere.
 
-<p>With the <b>-c</b> (<em>copy</em>) flag, the input map cell values are
+<p>With the <b>-c</b> (<em>copy</em>) flag, the input raster map cell values are
 copied verbatim along the path. With the <b>-a</b> (<em>accumulate</em>)
 flag, the accumulated cell value from the starting point up to the current
 cell is written on output. With either the <b>-c</b> or the <b>-a</b> flags, the
@@ -26,34 +26,39 @@
 starting point to the final point.
 The <b>-c</b>, <b>-a</b>, and <b>-n</b> flags are mutually incompatible.
 
-<p>For an elevation surface, the path is calculated by choosing the steeper 
-"slope" between adjacent cells. The slope calculation accurately acounts 
-for the variable scale in lat-lon projections. For a cost surface, the path
-is calculated by following the movement direction surface back to the start 
-point given in <em>r.walk</em> or <em>r.cost</em>. The path search stops 
+<p>For an elevation surface, the path is calculated by choosing the
+steeper "slope" between adjacent cells. The slope calculation
+accurately acounts for the variable scale in lat-lon projections. For
+a cost surface, the path is calculated by following the movement
+direction surface back to the start point given
+in <em><a href="r.walk.html">r.walk</a></em> or
+<em><a href="r.cost.html">r.cost</a></em>. The path search stops 
 as soon as a region border or a neighboring NULL cell is encountered, 
 because in these cases the direction can not be determined (the path 
 could continue outside the current region).
 
-<p>The <b>coordinate</b> parameter consists of map E and N grid coordinates of
+<p>The <b>start_coordinates</b> parameter consists of map E and N grid coordinates of
 a starting point. Each x,y pair is the easting and northing (respectively) of
 a starting point from which a least-cost corridor will be developed.
-The <b>vector_points</b> parameter can take multiple vector maps containing 
+The <b>start_points</b> parameter can take multiple vector maps containing 
 additional starting points.
 Up to 1024 starting points can be input from a combination of the
-<b>coordinate</b> and <b>vector_points</b> parameters.
+<b>start_coordinates</b> and <b>start_points</b> parameters.
 
 <h2>NOTES</h2>
 
-If no direction input map is given, <em>r.drain</em> currently finds 
-only the lowest point (the cell having the smallest category value) in 
-the input file that can be reached through directly adjacent cells 
-that are less than or equal in value to the cell reached immediately 
-prior to it; therefore, it will not necessarily reach the lowest point 
-in the input file. It currently finds <em>pits</em> in the data, rather 
-than the lowest point in the entire input map. The <em>r.fill.dir</em>,
-<em>r.terraflow</em>, and <em>r.basins.fill</em> modules can be used to
-fill in subbasins prior to processing with <em>r.drain</em>.
+If no direction input map is given, <em>r.drain</em> currently finds
+only the lowest point (the cell having the smallest category value) in
+the input file that can be reached through directly adjacent cells
+that are less than or equal in value to the cell reached immediately
+prior to it; therefore, it will not necessarily reach the lowest point
+in the input file. It currently finds <em>pits</em> in the data,
+rather than the lowest point in the entire input
+map. The <em><a href="r.fill.dir.html">r.fill.dir</a></em>,
+<em><a href="r.terraflow.html">r.terraflow</a></em>,
+and <em><a href="r.basins.fill.html">r.basins.fill</a></em> modules
+can be used to fill in subbasins prior to processing
+with <em>r.drain</em>.
 
 <p>
 <em>r.drain</em> will not give sane results at the region boundary. On outer rows
@@ -194,19 +199,22 @@
 
 <h2>SEE ALSO</h2>
 
-<em><a href="g.region.html">g.region</a></em>,
-<em><a href="r.cost.html">r.cost</a></em>,
-<em><a href="r.fill.dir.html">r.fill.dir</a></em>,
-<em><a href="r.basins.fill.html">r.basins.fill</a></em>,
-<em><a href="r.terraflow.html">r.terraflow</a></em>,
-<em><a href="r.mapcalc.html">r.mapcalc</a></em>,
-<em><a href="r.walk.html">r.walk</a></em>
+<em>
+<a href="g.region.html">g.region</a>,
+<a href="r.cost.html">r.cost</a>,
+<a href="r.fill.dir.html">r.fill.dir</a>,
+<a href="r.basins.fill.html">r.basins.fill</a>,
+<a href="r.terraflow.html">r.terraflow</a>,
+<a href="r.mapcalc.html">r.mapcalc</a>,
+<a href="r.walk.html">r.walk</a>
+</em>
 
-<h2>AUTHOR</h2>
+<h2>AUTHORS</h2>
 
-Completely rewritten by Roger S. Miller, 2001
-<p>July 2004 at WebValley 2004, error checking and vector points added by
+Completely rewritten by Roger S. Miller, 2001<br>
+July 2004 at WebValley 2004, error checking and vector points added by
 Matteo Franchi (Liceo Leonardo Da Vinci, Trento) and
 Roberto Flor (ITC-irst, Trento, Italy)
 
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>



More information about the grass-commit mailing list