[GRASS-dev] Rast_set_c_value question

Glynn Clements glynn at gclements.plus.com
Mon Mar 25 16:43:44 PDT 2013


Rashad M wrote:

> Does `Rast_set_c_value` set value of all cells in raster or individual cell?

Look at the code in lib/raster/raster.c.

It converts the CELL value given by its second argument to the type
specified by its third argument and stores the converted value at the
pointer given by its first argument.

> I have a code:
> 
> s = Rast_cell_size(CELL_TYPE)
> 
> Rast_set_c_value(outptr[i], int(tmpcell), CELL_TYPE)
> 
> outptr[i] = G_incr_void_ptr(outptr[i], s)
> 
> can anybody explain what this does?

The above code is logically equivalent to:

	*(outptr[i]++) = (int) tmpcell;

except that outptr[i] could be a CELL*, FCELL* or DCELL*, with the
actual type determined at run time.

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


More information about the grass-dev mailing list