Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/OSGeo/grass-addons
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenpawley committed Jul 11, 2020
2 parents c7921c1 + b3ee5be commit 5abfba1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
7 changes: 4 additions & 3 deletions grass7/raster/r.accumulate/calculate_lfp_iterative.c
Expand Up @@ -306,9 +306,10 @@ static void find_up(struct cell_map *dir_buf, struct raster_map *accum_buf,
if ((i == 0 && j == 0) || col + j < 0 || col + j >= ncols)
continue;

/* if a neighbor cell flows into the current cell, store its
* accumulation in the accum array */
if (dir_buf->c[row + i][col + j] == dir_checks[i + 1][j + 1][0]) {
/* if a neighbor cell flows into the current cell with no flow
* loop, store its accumulation in the accum array */
if (dir_buf->c[row + i][col + j] == dir_checks[i + 1][j + 1][0] &&
dir_buf->c[row][col] != dir_checks[i + 1][j + 1][1]) {
double up_acc = get(accum_buf, row + i, col + j);

/* upstream accumulation must always be less than the current
Expand Down
7 changes: 4 additions & 3 deletions grass7/raster/r.accumulate/calculate_lfp_recursive.c
Expand Up @@ -237,9 +237,10 @@ static int trace_up(struct cell_map *dir_buf, struct raster_map *accum_buf,
if ((i == 0 && j == 0) || col + j < 0 || col + j >= ncols)
continue;

/* if a neighbor cell flows into the current cell, store its
* accumulation in the accum array */
if (dir_buf->c[row + i][col + j] == dir_checks[i + 1][j + 1][0]) {
/* if a neighbor cell flows into the current cell with no flow
* loop, store its accumulation in the accum array */
if (dir_buf->c[row + i][col + j] == dir_checks[i + 1][j + 1][0] &&
dir_buf->c[row][col] != dir_checks[i + 1][j + 1][1]) {
double up_acc = get(accum_buf, row + i, col + j);

/* upstream accumulation must always be less than the current
Expand Down
17 changes: 10 additions & 7 deletions grass7/raster/r.accumulate/delineate_streams.c
Expand Up @@ -52,11 +52,12 @@ void delineate_streams(struct Map_info *Map, struct cell_map *dir_buf,
if ((i == 0 && j == 0) || col + j < 0 || col + j >= ncols)
continue;

/* if a neighbor cell flows into the current cell and has a
* flow higher than the threshold, the current cell is not
* a headwater */
/* if a neighbor cell flows into the current cell with no
* flow loop and has a flow higher than the threshold, the
* current cell is not a headwater */
if (dir_buf->c[row + i][col + j] ==
dir_checks[i + 1][j + 1][0] &&
dir_buf->c[row][col] != dir_checks[i + 1][j + 1][1] &&
get(accum_buf, row + i, col + j) >= thresh)
nup++;
}
Expand Down Expand Up @@ -122,12 +123,14 @@ static void trace_down(struct cell_map *dir_buf, struct raster_map *accum_buf,
if ((i == 0 && j == 0) || col + j < 0 || col + j >= ncols)
continue;

/* if multiple neighbor cells flow into the current cell and
* have a flow higher than the threshold, the current cell is a
* confluence; stop tracing in this case only if this cell is
* not starting a new stream at this confluence */
/* if multiple neighbor cells flow into the current cell with
* no flow loop and have a flow higher than the threshold, the
* current cell is a confluence; stop tracing in this case only
* if this cell is not starting a new stream at this confluence
*/
if (dir_buf->c[row + i][col + j] ==
dir_checks[i + 1][j + 1][0] &&
dir_buf->c[row][col] != dir_checks[i + 1][j + 1][1] &&
get(accum_buf, row + i, col + j) >= thresh && pl->n > 1 &&
++nup > 1)
return;
Expand Down
Expand Up @@ -147,8 +147,9 @@ static void find_up(struct cell_map *dir_buf, char **done, int id, int row,
if ((i == 0 && j == 0) || col + j < 0 || col + j >= ncols)
continue;

/* if a neighbor cell flows into the current cell, store its
* row and col in the up array */
/* if a neighbor cell flows into the current cell, store its row
* and col in the up array; no check for flow loop is needed
* because dir_buf is being overwritten */
if (dir_buf->c[row + i][col + j] == dir_checks[i + 1][j + 1][0] &&
!done[row + i][col + j]) {
up[*nup].row = row + i;
Expand Down
Expand Up @@ -99,8 +99,10 @@ static void trace_up(struct cell_map *dir_buf, char **done, int row, int col,
continue;

/* if a neighbor cell flows into the current cell, add it to the
* map and trace up further */
if (dir_buf->c[row + i][col + j] == dir_checks[i + 1][j + 1][0]) {
* map and trace up further; no check for flow loop is needed
* because dir_buf is being overwritten */
if (dir_buf->c[row + i][col + j] == dir_checks[i + 1][j + 1][0] &&
!done[row + i][col + j]) {
dir_buf->c[row][col] = id;
done[row][col] = 1;
trace_up(dir_buf, done, row + i, col + j, id);
Expand Down

0 comments on commit 5abfba1

Please sign in to comment.