24 #include <grass/gis.h>
25 #include <grass/glocale.h>
27 static int EmbedGivenNulls(
void *,
char *, RASTER_MAP_TYPE,
int);
40 static int EmbedGivenNulls(
void *cell,
char *nulls, RASTER_MAP_TYPE map_type,
52 for (i = 0; i < ncols; i++) {
68 G_warning(_(
"EmbedGivenNulls: wrong data type!"));
91 RASTER_MAP_TYPE data_type)
128 G_warning(_(
"G_set_null_value: wrong data type!"));
146 for (i = 0; i < numVals; i++)
147 cellVals[i] = (
int) 0x80000000;
160 static const unsigned char null_bits[4] = {
161 0xFF, 0xFF, 0xFF, 0xFF};
164 for (i = 0; i < numVals; i++)
165 memcpy(&fcellVals[i], null_bits,
sizeof(null_bits));
178 static const unsigned char null_bits[8] = {
179 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
182 for (i = 0; i < numVals; i++)
183 memcpy(&dcellVals[i], null_bits,
sizeof(null_bits));
220 G_warning(
"G_is_null_value: wrong data type!");
247 return *cellVal == (CELL) 0x80000000;
283 return *fcellVal != *fcellVal;
308 return *dcellVal != *dcellVal;
342 RASTER_MAP_TYPE data_type)
344 return (EmbedGivenNulls(rast, null_row, data_type, ncols));
372 return (EmbedGivenNulls((
void *)cellVal, null_row, CELL_TYPE, ncols));
400 return (EmbedGivenNulls((
void *)fcellVal, null_row, FCELL_TYPE, ncols));
428 return (EmbedGivenNulls((
void *)dcellVal, null_row, DCELL_TYPE, ncols));
451 G_warning(
"G__check_null_bit: can't access index %d. "
452 "Size of flags is %d (bit # is %d",
457 offset = (ind + 1) * 8 - bit_num - 1;
459 return ((flags[ind] & ((
unsigned char)1 << offset)) != 0);
477 int col,
int n,
int ncols)
484 if (col == 0 && n == ncols) {
492 for (i = 0; i <
size; i++) {
497 if (count >= col && count < (col + n)) {
498 v = v | ((
unsigned char)zero_ones[count - col] << k);
500 else if (count < ncols) {
536 for (i = 0; i <
size; i++) {
542 *v = *v | ((
unsigned char)zero_ones[count] << k);
565 const unsigned char *v;
574 for (i = 0; i <
size; i++) {
579 zero_ones[
count] = ((*v & ((
unsigned char)1 << k)) != 0);
608 for (i = 0; i <
size; i++) {
609 if ((i + 1) * 8 <= cols) {
610 *v = (
unsigned char)255;
613 *v = (
unsigned char)255 << ((i + 1) * 8 -
cols);
int G_is_c_null_value(const CELL *cellVal)
Returns 1 if cell is NULL, 0 otherwise. This will test if the value cell is the largest int...
void G__set_null_value(void *rast, int numVals, int null_is_zero, RASTER_MAP_TYPE data_type)
void G_set_d_null_value(DCELL *dcellVals, int numVals)
int G__set_flags_from_01_random(const char *zero_ones, unsigned char *flags, int col, int n, int ncols)
int G_zero(void *buf, int i)
Zero out a buffer, buf, of length i.
int G_is_d_null_value(const DCELL *dcellVal)
Returns 1 if dcell is NULL, 0 otherwise. This will test if the value dcell is a NaN. Same test as in G_is_f_null_value().
int G_is_f_null_value(const FCELL *fcellVal)
Returns 1 if fcell is NULL, 0 otherwise. This will test if the value fcell is a NaN. It isn't good enough to test for a particular NaN bit pattern since the machine code may change this bit pattern to a different NaN. The test will be.
int G_insert_null_values(void *rast, char *null_row, int ncols, RASTER_MAP_TYPE data_type)
Insert NULL value.
size_t G_raster_size(RASTER_MAP_TYPE data_type)
Returns size of a raster CELL in bytes.
int G__convert_01_flags(const char *zero_ones, unsigned char *flags, int n)
int G__init_null_bits(unsigned char *flags, int cols)
int G_insert_d_null_values(DCELL *dcellVal, char *null_row, int ncols)
Insert DCELL NULL value.
int G__convert_flags_01(char *zero_ones, const unsigned char *flags, int n)
int G_insert_f_null_values(FCELL *fcellVal, char *null_row, int ncols)
Insert FCELL NULL value.
void G_set_f_null_value(FCELL *fcellVals, int numVals)
int G__null_bitstream_size(int cols)
Determines null bitstream size.
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
void G_set_null_value(void *buf, int numVals, RASTER_MAP_TYPE data_type)
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
void G_set_c_null_value(CELL *cellVals, int numVals)
int G__check_null_bit(const unsigned char *flags, int bit_num, int n)
int G_is_null_value(const void *rast, RASTER_MAP_TYPE data_type)
If the data_type is CELL_TYPE, calls G_is_c_null_value ((CELL *) rast); If the data_type is FCELL_TYP...
int G_insert_c_null_values(CELL *cellVal, char *null_row, int ncols)
Insert CELL NULL value.