[GRASS5] raster category confusion

Markus Neteler neteler at itc.it
Fri Sep 2 10:00:31 EDT 2005


On Thu, Sep 01, 2005 at 04:06:33PM +0200, Markus Neteler wrote:
> On Thu, Sep 01, 2005 at 01:21:24PM +0100, Glynn Clements wrote:
> > 
> > Markus Neteler wrote:
> > 
> > > > Forget about r.cats (and categories in general). This:
> > > > 
> > > > > r.stats -1 one
> > > > > 120
> > > > > 156
> > > > > 99
> > > > > 100
> > > > > 120
> > > > > 156
> > > > > 99
> > > > > 100
> > > > 
> > > > is a lot more interesting (and relevant).
> > > 
> > > OK:
> > > 
> > > in r.stats:
> > > 
> > > main.c 
> > >  G_get_range_min_max (&range, &min, &max);
> > >  min =1
> > >  max =1
> > > 
> > > ok so far.
> > > raw_stats (fd, verbose, with_coordinates, with_xy, with_labels);
> > >            fd     0           0               0          0
> > > 
> > > Entering raw_stats():
> > > raw_stats.c:49
> > >  rastp[i] = rast[i];
> > >  i=0
> > >  rastp[0]= void
> > > 
> > >  raw_stats.c:98, when i is 0, then
> > > *((CELL *) rastp[i]) is 120.
> > > 
> > > Then it prints 120 and so forth.
> > > 
> > > Should I add some G_debug() in raw_stats?
> > 
> > I'd start by examining the pointers rastp[0] and rast[0], and the
> > contents of the buffer to which they point, before entering the
> > "for (col = ..." loop. I.e.:
> > 
> > 	print rast[0]
> > 	print rastp[0]
> > 	print *(CELL*)(rast[0])@50
> 
> The @ is dislike (not sure what it does). This is what I get:
> 
> GRASS 6.1.cvs (spearfish60):~/grass61/raster/r.stats > cvs diff raw_stats.c
> Index: raw_stats.c
> ===================================================================
> RCS file: /grassrepository/grass6/raster/r.stats/raw_stats.c,v
> retrieving revision 2.1
> diff -u -r2.1 raw_stats.c
> --- raw_stats.c 13 Jul 2005 15:55:40 -0000      2.1
> +++ raw_stats.c 1 Sep 2005 13:10:08 -0000
> @@ -52,6 +52,11 @@
>         if (with_coordinates)
>             G_format_northing (G_row_to_northing(row+.5, &window), nbuf, -1);
> 
> +
> +       G_debug(0, "rast[%d]: %d", rast[i], i);
> +       G_debug(0, "rastp[%d]: %d", rastp[i], i);
> +       G_debug(0, "*(CELL*)(rast[0]): %d", *(CELL*)(rast[0]));
> +       G_debug(0, "*(CELL*)(rast[%d]): %d", *(CELL*)(rast[i]));
>         for (col = 0; col < ncols; col++)
>         {
>             if (no_nulls || no_nulls_all)
> GRASS 6.1.cvs (spearfish60):~/grass61/raster/r.stats > r.stats -1 one
> D0/0: rast[0]: 1
> D0/0: rastp[0]: 1
> D0/0: *(CELL*)(rast[0]): 120
> Segmentation fault
> 
> Apparently the last G_debug does not make sense, but the mysterious (?) 120
> is there.
> 
> BTW:
>  gcc version 3.4.3 20050227 (Red Hat 3.4.3-22.1)
>

OK, we debugged some more hours here. Outcome:

With apparently identical settings (PATH, LD_LIBRARY_PATH etc),
identical software (GRASS, libs etc), identical shell:

- user 'neteler' still writes/reads nonsense raster maps
- another user on the same machine successfully writes/reads raster
  maps except for those generated by user 'neteler'

It seems that I am out of the game :-)

Crazy.

Markus




More information about the grass-dev mailing list