[GRASS5] d.rast, r.stats: G_percent bug
Glynn Clements
glynn.clements at virgin.net
Thu Jun 21 08:59:42 EDT 2001
Markus Neteler wrote:
> at time there is a little G_percent() mess with
> d.rast -> doesn't reach 100% (in tcltkgrass)
G_percent() is called *before* each pass of the loop. You need to call
G_percent() again (with appropriate arguments) once the loop has
completed. Also, this is necessary (to reset the "prev" variable) if
G_percent is to be used in a subsequent loop.
> r.stats -> displays percentage very odd,
In what sense?
> doesn't reach 100%
Same as above.
Also, the way in which the third argument is handled is somewhat
dubious. G_percent() only displays percentages which are an integral
multiple of the third argument; this will produce odd results in cases
where the percentage step is almost an exact multiple of the third
argument.
E.g. the following code:
#define N 51
for (i = 0; i < N; i++)
{
G_percent(i, N, 2);
sleep(1);
}
will display 0%, 50%, 52%, 54%, ..., 98%, while changing N to 49 will
result in it displaying 0%, 2%, 4%, ..., 48%.
Assuming that the intention is to reduce the amount of output, it
would be better to use e.g.
if (x < prev + s) return 0;
instead of
if (x % s) return 0;
--
Glynn Clements <glynn.clements at virgin.net>
More information about the grass-dev
mailing list