No subject

Charles Ehlschlaeger chuck at geog.GEOG.UCSB.EDU
Fri Sep 3 17:15:19 EDT 1993


I have heard over grassu that r.watershed (version 4.1) is not working. After
looking into the code, I realized that a bug was introduced into the code I
wrote to speed up execution of large DEM surfaces. I am sending this note to
OGI, but it is an easy fix for those of you in a hurry:

Line 8-10 of .../src/raster/r.watershed/ram/ramseg.h reads:

>#define SEG_INDEX(s,r,c) (int) \
>   ((((r) >> RAMSEGBITS) * (s) + ((((c) >> RAMSEGBITS)) << DOUBLEBITS)) \
>    + ((((r) & SEGLENLESS) << RAMSEGBITS) + ((c) & SEGLENLESS)))

The parenthesis are all in the wrong places. They should be located:

>#define SEG_INDEX(s,r,c) (int) \
>   ((((r) >> RAMSEGBITS) * (s) + ((c) >> RAMSEGBITS)) << DOUBLEBITS) \
>    + (((r) & SEGLENLESS) << RAMSEGBITS) + ((c) & SEGLENLESS)

If you replace lines 9 and 10 in ramseg.h (without the ">"s) and re-compile,
r.watershed 4.1 should work as well (or as poorly) as older versions of
r.watershed.

Chuck Ehlschlaeger



More information about the grass-user mailing list