[GRASS5] bug in d.what.rast

Eric G. Miller egm2 at jps.net
Sun Mar 3 01:37:53 EST 2002


On Sun, Mar 03, 2002 at 05:04:01AM +0000, Glynn Clements wrote:

> In the previous version, mapset was always NULL the first time that
> show_utm() was called, ensuring that the Cell_head was read. 
> Thereafter, mapset would be non-NULL, and the existing Cell_head would
> be read.
> 
> So, the bug was introduced in 1.4, and the fix is to always call
> G_get_cellhd(). And there isn't any reason for cellhd to be static
> now.

This is kind of what I thought, but I didn't look close enough to
make a decision.

> Also, I'm suspicious of Huidae's "fix" in 1.3:
> 
> -    n_row = (int) ((cellhd.north - north) / cellhd.ns_res);
> -    e_col = (int) ((east - cellhd.west) / cellhd.ew_res);
> +    n_row = (int) ((cellhd.north - north) / window->ns_res);
> +    e_col = (int) ((east - cellhd.west) / window->ew_res);
> 
> Either of:
> 
> 	n_row = (int) ((cellhd.north - north) / cellhd.ns_res);
> 	e_col = (int) ((east - cellhd.west) / cellhd.ew_res);
> and:
> 	n_row = (int) ((window->north - north) / window->ns_res);
> 	e_col = (int) ((east - window->west) / window->ew_res);
> 
> make sense, depending upon whether you want coordinates in map cells
> or window cells. But I can't see any obvious significance to the
> values returned by the existing code.

The man page says it outputs row/col for the entire map region.  It's
a bit ambiguous what that means.  One reason to use the window vs.
the actual cell region, is probably because the coordinates derived
from a mouse click are based on the display window.  It should be
consistent with how the categories are looked up (otherwise, it'd
likely report a row/col value that doesn't match the category reported).

> Another question springs to mind, namely whether d.what.rast should
> read the region from the monitor rather than using the current window,
> as the monitor's region reflects what is actually displayed in the
> window.

Probably should use the monitor's.  In practice, they'll probably
be the same as user's aren't likely to change the region setting
between drawing the raster and querying it.  Still, if they do,
it could lead to interesting results...

-- 
Eric G. Miller <egm2 at jps.net>



More information about the grass-dev mailing list