[GRASS-SVN] r67235 - grass/trunk/raster/r.stream.extract
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Dec 18 13:07:41 PST 2015
Author: mmetz
Date: 2015-12-18 13:07:41 -0800 (Fri, 18 Dec 2015)
New Revision: 67235
Modified:
grass/trunk/raster/r.stream.extract/do_astar.c
Log:
r.stream.extract: fix correction for diagonal flow direction bias
Modified: grass/trunk/raster/r.stream.extract/do_astar.c
===================================================================
--- grass/trunk/raster/r.stream.extract/do_astar.c 2015-12-18 21:05:10 UTC (rev 67234)
+++ grass/trunk/raster/r.stream.extract/do_astar.c 2015-12-18 21:07:41 UTC (rev 67235)
@@ -4,8 +4,8 @@
#include <grass/glocale.h>
#include "local_proto.h"
-#define GET_PARENT(c) ((((c) - 2) >> 3) + 1)
-#define GET_CHILD(p) (((p) << 3) - 6)
+#define GET_PARENT(c) ((((GW_LARGE_INT)(c) - 2) >> 3) + 1)
+#define GET_CHILD(p) (((GW_LARGE_INT)(p) << 3) - 6)
HEAP_PNT heap_drop(void);
static double get_slope(CELL, CELL, double);
@@ -78,7 +78,8 @@
/* 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 @@
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]],
More information about the grass-commit
mailing list