[GRASS-dev] d.zoom inconsistency,?

Hi,

Please look at the attached pictures. There is a raster on an X monitor
(raster.png).

Let's zoom-in with d.zoom as shown on the box_horiz_over.png. The
result is 4 cells (zoom_horiz_over.png).

Now let's zoom like on the box_vert_over.png. The result is 8 cells
(zoom_vert_over.png).

Shouldn't 4 cells be the result in both cases? If you don't see the
logics in my question I can explain it :).

It's the same in GRASS 6.2, so nothing newly introduced. Note that the
gis.m zoom tool does both zooming variants the way it seems logical to
me, ie. 4 cells is the result for both variants.

Maciek

(attachments)

raster.png
box_horiz_over.png
zoom_horiz_over.png
box_vert_over.png
zoom_vert_over.png

Maciej Sieczka wrote:

Please look at the attached pictures. There is a raster on an X monitor
(raster.png).

Let's zoom-in with d.zoom as shown on the box_horiz_over.png. The
result is 4 cells (zoom_horiz_over.png).

Now let's zoom like on the box_vert_over.png. The result is 8 cells
(zoom_vert_over.png).

Shouldn't 4 cells be the result in both cases? If you don't see the
logics in my question I can explain it :).

I haven't gone into it with gdb yet, but the issue appears to be the
following code in set_win() (display/d.zoom/set.c):

  td = ceil (north / nsr);
  tnorth = td * nsr;
  td = floor (south / nsr);
  tsouth = td * nsr;
  td = rint (east / ewr);
  teast = td * ewr;
  td = rint (west / ewr);
  twest = td * ewr;

IOW, north is rounded up, south is rounded down, east and west are
rounded to nearest.

FWIW, I also consider this to be counter-intuitive; although there's
no "right" approach, any approach which treats the horizontal and
vertical axes differently is wrong, IMHO.

Beyond that, rounding opposing edges in the same direction (i.e.
rounding both up or rounding both down) also seems wrong. More useful
approaches would be:

1. Round inwards, i.e. round west+south up, east+north down
2. Round outwards, i.e. round west+south down, east+north up
3. Always round to nearest.

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