GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gis/raster.c File Reference
#include <stdlib.h>
#include <grass/gis.h>
Include dependency graph for gis/raster.c:

Go to the source code of this file.

Functions

void * G_incr_void_ptr (const void *ptr, const size_t size)
 Advance void pointer. More...
 
int G_raster_cmp (const void *v1, const void *v2, RASTER_MAP_TYPE data_type)
 Compares raster values p and q. More...
 
int G_raster_cpy (void *v1, const void *v2, int n, RASTER_MAP_TYPE data_type)
 Copies raster values q into p. More...
 
int G_set_raster_value_c (void *rast, CELL cval, RASTER_MAP_TYPE data_type)
 Places a CELL raster value. More...
 
int G_set_raster_value_f (void *rast, FCELL fval, RASTER_MAP_TYPE data_type)
 Places a FCELL raster value. More...
 
int G_set_raster_value_d (void *rast, DCELL dval, RASTER_MAP_TYPE data_type)
 Places a DCELL raster value. More...
 
CELL G_get_raster_value_c (const void *rast, RASTER_MAP_TYPE data_type)
 Retrieves the value of type data_type from pointer p. More...
 
FCELL G_get_raster_value_f (const void *rast, RASTER_MAP_TYPE data_type)
 Retrieves the value of type data_type from pointer p. More...
 
DCELL G_get_raster_value_d (const void *rast, RASTER_MAP_TYPE data_type)
 Retrieves the value of type data_type from pointer p,. More...
 

Function Documentation

CELL G_get_raster_value_c ( const void *  rast,
RASTER_MAP_TYPE  data_type 
)

Retrieves the value of type data_type from pointer p.

Retrieves the value of type data_type from pointer p, converts it to CELL type and returns the result. If null value is stored in p, returns CELL null value.

Used for retrieving CELL values from raster cells of any type.

NOTE: when data_type != CELL_TYPE, no quantization is used, only type conversion.

Parameters
p
data_type
Returns
CELL

Definition at line 243 of file gis/raster.c.

References G_is_null_value(), and G_set_c_null_value().

DCELL G_get_raster_value_d ( const void *  rast,
RASTER_MAP_TYPE  data_type 
)

Retrieves the value of type data_type from pointer p,.

Retrieves the value of type data_type from pointer p, converts it to DCELL type and returns the result. If null value is stored in p, returns DCELL null value.

Used for retrieving DCELL values from raster cells of any type.

Parameters
p
data_type
Returns
DCELL

Definition at line 313 of file gis/raster.c.

References G_is_null_value(), and G_set_d_null_value().

Referenced by G__lookup_colors(), G_get_raster_cat(), G_mark_raster_cats(), and G_set_raster_cat().

FCELL G_get_raster_value_f ( const void *  rast,
RASTER_MAP_TYPE  data_type 
)

Retrieves the value of type data_type from pointer p.

Retrieves the value of type data_type from pointer p, converts it to FCELL type and returns the result. If null value is stored in p, returns FCELL null value.

Used for retrieving FCELL values from raster cells of any type.

Parameters
p
data_type
Returns
FCELL

Definition at line 278 of file gis/raster.c.

References G_is_null_value(), and G_set_f_null_value().

void* G_incr_void_ptr ( const void *  ptr,
const size_t  size 
)

Advance void pointer.

Advances void pointer by size bytes Returns new pointer value.

Useful in raster row processing loops, substitutes

CELL *cell;
cell += n;

Now

rast = G_incr_void_ptr(rast, G_raster_size(data_type))

(where rast is void* and data_type is RASTER_MAP_TYPE can be used instead of rast++.)

very useful to generalize the row processing - loop i.e. void * buf_ptr += G_raster_size(data_type)

Parameters
ptr
size
Returns
void *

Definition at line 33 of file gis/raster.c.

Referenced by D_draw_raster_RGB(), G3d_copyFromXdr(), G3d_copyToXdr(), G3d_copyValues(), G3d_getBlock(), G3d_makeAlignedVolumeFile(), G3d_range_updateFromTile(), G__lookup_colors(), G_get_raster_row_colors(), G_mark_raster_cats(), G_row_update_fp_range(), and N_read_rast_to_array_2d().

int G_raster_cmp ( const void *  v1,
const void *  v2,
RASTER_MAP_TYPE  data_type 
)

Compares raster values p and q.

Returns: 1 if p > q or only q is null value -1 if p < q or only p is null value 0 if p == q or p==q==null value

Parameters
p
q
data_type
Returns
int

Definition at line 54 of file gis/raster.c.

References G_is_null_value().

Referenced by G__lookup_colors().

int G_raster_cpy ( void *  v1,
const void *  v2,
int  n,
RASTER_MAP_TYPE  data_type 
)

Copies raster values q into p.

If q is null value, sets q to null value.

Parameters
p
q
n
data_type
Returns
int

Definition at line 105 of file gis/raster.c.

References G_copy(), and G_raster_size().

int G_set_raster_value_c ( void *  rast,
CELL  cval,
RASTER_MAP_TYPE  data_type 
)

Places a CELL raster value.

If G_is_c_null_value(val) is true, sets p to null value. Converts CELL val to data_type (type of p) and stores result in p. Used for assigning CELL values to raster cells of any type.

Parameters
p
val
data_type
Returns
int

Definition at line 125 of file gis/raster.c.

References G_is_c_null_value(), and G_set_null_value().

int G_set_raster_value_d ( void *  rast,
DCELL  dval,
RASTER_MAP_TYPE  data_type 
)

Places a DCELL raster value.

If G_is_d_null_value(val) is true, sets p to null value. Converts DCELL val to data_type (type of p) and stores result in p. Used for assigning DCELL values to raster cells of any type.

Parameters
p
val
data_type
Returns
int

Definition at line 201 of file gis/raster.c.

References G_is_d_null_value(), and G_set_null_value().

Referenced by G_get_ith_c_raster_cat(), G_get_ith_f_raster_cat(), G_get_ith_raster_cat(), and G_get_next_marked_raster_cat().

int G_set_raster_value_f ( void *  rast,
FCELL  fval,
RASTER_MAP_TYPE  data_type 
)

Places a FCELL raster value.

If G_is_f_null_value(val) is true, sets p to null value. Converts FCELL val to data_type (type of p) and stores result in p. Used for assigning FCELL values to raster cells of any type.

Parameters
p
val
data_type
Returns
int

Definition at line 163 of file gis/raster.c.

References G_is_f_null_value(), and G_set_null_value().