[GRASS5] color table

Markus Neteler neteler at itc.it
Tue Aug 26 11:44:07 EDT 2003


On Tue, Aug 26, 2003 at 09:42:22AM +0200, Radim Blazek wrote:
> On Tuesday 26 August 2003 02:52, Glynn Clements wrote:
> > Radim Blazek wrote:
> > > Bug?:
> >
> > Yep. In libgis.
> >
> > > r.mapcalc pok1=-6.0
> > > echo -e "-10.1 green\n-5 green\n-5 blue\n10 blue" | r.colors map=pok1
> > > color=rules r.mapcalc pok2="int(pok1)"
> > > r.colors map=pok2 rast=pok1
> > > d.rast map=pok2 ---> blue!!!
> >
> > It's due to an inconsistency in the convertion of negative FP values
> > to integers. organize_lookup() in color_org.c simply truncates:
> >
> >   121:    x = (CELL ) cp->min;
> >
> >
> > while G__lookup_colors() in color_look.c uses floor():
> >
> >   156:    dmin = cp->min;
> >   157:    dmax = cp->max;
> >   158:    min = floor(dmin);
> >
> > Truncating rounds towards zero, while floor() rounds downwards
> > (towards minus infinity), so if cp->min is -10.1, truncating gives -10
> > while floor gives -11. This causes lookups in cp->lookup.{red,grn,blu}
> > to be off by one.
> >
> > Try the attached patch.
> 
> OK, are you going to submit it to CVS?

If yes, should it go into the release branch?

If possible, I would like to release 5.0.3 tomorrow or
Thursday latest (then I am out of town for more than a week).

Markus




More information about the grass-dev mailing list