GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gis/get_row.c File Reference
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <grass/config.h>
#include <grass/glocale.h>
#include "G.h"
Include dependency graph for gis/get_row.c:

Go to the source code of this file.

Macros

#define NULL_FILE   "null"
 

Functions

int G_get_map_row_nomask (int fd, CELL *buf, int row)
 Read raster row without masking (this routine is deprecated) More...
 
int G_get_raster_row_nomask (int fd, void *buf, int row, RASTER_MAP_TYPE data_type)
 Read raster row without masking. More...
 
int G_get_c_raster_row_nomask (int fd, CELL *buf, int row)
 Read raster row without masking (CELL type) More...
 
int G_get_f_raster_row_nomask (int fd, FCELL *buf, int row)
 Read raster row without masking (FCELL type) More...
 
int G_get_d_raster_row_nomask (int fd, DCELL *buf, int row)
 Read raster row without masking (DCELL type) More...
 
int G_get_map_row (int fd, CELL *buf, int row)
 Get raster row (this routine is deprecated!) More...
 
int G_get_raster_row (int fd, void *buf, int row, RASTER_MAP_TYPE data_type)
 Get raster row. More...
 
int G_get_c_raster_row (int fd, CELL *buf, int row)
 Get raster row (CELL type) More...
 
int G_get_f_raster_row (int fd, FCELL *buf, int row)
 Get raster row (FCELL type) More...
 
int G_get_d_raster_row (int fd, DCELL *buf, int row)
 Get raster row (DCELL type) More...
 
int G_get_null_value_row (int fd, char *flags, int row)
 Read or simmulate null value row. More...
 

Macro Definition Documentation

#define NULL_FILE   "null"

Definition at line 30 of file gis/get_row.c.

Function Documentation

int G_get_c_raster_row ( int  fd,
CELL *  buf,
int  row 
)

Get raster row (CELL type)

Reads a row of raster data and leaves the NULL values intact. (As opposed to the deprecated function G_get_map_row() which converts NULL values to zero.)

NOTE. When the raster map is old and null file doesn't exist, it is assumed that all 0-cells are no-data. When map is floating point, uses quant rules set explicitly by G_set_quant_rules() or stored in map's quant file to convert floats to integers.

Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
Returns
1 on success
0 row requested not within window
-1 on error

Definition at line 922 of file gis/get_row.c.

References G_get_raster_row().

Referenced by G_get_null_value_row(), Gs_get_cat_label(), Gs_loadmap_as_char(), Gs_loadmap_as_int(), and Gs_loadmap_as_short().

int G_get_c_raster_row_nomask ( int  fd,
CELL *  buf,
int  row 
)

Read raster row without masking (CELL type)

Same as G_get_c_raster_row() except no masking occurs.

Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
data_typedata type
Returns
1 on success
0 row requested not within window
-1 on error

Definition at line 781 of file gis/get_row.c.

References G_get_raster_row_nomask().

int G_get_d_raster_row ( int  fd,
DCELL *  buf,
int  row 
)

Get raster row (DCELL type)

Same as G_get_f_raster_row() except that the array dcell is double.

Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
Returns
1 on success
0 row requested not within window
-1 on error

Definition at line 965 of file gis/get_row.c.

References G_get_raster_row().

Referenced by G_get_raster_sample_bilinear(), G_get_raster_sample_cubic(), G_get_raster_sample_nearest(), and Gs_get_cat_label().

int G_get_d_raster_row_nomask ( int  fd,
DCELL *  buf,
int  row 
)

Read raster row without masking (DCELL type)

Same as G_get_d_raster_row() except no masking occurs.

Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
data_typedata type
Returns
1 on success
0 row requested not within window
-1 on error

Definition at line 821 of file gis/get_row.c.

References G_get_raster_row_nomask().

int G_get_f_raster_row ( int  fd,
FCELL *  buf,
int  row 
)

Get raster row (FCELL type)

Read a row from the raster map open on fd into the float array fcell performing type conversions as necessary based on the actual storage type of the map. Masking, resampling into the current region. NULL-values are always embedded in fcell (never converted to a value).

Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
Returns
1 on success
0 row requested not within window
-1 on error

Definition at line 945 of file gis/get_row.c.

References G_get_raster_row().

Referenced by Gs_loadmap_as_float().

int G_get_f_raster_row_nomask ( int  fd,
FCELL *  buf,
int  row 
)

Read raster row without masking (FCELL type)

Same as G_get_f_raster_row() except no masking occurs.

Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
data_typedata type
Returns
1 on success
0 row requested not within window
-1 on error

Definition at line 801 of file gis/get_row.c.

References G_get_raster_row_nomask().

int G_get_map_row ( int  fd,
CELL *  buf,
int  row 
)

Get raster row (this routine is deprecated!)

