Jelajahi Sumber

r.stream.extract: fix correction for diagonal flow direction bias

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@67236 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 9 tahun lalu
induk
melakukan
05ae435e3a
1 mengubah file dengan 6 tambahan dan 5 penghapusan
  1. 6 5
      raster/r.stream.extract/do_astar.c

+ 6 - 5
raster/r.stream.extract/do_astar.c

@@ -78,7 +78,8 @@ int do_astar(void)
 	    /* get r, c (r_nbr, c_nbr) for neighbours */
 	    r_nbr = r + nextdr[ct_dir];
 	    c_nbr = c + nextdc[ct_dir];
-	    slope[ct_dir] = ele_nbr[ct_dir] = 0;
+	    slope[ct_dir] = -1;
+	    ele_nbr[ct_dir] = 0;
 	    skip_diag = 0;
 
 	    /* check that neighbour is within region */
@@ -95,16 +96,16 @@ int do_astar(void)
 			                  dist_to_nbr[ct_dir]);
 	    }
 	    /* avoid diagonal flow direction bias */
-	    if (!is_in_list) {
-		if (ct_dir > 3 && slope[ct_dir] > 0) {
-		    if (slope[nbr_ew[ct_dir]] > 0) {
+	    if (!is_worked) {
+		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] <
 			    get_slope(ele_nbr[nbr_ew[ct_dir]],
 				       ele_nbr[ct_dir], ew_res))
 			    skip_diag = 1;
 		    }
-		    if (!skip_diag && slope[nbr_ns[ct_dir]] > 0) {
+		    if (!skip_diag && slope[nbr_ns[ct_dir]] >= 0) {
 			/* slope to ns nbr > slope to center */
 			if (slope[ct_dir] <
 			    get_slope(ele_nbr[nbr_ns[ct_dir]],