Browse Source

r.terraflow: module description simplification
module updates
fix some warnings


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@70532 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 8 years ago
parent
commit
067afcf8a3

+ 1 - 1
raster/r.terraflow/flow.cpp

@@ -220,7 +220,7 @@ fillstr2sweepstr(AMI_STREAM<waterWindowBaseType>* fillStream) {
 
 
   G_debug(1, "sweep stream size: %.2fMB",
   G_debug(1, "sweep stream size: %.2fMB",
           (double)sweepstr->stream_len()*sizeof(sweepItem)/(1<<20));
           (double)sweepstr->stream_len()*sizeof(sweepItem)/(1<<20));
-  G_debug(1, " (%d items, item size=%d B\n ", 
+  G_debug(1, " (%d items, item size=%ld B\n ", 
           (int)sweepstr->stream_len(), sizeof(sweepItem));;
           (int)sweepstr->stream_len(), sizeof(sweepItem));;
 
 
   if (stats)
   if (stats)

+ 7 - 14
raster/r.terraflow/main.cpp

@@ -134,7 +134,7 @@ parse_args(int argc, char *argv[]) {
   mem->key         = "memory";
   mem->key         = "memory";
   mem->type        = TYPE_INTEGER;
   mem->type        = TYPE_INTEGER;
   mem->required    = NO;
   mem->required    = NO;
-  mem->answer      = "300";
+  mem->answer      = (char *) "300";
   mem->description = _("Maximum memory to be used (in MB)");
   mem->description = _("Maximum memory to be used (in MB)");
 
 
   /* temporary STREAM path */
   /* temporary STREAM path */
@@ -153,7 +153,7 @@ parse_args(int argc, char *argv[]) {
   stats_opt->key        = "stats";
   stats_opt->key        = "stats";
   stats_opt->type       = TYPE_STRING;
   stats_opt->type       = TYPE_STRING;
   stats_opt->required   = NO;
   stats_opt->required   = NO;
-  stats_opt->description= _("Name of file containing runtime statistics");
+  stats_opt->description= _("Name for output file containing runtime statistics");
   stats_opt->guisection = _("Outputs");
   stats_opt->guisection = _("Outputs");
   
   
   G_option_requires(input_elev, output_elev, output_dir, output_watershed,
   G_option_requires(input_elev, output_elev, output_dir, output_watershed,
@@ -240,8 +240,8 @@ void check_header(char* cellname) {
 	}
 	}
 #endif 
 #endif 
 #ifdef ELEV_FLOAT
 #ifdef ELEV_FLOAT
-	G_verbose_message( _("Elevation stored as FLOAT (%dB)"), 
-			sizeof(elevation_type));
+	G_verbose_message(_("Elevation stored as FLOAT (%ldB)"), 
+                          sizeof(elevation_type));
 	if (data_type == CELL_TYPE) {
 	if (data_type == CELL_TYPE) {
 	  G_warning(_("Raster map <%s> is of type CELL_TYPE "
 	  G_warning(_("Raster map <%s> is of type CELL_TYPE "
                       "-- you should use r.terraflow.short"), opt->elev_grid); 
                       "-- you should use r.terraflow.short"), opt->elev_grid); 
@@ -421,10 +421,10 @@ printMaxSortSize(long nodata_count) {
   G_debug(1, "total elements=%ld, nodata elements=%ld",
   G_debug(1, "total elements=%ld, nodata elements=%ld",
           (long)nrows * ncols, nodata_count);
           (long)nrows * ncols, nodata_count);
   G_debug(1, "largest temporary files: ");
   G_debug(1, "largest temporary files: ");
-  G_debug(1, "\t\t FILL: %s [%ld elements, %dB each]",
+  G_debug(1, "\t\t FILL: %s [%ld elements, %ldB each]",
           formatNumber(buf, fillmaxsize),
           formatNumber(buf, fillmaxsize),
           (long)nrows * ncols, sizeof(waterWindowType));
           (long)nrows * ncols, sizeof(waterWindowType));
-  G_debug(1, "\t\t FLOW: %s [%ld elements, %dB each]",
+  G_debug(1, "\t\t FLOW: %s [%ld elements, %ldB each]",
           formatNumber(buf, flowmaxsize),
           formatNumber(buf, flowmaxsize),
           (long)nrows * ncols - nodata_count, sizeof(sweepItem));
           (long)nrows * ncols - nodata_count, sizeof(sweepItem));
   G_debug(1, "Will need at least %s space available in %s",
   G_debug(1, "Will need at least %s space available in %s",
@@ -461,14 +461,7 @@ main(int argc, char *argv[]) {
 
 
  
  
   module = G_define_module();
   module = G_define_module();
-#ifdef ELEV_SHORT
-  module->label = _("Performs flow computation for massive grids.");
-  module->description = _("Integer version.");
-#endif
-#ifdef ELEV_FLOAT
-  module->label = _("Performs flow computation for massive grids.");
-  module->description = _("Float version.");
-#endif
+  module->description = _("Performs flow computation for massive grids.");
   G_add_keyword(_("raster"));
   G_add_keyword(_("raster"));
   G_add_keyword(_("hydrology"));
   G_add_keyword(_("hydrology"));
   G_add_keyword(_("flow"));
   G_add_keyword(_("flow"));

+ 34 - 41
raster/r.terraflow/r.terraflow.html

@@ -72,11 +72,11 @@ each cell.
 <b>d8cut</b> option, then
 <b>d8cut</b> option, then
 the flow of this cell is routed to its neighbors using the SFD (D8)
 the flow of this cell is routed to its neighbors using the SFD (D8)
 model. This option affects only the flow accumulation raster and is
 model. This option affects only the flow accumulation raster and is
-meaningful only for MFD flow (i.e. if the -s flag is not used); If
+meaningful only for MFD flow (i.e. if the <b>-s</b> flag is not used); If
 this option is used for SFD flow it is ignored. The default value of
 this option is used for SFD flow it is ignored. The default value of
 <b>d8cut</b> is <i>infinity</i>.
 <b>d8cut</b> is <i>infinity</i>.
 
 
-<p><em>r.terraflow</em> also computes the tci raster (topographic convergence
+<p><em>r.terraflow</em> also computes the <b>tci</b> raster (topographic convergence
 index, defined as the logarithm of the ratio of flow accumulation and
 index, defined as the logarithm of the ratio of flow accumulation and
 local slope).
 local slope).
 
 
@@ -96,7 +96,7 @@ columns) in the elevation raster (more precisely, 80K bytes, where K
 is the number of valid (not no-data) cells in the input elevation
 is the number of valid (not no-data) cells in the input elevation
 raster).
 raster).
 <p>All these intermediate temporary files are stored in the path specified
 <p>All these intermediate temporary files are stored in the path specified
-by the <b>STREAM_DIR</b> option. Note: <b>STREAM_DIR</b> must contain
+by the <b>directory</b> option. Note: <b>directory</b> must contain
 enough free disk space in order to store up to 2 x 80N bytes.
 enough free disk space in order to store up to 2 x 80N bytes.
 
 
 <p>The <b>memory</b> option can be used to set the maximum amount of main
 <p>The <b>memory</b> option can be used to set the maximum amount of main
@@ -118,8 +118,7 @@ compiled to store elevations internally as floats. Other versions can be
 created by the user if needed.
 created by the user if needed.
 
 
 <p>Hints concerning compilation with storage of elevations internally as
 <p>Hints concerning compilation with storage of elevations internally as
-shorts:
-<br>such a version uses less space (up to 60B per cell, up
+shorts: such a version uses less space (up to 60B per cell, up
 to 60N intermediate file) and therefore is more space and time
 to 60N intermediate file) and therefore is more space and time
 efficient. <em>r.terraflow</em> is intended for use with floating
 efficient. <em>r.terraflow</em> is intended for use with floating
 point raster data (FCELL), and <em>r.terraflow (short)</em> with integer
 point raster data (FCELL), and <em>r.terraflow (short)</em> with integer
@@ -147,12 +146,10 @@ identical for integer raster data (CELL maps).
 
 
 <h2>EXAMPLES</h2>
 <h2>EXAMPLES</h2>
 
 
-Example for small area in North Carolina sample dataset:
+Example for small area in North Carolina sample dataset to calculate flow accumulation:
 <div class="code"><pre>
 <div class="code"><pre>
 g.region raster=elev_lid792_1m
 g.region raster=elev_lid792_1m
-r.terraflow elevation=elev_lid792_1m filled=elev_lid792_1m_filled \
-    direction=elev_lid792_1m_direction swatershed=elev_lid792_1m_swatershed \
-    accumulation=elev_lid792_1m_accumulation tci=elev_lid792_1m_tci
+r.terraflow elevation=elev_lid792_1m accumulation=elev_lid792_1m_accumulation
 </pre></div>
 </pre></div>
 
 
 <div align="center" style="margin: 10px">
 <div align="center" style="margin: 10px">
@@ -189,6 +186,34 @@ r.terraflow elev=elevation.10m filled=elevation10m.filled \
 </pre></div>
 </pre></div>
 
 
 
 
+<h2>REFERENCES</h2>
+
+<ol>
+  <li> The <a href="http://www.cs.duke.edu/geo*/terraflow/">TerraFlow</a> project at Duke University
+  <li><A NAME="arge:drainage"
+       HREF="http://www.cs.duke.edu/geo*/terraflow/papers/alenex00_drainage.ps.gz">
+       I/O-efficient algorithms for problems on grid-based
+       terrains</a>.  Lars Arge, Laura Toma, and Jeffrey S. Vitter. In
+       <em>Proc. Workshop on Algorithm Engineering and Experimentation</em>,
+       2000. To appear in <em>Journal of Experimental Algorithms</em>.
+       
+  <li><A NAME="terraflow:acmgis01"
+       HREF="http://www.cs.duke.edu/geo*/terraflow/papers/acmgis01_terraflow.pdf">
+       Flow computation on massive grids</a>.
+       Lars Arge, Jeffrey S. Chase, Patrick N. Halpin, Laura Toma,
+       Jeffrey S. Vitter, Dean Urban and Rajiv Wickremesinghe. In
+       <em>Proc. ACM Symposium on Advances in Geographic Information
+       Systems</em>, 2001.
+       
+  <li><A NAME="terraflow:geoinformatica"
+       HREF="http://www.cs.duke.edu/geo*/terraflow/papers/journal_terraflow.pdf">
+       Flow computation on massive grid terrains</a>.
+       Lars Arge, Jeffrey S. Chase, Patrick N. Halpin, Laura Toma,
+       Jeffrey S. Vitter, Dean Urban and Rajiv Wickremesinghe.
+       In <em>GeoInformatica, International Journal on
+       Advances of Computer Science for Geographic Information
+       Systems</em>, 7(4):283-313, December 2003.
+</ol>
 
 
 <h2>SEE ALSO</h2>
 <h2>SEE ALSO</h2>
 
 
@@ -202,8 +227,6 @@ r.terraflow elev=elevation.10m filled=elevation10m.filled \
 <a href="r.watershed.html">r.watershed</a>
 <a href="r.watershed.html">r.watershed</a>
 </em>
 </em>
 
 
-
-
 <h2>AUTHORS</h2>
 <h2>AUTHORS</h2>
 
 
 <dl>
 <dl>
@@ -226,34 +249,4 @@ r.terraflow elev=elevation.10m filled=elevation10m.filled \
 	<dt>Contact: <a href="mailto:ltoma@bowdoin.edu "> Laura Toma</a></dt>
 	<dt>Contact: <a href="mailto:ltoma@bowdoin.edu "> Laura Toma</a></dt>
 </dl>
 </dl>
 
 
-
-<h2>REFERENCES</h2>
-
-<ol>
-  <li> The <a href="http://www.cs.duke.edu/geo*/terraflow/">TerraFlow</a> project at Duke University
-  <li><A NAME="arge:drainage"
-       HREF="http://www.cs.duke.edu/geo*/terraflow/papers/alenex00_drainage.ps.gz">
-       I/O-efficient algorithms for problems on grid-based
-       terrains</a>.  Lars Arge, Laura Toma, and Jeffrey S. Vitter. In
-       <em>Proc. Workshop on Algorithm Engineering and Experimentation</em>,
-       2000. To appear in <em>Journal of Experimental Algorithms</em>.
-       
-  <li><A NAME="terraflow:acmgis01"
-       HREF="http://www.cs.duke.edu/geo*/terraflow/papers/acmgis01_terraflow.pdf">
-       Flow computation on massive grids</a>.
-       Lars Arge, Jeffrey S. Chase, Patrick N. Halpin, Laura Toma,
-       Jeffrey S. Vitter, Dean Urban and Rajiv Wickremesinghe. In
-       <em>Proc. ACM Symposium on Advances in Geographic Information
-       Systems</em>, 2001.
-       
-  <li><A NAME="terraflow:geoinformatica"
-       HREF="http://www.cs.duke.edu/geo*/terraflow/papers/journal_terraflow.pdf">
-       Flow computation on massive grid terrains</a>.
-       Lars Arge, Jeffrey S. Chase, Patrick N. Halpin, Laura Toma,
-       Jeffrey S. Vitter, Dean Urban and Rajiv Wickremesinghe.
-       In <em>GeoInformatica, International Journal on
-       Advances of Computer Science for Geographic Information
-       Systems</em>, 7(4):283-313, December 2003.
-</ol>
-
 <p><i>Last changed: $Date$</i>
 <p><i>Last changed: $Date$</i>

+ 1 - 5
raster/r.terraflow/weightWindow.cpp

@@ -192,8 +192,7 @@ weightWindow::compute(const dimension_type i, const dimension_type j,
 		      const direction_type dir,
 		      const direction_type dir,
 		      const int trustdir) {
 		      const int trustdir) {
   
   
-  elevation_type elev_crt, elev_neighb, e_diff;
-  dimension_type i_neighb, j_neighb;
+  elevation_type elev_crt, elev_neighb;
   
   
   /* initialize all weights to 0 */
   /* initialize all weights to 0 */
   init();
   init();
@@ -210,10 +209,7 @@ weightWindow::compute(const dimension_type i, const dimension_type j,
     for (short dj = -1; dj <= 1; dj++) {
     for (short dj = -1; dj <= 1; dj++) {
       
       
       /* grid coordinates and elevation of neighbour */
       /* grid coordinates and elevation of neighbour */
-      i_neighb = i + di; 
-      j_neighb = j + dj;
       elev_neighb = elevwin.get(di, dj);
       elev_neighb = elevwin.get(di, dj);
-      e_diff = (elevation_type)(elev_crt - elev_neighb);
 
 
       skipit = ((di ==0) && (dj==0));
       skipit = ((di ==0) && (dj==0));
       skipit |= (elev_crt < elev_neighb);
       skipit |= (elev_crt < elev_neighb);