[GRASS5] bug in d.what.rast

Glynn Clements glynn.clements at virgin.net
Sun Mar 3 10:48:06 EST 2002


Eric G. Miller wrote:

> > 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).

The category reported is for the cell which is displayed beneath the
mouse cursor. But that cell can be addressed using either map row/col
or window row/col.

The main reasons that I can see for using window row/col are:

1. Those correspond to r.mapcalc's row() and col() functions, and I
can't immediately think of anywhere else that rows/cols are visible to
the user. However, r.mapcalc's row() and col() functions use one-based
indices, while "d.what.rast -c" uses zero-based indices.

2. When specifying multiple maps, the window row/col are the same for
all of them, whereas the map row/col varies with a map's boundaries
and resolution.

However, if the intention is to use window rows/cols, there isn't any
point in passing the map name or mapset to show_utm(). Those values
are only used to retrieve the map's Cell_head, which is only required
if you want to report map rows/cols.

-- 
Glynn Clements <glynn.clements at virgin.net>



More information about the grass-dev mailing list