7
7
int r, rr, c, cc, uprow = 0, upcol = 0;
9
CELL downdir, asp_value, hih_ele, new_ele, aspect, value;
9
CELL hih_ele, new_ele, value;
10
char downdir, asp_value, aspect;
10
11
DCELL dvalue, max_drain; /* flow acc is now DCELL */
11
SHORT updir, riteflag, leftflag, thisdir;
12
int updir, riteflag, leftflag, thisdir;
14
17
cseg_put(&bas, &basin_num, row, col);
16
19
for (r = row - 1, rr = 0; r <= row + 1; r++, rr++) {
17
20
for (c = col - 1, cc = 0; c <= col + 1; c++, cc++) {
18
21
if (r >= 0 && c >= 0 && r < nrows && c < ncols) {
22
if (r == row && c == col)
20
cseg_get(&asp, &aspect, r, c);
25
seg_get(&aspflag, (char *)&af, r, c);
21
27
if (aspect == drain[rr][cc]) {
22
dseg_get(&wat, &dvalue, r, c);
28
seg_get(&watalt, (char *)&wa, r, c);
25
if ((dvalue - max_drain) > 5E-8f) { /* floating point comparison problem workaround */
32
if (dvalue > max_drain) {
28
35
max_drain = dvalue;
34
41
if (max_drain > -1) {
35
42
updir = drain[row - uprow + 1][col - upcol + 1];
36
cseg_get(&asp, &downdir, row, col);
43
seg_get(&aspflag, (char *)&af, row, col);
38
46
downdir = -downdir;
40
if (uprow != row && upcol != col)
41
stream_length += diag;
42
else if (uprow != row)
43
stream_length += window.ns_res;
45
stream_length += window.ew_res;
47
else { /* sides == 4 */
49
cseg_get(&asp, &asp_value, uprow, upcol);
50
if (downdir == 2 || downdir == 6) {
51
if (asp_value == 2 || asp_value == 6)
49
if (uprow != row && upcol != col)
50
stream_length += diag;
51
else if (uprow != row)
52
52
stream_length += window.ns_res;
54
stream_length += diag;
56
else { /* downdir == 4,8 */
58
if (asp_value == 4 || asp_value == 8)
59
54
stream_length += window.ew_res;
61
stream_length += diag;
56
else { /* sides == 4 */
57
seg_get(&aspflag, (char *)&af, uprow, upcol);
59
if (downdir == 2 || downdir == 6) {
60
if (asp_value == 2 || asp_value == 6)
61
stream_length += window.ns_res;
63
stream_length += diag;
65
else { /* downdir == 4,8 */
67
if (asp_value == 4 || asp_value == 8)
68
stream_length += window.ew_res;
70
stream_length += diag;
64
74
riteflag = leftflag = 0;
65
75
for (r = row - 1, rr = 0; rr < 3; r++, rr++) {
66
76
for (c = col - 1, cc = 0; cc < 3; c++, cc++) {
67
77
if (r >= 0 && c >= 0 && r < nrows && c < ncols) {
68
cseg_get(&asp, &aspect, r, c);
78
seg_get(&aspflag, (char *)&af, r, c);
69
80
if (aspect == drain[rr][cc]) {
70
81
thisdir = updrain[rr][cc];
71
82
switch (haf_basin_side(updir,
75
86
overland_cells(r, c, basin_num, basin_num,
99
cseg_get(&alt, &hih_ele, row, col);
111
seg_get(&watalt, (char *) &wa, row, col);
100
113
slope = (hih_ele - old_elev) / stream_length;
101
114
if (slope < MIN_SLOPE)
102
115
slope = MIN_SLOPE;