[GRASS5] [bug #4071] (grass) d.what.rast strange values outside of map area

Glynn Clements glynn at gclements.plus.com
Wed Feb 8 21:09:41 EST 2006


Request Tracker wrote:

> I discovered an unhelpful behaviour of the GRASS monitor
> or d.what.rast resp.

It's d.what.rast.

> This bug persists despite the recent
> display driver modifications (which may be unrelated to this).

They are unrelated.
 
> Test case:

> #click into no data pixels at border (outside of map box):
> d.what.rast

d.what.rast makes no attempt to check that the selected cell is
actually inside the map.

If you click above or below the map, you should get warnings from
libgis that the program attempted to read an invalid row, e.g.:

	WARNING: [elevation.dem in PERMANENT] - read request for row 148 is outside
	         region
	elevation.dem in PERMANENT  (Null)ERROR reading cell file

G_get_c_raster_row() will fill the buffer with zeros (not nulls) if
you ask for an invalid row. Arguably it should use nulls, although
this case shouldn't be allowed to happen anyhow.

If you click to either side of the map, d.what.rast will end up
reading from outside the buffer.

> Is this related to
>  http://www.intevation.de/rt/webrt?serial_num=2986&display=History
> ?

No.

> A fix would be appreciated. I don't know where to look for that.

display/d.what.rast/what.c

It needs a check along the lines of:

	if (row < 0 || row >= nrows || col < 0 || col >= ncols)
		/* outside map */

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list