[GRASS-SVN] r39951 - grass/trunk/raster/r.watershed/ram
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Dec 9 04:26:04 EST 2009
Author: mmetz
Date: 2009-12-09 04:25:52 -0500 (Wed, 09 Dec 2009)
New Revision: 39951
Modified:
grass/trunk/raster/r.watershed/ram/do_astar.c
Log:
next fix for ticket #807
Modified: grass/trunk/raster/r.watershed/ram/do_astar.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/do_astar.c 2009-12-09 01:13:48 UTC (rev 39950)
+++ grass/trunk/raster/r.watershed/ram/do_astar.c 2009-12-09 09:25:52 UTC (rev 39951)
@@ -21,6 +21,7 @@
int nbr_ns[8] = { 0, 1, 2, 3, 3, 2, 3, 2 };
double dx, dy, dist_to_nbr[8], ew_res, ns_res;
double slope[8];
+ int skip_diag;
G_message(_("SECTION 2: A * Search."));
@@ -76,45 +77,44 @@
index_up = SEG_INDEX(alt_seg, upr, upc);
is_in_list = FLAG_GET(in_list, upr, upc);
is_worked = FLAG_GET(worked, upr, upc);
+ skip_diag = 0;
/* avoid diagonal flow direction bias */
if (!is_worked) {
alt_nbr[ct_dir] = alt[index_up];
slope[ct_dir] =
get_slope2(alt_val, alt_nbr[ct_dir],
dist_to_nbr[ct_dir]);
- if (ct_dir > 3) {
- if (slope[nbr_ew[ct_dir]]) {
+ 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_slope2(alt_nbr[nbr_ew[ct_dir]],
alt_nbr[ct_dir], ew_res))
- is_in_list = 1;
+ skip_diag = 1;
}
- if (!is_in_list && slope[nbr_ns[ct_dir]]) {
+ if (!skip_diag && slope[nbr_ns[ct_dir]] > 0) {
/* slope to ns nbr > slope to center */
if (slope[ct_dir] <
get_slope2(alt_nbr[nbr_ns[ct_dir]],
alt_nbr[ct_dir], ns_res))
- is_in_list = 1;
+ skip_diag = 1;
}
}
}
/* add neighbour as new point if not in the list */
- if (is_in_list == 0) {
+ if (is_in_list == 0 && skip_diag == 0) {
add_pt(upr, upc, alt_nbr[ct_dir], alt_val);
/* set flow direction */
asp[index_up] = drain[upr - r + 1][upc - c + 1];
}
- else {
- if (is_worked == 0) {
- /* neighbour is edge in list, not yet worked */
- if (asp[index_up] < 0) {
- asp[index_up] = drain[upr - r + 1][upc - c + 1];
+ else if (is_in_list == 1 && is_worked == 0) {
+ /* neighbour is edge in list, not yet worked */
+ if (asp[index_up] < 0) {
+ asp[index_up] = drain[upr - r + 1][upc - c + 1];
- if (wat[index_doer] > 0)
- wat[index_doer] = -wat[index_doer];
- }
+ if (wat[index_doer] > 0)
+ wat[index_doer] = -wat[index_doer];
}
}
} /* end if in region */
More information about the grass-commit
mailing list