If the map is floating-point, quantize the floating-point values to integer using the quantization rules established for the map when the map was opened for reading (this quantization is read from cell_misc/name/f_quant file, but can be reset after opening raster map by G_set_quant_rules()). NULL values are converted to zeros.

This routine is deprecated! Use G_get_raster_row() instead.

Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
Returns
1 on success
0 row requested not within window
-1 on error

Definition at line 848 of file gis/get_row.c.

Referenced by IL_create_bitmask().

int G_get_map_row_nomask ( int  fd,
CELL *  buf,
int  row 
)

Read raster row without masking (this routine is deprecated)

This routine reads the specified row from the raster map open on file descriptor fd into the buf buffer like G_get_map_row() does. The difference is that masking is suppressed. If the user has a mask set, G_get_map_row() will apply the mask but G_get_map_row_nomask() will ignore it. This routine prints a diagnostic message and returns -1 if there is an error reading the raster map. Otherwise a nonnegative value is returned.

Note. Ignoring the mask is not generally acceptable. Users expect the mask to be applied. However, in some cases ignoring the mask is justified. For example, the GRASS modules r.describe, which reads the raster map directly to report all data values in a raster map, and r.slope.aspect, which produces slope and aspect from elevation, ignore both the mask and the region. However, the number of GRASS modules which do this should be minimal. See Mask for more information about the mask.

This routine is deprecated! Use G_get_raster_row_nomask() instead.

Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
Returns
1 on success
0 row requested not within window
-1 on error

Definition at line 740 of file gis/get_row.c.

int G_get_null_value_row ( int  fd,
char *  flags,
int  row 
)

Read or simmulate null value row.

Read or simmulate null value row and set the cells corresponding to null value to 1. The masked out cells are set to null when the mask exists. (the MASK is taken care of by null values (if the null file doesn't exist for this map, then the null row is simulated by assuming that all zeros in raster map are nulls. Also all masked out cells become nulls.

Parameters
fdfile descriptor for the opened map
bufbuffer for the row to be placed into
rowdata row desired
Returns
1

Definition at line 1242 of file gis/get_row.c.

References fd, G__::fileinfo, G_allocate_c_raster_buf(), G_free(), G_get_c_raster_row(), G_is_c_null_value(), fileinfo::reclass_flag, and G__::window.

Referenced by Gs_loadmap_as_bitmap(), Gs_loadmap_as_char(), Gs_loadmap_as_float(), Gs_loadmap_as_int(), and Gs_loadmap_as_short().

int G_get_raster_row ( int  fd,
void *  buf,
int  row,
RASTER_MAP_TYPE  data_type 
)

Get raster row.

If data_type is

  • CELL_TYPE, calls G_get_c_raster_row()
  • FCELL_TYPE, calls G_get_f_raster_row()
  • DCELL_TYPE, calls G_get_d_raster_row()

    Reads appropriate information into the buffer buf associated with the requested row row. buf is associated with the current window.

    Note, that the type of the data in buf (say X) is independent of the type of the data in the file described by fd (say Y).

    • Step 1: Read appropriate raw map data into a intermediate buffer.
    • Step 2: Convert the data into a CPU readable format, and subsequently resample the data. the data is stored in a second intermediate buffer (the type of the data in this buffer is Y).
    • Step 3: Convert this type Y data into type X data and store it in buffer "buf". Conversion is performed in functions "transfer_to_cell_XY". (For details of the conversion between two particular types check the functions).
    • Step 4: read or simmulate null value row and zero out cells corresponding to null value cells. The masked out cells are set to null when the mask exists. (the MASK is taken care of by null values (if the null file doesn't exist for this map, then the null row is simulated by assuming that all zero are nulls *** in case of G_get_raster_row() and assuming that all data is valid in case of G_get_f/d_raster_row(). In case of deprecated function G_get_map_row() all nulls are converted to zeros (so there are no embedded nulls at all). Also all masked out cells become zeros.
Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
data_typedata type
Returns
1 on success
-1 on error

Definition at line 895 of file gis/get_row.c.

Referenced by G_get_c_raster_row(), G_get_d_raster_row(), G_get_f_raster_row(), G_get_raster_row_colors(), and N_read_rast_to_array_2d().

int G_get_raster_row_nomask ( int  fd,
void *  buf,
int  row,
RASTER_MAP_TYPE  data_type 
)

Read raster row without masking.

Same as G_get_raster_row() except no masking occurs.

Parameters
fdfile descriptor for the opened raster map
bufbuffer for the row to be placed into
rowdata row desired
data_typedata type
Returns
1 on success
0 row requested not within window
-1 on error

Definition at line 760 of file gis/get_row.c.

Referenced by G_get_c_raster_row_nomask(), G_get_d_raster_row_nomask(), and G_get_f_raster_row_nomask().