[GRASS-dev] Re: g.region bugs [was: GRASS 6.3.0 release preparation]

Glynn Clements glynn at gclements.plus.com
Tue Oct 16 16:52:44 EDT 2007


Maciej Sieczka wrote:

> So, we are back to were it all started. More findings and
> details follow.
> 
> Correction to original report - the bug *does* crop out in
> GRASS 6.2.3 CVS too. However, differently. Please see:
> 
> The vector line is as follows:
> 
> $ echo "L 2 1
> 602473.66691719 5680962.45268225
> 602448.70284465 5680961.09147704
> 1 1" | v.in.ascii -n form=standard out=line
> 
> 
> 
>  IN GRASS 6.2.3 CVS:
> 
> $ g.region n=5680980 s=5680960 w=602440 e=602480 res=20 -a
> 
> $ g.region vect=line res=1 -ag
> n=5680980
> s=5680960
> w=602440
> e=602480
> nsres=1
> ewres=1
> rows=20
> cols=40
> 
> Wrong. But let's try again:
> 
> $ g.region vect=line res=1 -ag
> n=5680963
> s=5680961
> w=602448
> e=602474
> nsres=1
> ewres=1
> rows=2
> cols=26
> 
> Correct this time! Strange.

The -a flag causes the region to be aligned to the existing
resolution; the res= etc options aren't processed until later.

>  IN GRASS 6.3 CVS:
> 
> $ g.region n=5680980 s=5680960 w=602440 e=602480 res=20 -a
> 
> $ g.region vect=line res=1 -ag
> n=5680963
> s=5680942
> w=602448
> e=602489
> nsres=1
> ewres=1
> rows=21
> cols=41
> cells=861
> 
> Wrong, though different than the first try in 6.2.3 CVS (see
> above).

In 6.3-CVS, the -a flag aligns the vector to itself (!), rather than
to the original region.

AFAICT, the error was introduced when the vect= option was extended to
allow multiple maps. Previously, temp_window was used to hold the
original region so that the new region (in window) could be aligned to
it.

The changed version uses temp_window to hold the region for the
current vector map (the bounds from the map but with the original
resolution) while window holds the cumulative region. The original
region is no longer stored anywhere, so alignment is not possible. The
change should have added a third variable rather than re-using
temp_window.

I've fixed this in CVS, where "fixed" means "behaves as in 6.2". 

Changing the behaviour of -a to align to the new resolution rather
than the original resolution is an incompatible change. It's debatable
whether that should go into 6.3; it certainly shouldn't be backported. 
Although it might be worthwhile clarifying the behaviour in the
documentation.

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




More information about the grass-dev mailing list