[GRASS-SVN] r67301 - in grass/branches/releasebranch_7_0/raster/r.watershed: ram seg
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Dec 21 05:55:00 PST 2015
Author: mmetz
Date: 2015-12-21 05:55:00 -0800 (Mon, 21 Dec 2015)
New Revision: 67301
Modified:
grass/branches/releasebranch_7_0/raster/r.watershed/ram/do_astar.c
grass/branches/releasebranch_7_0/raster/r.watershed/ram/do_cum.c
grass/branches/releasebranch_7_0/raster/r.watershed/seg/do_astar.c
grass/branches/releasebranch_7_0/raster/r.watershed/seg/do_cum.c
Log:
r.watershed: fix correction for diagonal flow bias
Modified: grass/branches/releasebranch_7_0/raster/r.watershed/ram/do_astar.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.watershed/ram/do_astar.c 2015-12-21 10:07:59 UTC (rev 67300)
+++ grass/branches/releasebranch_7_0/raster/r.watershed/ram/do_astar.c 2015-12-21 13:55:00 UTC (rev 67301)
@@ -133,8 +133,8 @@
get_slope2(alt_val, alt_nbr[ct_dir],
dist_to_nbr[ct_dir]);
}
- if (!is_worked) {
- if (ct_dir > 3 && slope[ct_dir] >= 0) {
+ if (!is_in_list || (!is_worked && asp[index_up] < 0)) {
+ if (ct_dir > 3 && slope[ct_dir] > 0) {
if (slope[nbr_ew[ct_dir]] >= 0) {
/* slope to ew nbr > slope to center */
if (slope[ct_dir] <
@@ -154,14 +154,14 @@
if (!skip_diag) {
/* add neighbour as new point if not in the list */
- if (is_in_list == 0) {
+ if (!is_in_list) {
add_pt(upr, upc, alt_nbr[ct_dir]);
/* set flow direction */
asp[index_up] = drain[upr - r + 1][upc - c + 1];
}
- else if (is_in_list && is_worked == 0 && slope[ct_dir] > 0) {
+ else if (!is_worked) {
/* neighbour is edge in list, not yet worked */
- if (asp[index_up] < 0) {
+ if (asp[index_up] < 0 && slope[ct_dir] > 0) {
/* adjust flow direction for edge cell */
asp[index_up] = drain[upr - r + 1][upc - c + 1];
Modified: grass/branches/releasebranch_7_0/raster/r.watershed/ram/do_cum.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.watershed/ram/do_cum.c 2015-12-21 10:07:59 UTC (rev 67300)
+++ grass/branches/releasebranch_7_0/raster/r.watershed/ram/do_cum.c 2015-12-21 13:55:00 UTC (rev 67301)
@@ -173,6 +173,8 @@
aspect = -1 * drain[r - r_nbr + 1][c - c_nbr + 1];
asp[this_index] = aspect;
}
+ if (valued > 0)
+ wat[down_index] = -valued;
continue;
}
@@ -357,6 +359,8 @@
if (dr == r_nbr && dc == c_nbr) {
astar_not_set = 0;
}
+ if (value < 0 && valued > 0)
+ wat[nbr_index] = -valued;
}
}
}
Modified: grass/branches/releasebranch_7_0/raster/r.watershed/seg/do_astar.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.watershed/seg/do_astar.c 2015-12-21 10:07:59 UTC (rev 67300)
+++ grass/branches/releasebranch_7_0/raster/r.watershed/seg/do_astar.c 2015-12-21 13:55:00 UTC (rev 67301)
@@ -86,8 +86,8 @@
get_slope2(alt_val, alt_nbr[ct_dir],
dist_to_nbr[ct_dir]);
}
- if (!is_worked) {
- if (ct_dir > 3 && slope[ct_dir] >= 0) {
+ if (!is_in_list || (!is_worked && af.asp < 0)) {
+ if (ct_dir > 3 && slope[ct_dir] > 0) {
if (slope[nbr_ew[ct_dir]] >= 0) {
/* slope to ew nbr > slope to center */
if (slope[ct_dir] <
@@ -107,16 +107,16 @@
if (!skip_diag) {
/* add neighbour as new point if not in the list */
- if (is_in_list == 0) {
+ if (!is_in_list) {
/* set flow direction */
af.asp = drain[upr - r + 1][upc - c + 1];
add_pt(upr, upc, alt_nbr[ct_dir]);
FLAG_SET(af.flag, INLISTFLAG);
seg_put(&aspflag, (char *)&af, upr, upc);
}
- else if (is_in_list && is_worked == 0 && slope[ct_dir] > 0) {
+ else if (!is_worked) {
/* neighbour is edge in list, not yet worked */
- if (af.asp < 0) {
+ if (af.asp < 0 && slope[ct_dir] > 0) {
/* adjust flow direction for edge cell */
af.asp = drain[upr - r + 1][upc - c + 1];
seg_put(&aspflag, (char *)&af, upr, upc);
Modified: grass/branches/releasebranch_7_0/raster/r.watershed/seg/do_cum.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.watershed/seg/do_cum.c 2015-12-21 10:07:59 UTC (rev 67300)
+++ grass/branches/releasebranch_7_0/raster/r.watershed/seg/do_cum.c 2015-12-21 13:55:00 UTC (rev 67301)
@@ -162,6 +162,12 @@
af.asp = -1 * drain[r - dr + 1][c - dc + 1];
}
seg_put(&aspflag, (char *)&af, r, c);
+ seg_get(&watalt, (char *)&wadown, dr, dc);
+ valued = wadown.wat;
+ if (valued > 0) {
+ wadown.wat = -valued;
+ seg_put(&watalt, (char *)&wadown, dr, dc);
+ }
continue;
}
@@ -384,6 +390,10 @@
if (dr == r_nbr && dc == c_nbr) {
astar_not_set = 0;
}
+ if (value < 0 && wat_nbr[ct_dir] > 0) {
+ wa.wat = -wat_nbr[ct_dir];
+ seg_put(&watalt, (char *)&wa, r_nbr, c_nbr);
+ }
}
}
}
More information about the grass-commit
mailing list