[GRASS5] shift bug in r.in.ascii/r.out.ascii
Roger Bivand
Roger.Bivand at nhh.no
Fri Jun 29 13:33:23 EDT 2001
On Fri, 29 Jun 2001, Markus Neteler wrote:
> Hi all,
>
> just found (obviously) a bug in r.in.ascii/r.out.ascii:
>
> if you export/import the same map several times, it get's
> shifted each time!
>
> r.out.ascii in=dem out=dem0.asc
> r.in.ascii in=dem0.asc out=dem1
>
> r.out.ascii in=dem1 out=dem1.asc
> r.in.ascii in=dem1.asc out=dem2
>
> r.out.ascii in=dem2 out=dem2.asc
> r.in.ascii in=dem2.asc out=dem3
> d.rast dem
> d.rast dem1
> d.rast dem2
> d.rast dem3
>
> As being lack of time today, any volunteers?
>
Looks to me as if fseek is moving one byte too far back in the buffer on
line 142 in r.in.ascii/cmd/gethead.c, putting the last digit of the number
of columns as the first cell value read. Since it is followed by a
newline, it is treated as value.
fseek(fd, -(len+1), SEEK_CUR);
For me, fseek(fd, -(len), SEEK_CUR); fixes it, but I haven't tried
it with other header fields or command line options.
Roger
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no
and: Department of Geography and Regional Development, University of
Gdansk, al. Mar. J. Pilsudskiego 46, PL-81 378 Gdynia, Poland.
More information about the grass-dev
mailing list