[GRASS-SVN] r73987 - grass-addons/grass7/raster/r.accumulate
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Jan 20 13:38:47 PST 2019
Author: hcho
Date: 2019-01-20 13:38:47 -0800 (Sun, 20 Jan 2019)
New Revision: 73987
Modified:
grass-addons/grass7/raster/r.accumulate/accumulate.c
grass-addons/grass7/raster/r.accumulate/calculate_lfp.c
grass-addons/grass7/raster/r.accumulate/delineate_streams.c
grass-addons/grass7/raster/r.accumulate/main.c
Log:
r.accumulate: Add progress messages
Modified: grass-addons/grass7/raster/r.accumulate/accumulate.c
===================================================================
--- grass-addons/grass7/raster/r.accumulate/accumulate.c 2019-01-20 21:10:52 UTC (rev 73986)
+++ grass-addons/grass7/raster/r.accumulate/accumulate.c 2019-01-20 21:38:47 UTC (rev 73987)
@@ -1,3 +1,4 @@
+#include <grass/glocale.h>
#include "global.h"
static double trace_up(struct cell_map *, struct raster_map *,
@@ -9,10 +10,13 @@
int rows = dir_buf->rows, cols = dir_buf->cols;
int row, col;
+ G_message(_("Accumulating flow..."));
for (row = 0; row < rows; row++) {
+ G_percent(row, rows, 1);
for (col = 0; col < cols; col++)
trace_up(dir_buf, weight_buf, accum_buf, done, neg, row, col);
}
+ G_percent(1, 1, 1);
}
static double trace_up(struct cell_map *dir_buf,
Modified: grass-addons/grass7/raster/r.accumulate/calculate_lfp.c
===================================================================
--- grass-addons/grass7/raster/r.accumulate/calculate_lfp.c 2019-01-20 21:10:52 UTC (rev 73986)
+++ grass-addons/grass7/raster/r.accumulate/calculate_lfp.c 2019-01-20 21:38:47 UTC (rev 73987)
@@ -48,11 +48,14 @@
/* loop through all outlets and find the longest flow path for each */
cat = 1;
+ G_message(_("Calculating longest flow path..."));
for (i = 0; i < outlet_pl->n; i++) {
int row = (int)Rast_northing_to_row(outlet_pl->y[i], &window);
int col = (int)Rast_easting_to_col(outlet_pl->x[i], &window);
int n;
+ G_percent(i, outlet_pl->n, 1);
+
/* if the outlet is outside the computational region, skip */
if (row < 0 || row >= rows || col < 0 || col >= cols) {
G_warning(_("Skip outlet (%f, %f) outside the current region"),
@@ -98,6 +101,7 @@
cat++;
}
}
+ G_percent(1, 1, 1);
free_point_list(&pl);
free_line_list(&ll);
Modified: grass-addons/grass7/raster/r.accumulate/delineate_streams.c
===================================================================
--- grass-addons/grass7/raster/r.accumulate/delineate_streams.c 2019-01-20 21:10:52 UTC (rev 73986)
+++ grass-addons/grass7/raster/r.accumulate/delineate_streams.c 2019-01-20 21:38:47 UTC (rev 73987)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
#include <grass/vector.h>
+#include <grass/glocale.h>
#include "global.h"
static void trace_down(struct cell_map *, struct raster_map *accum_buf,
@@ -25,7 +26,9 @@
Cats = Vect_new_cats_struct();
/* loop through all cells to find headwater cells */
+ G_message(_("Delineating streams..."));
for (row = 0; row < rows; row++) {
+ G_percent(row, rows, 1);
for (col = 0; col < cols; col++) {
int i, j;
int nup = 0;
@@ -75,6 +78,7 @@
}
}
}
+ G_percent(1, 1, 1);
free_point_list(&pl);
Modified: grass-addons/grass7/raster/r.accumulate/main.c
===================================================================
--- grass-addons/grass7/raster/r.accumulate/main.c 2019-01-20 21:10:52 UTC (rev 73986)
+++ grass-addons/grass7/raster/r.accumulate/main.c 2019-01-20 21:38:47 UTC (rev 73987)
@@ -348,7 +348,9 @@
dir_buf.rows = rows;
dir_buf.cols = cols;
dir_buf.c = G_malloc(rows * sizeof(CELL *));
+ G_message(_("Reading direction map..."));
for (row = 0; row < rows; row++) {
+ G_percent(row, rows, 1);
done[row] = G_calloc(cols, 1);
dir_buf.c[row] = Rast_allocate_c_buf();
Rast_get_c_row(dir_fd, dir_buf.c[row], row);
@@ -357,6 +359,7 @@
dir_buf.c[row][col] /= 45.0;
}
}
+ G_percent(1, 1, 1);
Rast_close(dir_fd);
/* optionally, read a weight map */
@@ -367,12 +370,15 @@
weight_buf.rows = rows;
weight_buf.cols = cols;
weight_buf.map.v = (void **)G_malloc(rows * sizeof(void *));
+ G_message(_("Reading weight map..."));
for (row = 0; row < rows; row++) {
+ G_percent(row, rows, 1);
weight_buf.map.v[row] =
(void *)Rast_allocate_buf(weight_buf.type);
Rast_get_row(weight_fd, weight_buf.map.v[row], row,
weight_buf.type);
}
+ G_percent(1, 1, 1);
Rast_close(weight_fd);
}
else {
More information about the grass-commit
mailing list