[GRASS-SVN] r67297 - in grass/trunk/raster/r.watershed: ram seg
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Dec 21 02:06:25 PST 2015
Author: mmetz
Date: 2015-12-21 02:06:25 -0800 (Mon, 21 Dec 2015)
New Revision: 67297
Modified:
grass/trunk/raster/r.watershed/ram/do_astar.c
grass/trunk/raster/r.watershed/seg/do_astar.c
Log:
r.watershed: fix correction for diagonal flow bias
Modified: grass/trunk/raster/r.watershed/ram/do_astar.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/do_astar.c 2015-12-21 08:00:06 UTC (rev 67296)
+++ grass/trunk/raster/r.watershed/ram/do_astar.c 2015-12-21 10:06:25 UTC (rev 67297)
@@ -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/trunk/raster/r.watershed/seg/do_astar.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/do_astar.c 2015-12-21 08:00:06 UTC (rev 67296)
+++ grass/trunk/raster/r.watershed/seg/do_astar.c 2015-12-21 10:06:25 UTC (rev 67297)
@@ -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);
More information about the grass-commit
mailing list