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

this bug's URL: http://intevation.de/rt/webrt?serial_num=4071
-------------------------------------------------------------------------

Subject: d.what.rast strange values outside of map area

Platform: GNU/Linux/x86_64
grass obtained from: CVS
grass binary for platform: Compiled from Sources

Hi,

I discovered an unhelpful behaviour of the GRASS monitor
or d.what.rast resp. This bug persists despite the recent
display driver modifications (which may be unrelated to this).

Test case:

#generate a hemisphere (use in non-LatLong location, e.g. Spearfish):
./testsuite/raster/rhemisphere.sh

#zoom to hemisphere:
g.region hemisphere -p

#generate box of same size:
v.in.region hemisphere_box

# open monitor with different ratio than map:
export GRASS_WIDTH=1000
export GRASS_HEIGHT=500
d.mon x0

# view the map and box
d.rast hemisphere
d.vect hemisphere_box type=boundary

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

1267(E) 437(N)
hemisphere in neteler, quant (1080098213)
hemisphere in neteler, actual (-3199042392403159334141127237487472760781471376965238957138138332769142568673864556645968880013387064229402063231226593015070762178538729445017824264192.000000)

1293(E) 253(N)
hemisphere in neteler, quant (1081451460)
hemisphere in neteler, actual (-0.000000)

Looks fairly ugly.

uname -a
Linux bartok 2.6.9-22.0.1.ELsmp #1 SMP Tue Oct 18 18:39:02 EDT 2005 x86_64 x86_64 x86_64 GNU/Linux

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

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

Markus

-------------------------------------------- Managed by Request Tracker

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@gclements.plus.com>

On Thu, Feb 09, 2006 at 02:09:41AM +0000, Glynn Clements wrote:

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 */

Thanks, I have added a test now. If you click outside of
the map, this message appears:

You are clicking outside the map

Example:

Buttons
Left: what's here
Right: quit

962.7016129(E) 599.7983871(N)
hemisphere in neteler, quant (161)
hemisphere in neteler, actual (160.717143)

1192.54032258(E) 636.08870968(N)
You are clicking outside the map

1281.25(E) 672.37903226(N)
You are clicking outside the map

Problem solved. Strangely: it must have been since the
existance of d.what.rast or at least after NULL introduction ?!?

Markus

On Thu, Feb 09, 2006 at 11:16:37AM -0700, Michael Barton wrote:

Markus,

Does this affect r.what?

no, it doesn't AFAIK. It is/was a display problem.
Not sure if there are other modules to fix as well.

Markus