[GRASS-dev] d.zoom inconsistency,?

Glynn Clements glynn at gclements.plus.com
Tue Mar 6 23:37:57 EST 2007


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




More information about the grass-dev mailing list