Przeglądaj źródła

r.watershed: fix correction for diagonal flow bias

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@67297 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 9 lat temu
rodzic
commit
979b6137da

+ 5 - 5
raster/r.watershed/ram/do_astar.c

@@ -133,8 +133,8 @@ int do_astar(void)
 			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 @@ int do_astar(void)
 
 		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];
 

+ 5 - 5
raster/r.watershed/seg/do_astar.c

@@ -86,8 +86,8 @@ int do_astar(void)
 			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 @@ int do_astar(void)
 
 		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);