21 #include "grass/N_pde.h"
22 #include "grass/glocale.h"
52 struct Cell_head region;
75 if (type == DCELL_TYPE) {
78 if (type == FCELL_TYPE) {
81 if (type == CELL_TYPE) {
87 if (data->cols != cols)
89 (
"N_read_rast_to_array_2d: the data array size is different from the current region settings");
90 if (data->rows != rows)
92 (
"N_read_rast_to_array_2d: the data array size is different from the current region settings");
97 G_message(_(
"Reading raster map <%s> into memory"), name);
99 for (y = 0; y < rows; y++) {
107 for (x = 0, ptr = rast; x <
cols;
109 if (type == CELL_TYPE) {
114 if (data->type == CELL_TYPE)
116 (CELL) * (CELL *) ptr);
117 if (data->type == FCELL_TYPE)
119 (FCELL) * (CELL *) ptr);
120 if (data->type == DCELL_TYPE)
122 (DCELL) * (CELL *) ptr);
125 if (type == FCELL_TYPE) {
130 if (data->type == CELL_TYPE)
132 (CELL) * (FCELL *) ptr);
133 if (data->type == FCELL_TYPE)
135 (FCELL) * (FCELL *) ptr);
136 if (data->type == DCELL_TYPE)
138 (DCELL) * (FCELL *) ptr);
141 if (type == DCELL_TYPE) {
146 if (data->type == CELL_TYPE)
148 (CELL) * (DCELL *) ptr);
149 if (data->type == FCELL_TYPE)
151 (FCELL) * (DCELL *) ptr);
152 if (data->type == DCELL_TYPE)
154 (DCELL) * (DCELL *) ptr);
188 struct Cell_head region;
205 if (type == CELL_TYPE)
207 if (type == FCELL_TYPE)
209 if (type == DCELL_TYPE)
212 G_message(_(
"Write 2d array to raster map <%s>"), name);
215 for (y = 0; y < rows; y++) {
217 for (x = 0; x <
cols; x++) {
218 if (type == CELL_TYPE)
220 if (type == FCELL_TYPE)
222 if (type == DCELL_TYPE)
225 if (type == CELL_TYPE)
230 if (type == FCELL_TYPE)
235 if (type == DCELL_TYPE)
282 double d1 = 0, f1 = 0;
292 depths = region.depths;
301 G3D_TILE_SAME_AS_FILE, G3D_USE_CACHE_DEFAULT);
311 if (type == FCELL_TYPE) {
314 if (type == DCELL_TYPE) {
320 if (data->
cols != cols)
322 (
"N_read_rast_to_array_3d: the data array size is different from the current region settings");
323 if (data->
rows != rows)
325 (
"N_read_rast_to_array_3d: the data array size is different from the current region settings");
326 if (data->
depths != depths)
328 (
"N_read_rast_to_array_3d: the data array size is different from the current region settings");
332 G_message(_(
"Read g3d map <%s> into the memory"), name);
345 for (z = 0; z < depths; z++) {
347 for (y = 0; y < rows; y++) {
348 for (x = 0; x <
cols; x++) {
349 if (type == FCELL_TYPE) {
355 if (data->
type == FCELL_TYPE)
357 if (data->
type == DCELL_TYPE)
367 if (data->
type == FCELL_TYPE)
369 if (data->
type == DCELL_TYPE)
413 double d1 = 0.0, f1 = 0.0;
423 depths = region.depths;
427 if (data->
cols != cols)
429 (
"N_write_array_3d_to_rast3d: the data array size is different from the current region settings");
430 if (data->
rows != rows)
432 (
"N_write_array_3d_to_rast3d: the data array size is different from the current region settings");
433 if (data->
depths != depths)
435 (
"N_write_array_3d_to_rast3d: the data array size is different from the current region settings");
438 if (type == DCELL_TYPE)
441 else if (type == FCELL_TYPE)
448 G_message(_(
"Write 3d array to g3d map <%s>"), name);
462 for (z = 0; z < depths; z++) {
464 for (y = 0; y < rows; y++) {
465 for (x = 0; x <
cols; x++) {
466 if (type == FCELL_TYPE) {
470 else if (type == DCELL_TYPE) {
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 G3d_maskOff(G3D_Map *map)
Turns off the mask for map. This is the default. Do not invoke this function after the first tile has...
int G_get_set_window(struct Cell_head *window)
Get the current working window.
int G_close_cell(int fd)
close a raster map
N_array_2d * N_read_rast_to_array_2d(char *name, N_array_2d *array)
Read a raster map into a N_array_2d structure.
int G_open_cell_old(const char *name, const char *mapset)
Open an existing integer raster map (cell)
int G_get_raster_row(int fd, void *buf, int row, RASTER_MAP_TYPE data_type)
Get raster row.
void N_put_array_3d_value_null(N_array_3d *data, int col, int row, int depth)
This function writes a null value to the N_array_3d data at position col, row, depth.
FCELL N_get_array_2d_f_value(N_array_2d *data, int col, int row)
Returns the value of type FCELL at position col, row.
void N_put_array_2d_d_value(N_array_2d *data, int col, int row, DCELL value)
Writes a DCELL value to the N_array_2d struct at position col, row.
void N_put_array_2d_f_value(N_array_2d *data, int col, int row, FCELL value)
Writes a FCELL value to the N_array_2d struct at position col, row.
RASTER_MAP_TYPE G_get_raster_map_type(int fd)
Determine raster type from descriptor.
void G3d_getValue(G3D_Map *map, int x, int y, int z, void *value, int type)
Returns in *value the cell-value of the cell with window-coordinate (x, y, z). The value returned is ...
N_array_2d * N_alloc_array_2d(int cols, int rows, int offset, int type)
Allocate memory for a N_array_2d data structure.
void * G_incr_void_ptr(const void *ptr, const size_t size)
Advance void pointer.
N_array_3d * N_alloc_array_3d(int cols, int rows, int depths, int offset, int type)
Allocate memory for a N_array_3d data structure.
void G3d_maskOn(G3D_Map *map)
Turns on the mask for map. Do not invoke this function after the first tile has been read since the r...
void G3d_getWindow(G3D_Region *window)
Stores the current default window in window.
int G_percent(long n, long d, int s)
Print percent complete messages.
char * G_find_cell2(const char *name, const char *mapset)
find a raster map (look but don't touch)
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().
void G_message(const char *msg,...)
Print a message to stderr.
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.
size_t G_raster_size(RASTER_MAP_TYPE data_type)
Returns size of a raster CELL in bytes.
int G_unopen_cell(int fd)
unopen a raster map
int G3d_maskIsOff(G3D_Map *map)
Returns 1 if the mask for map is turned off. Returns 0 otherwise.
int G_put_d_raster_row(int fd, const DCELL *buf)
void N_put_array_2d_value_null(N_array_2d *data, int col, int row)
Writes the null value to the N_array_2d struct at position col, row.
void N_put_array_2d_c_value(N_array_2d *data, int col, int row, CELL value)
Writes a CELL value to the N_array_2d struct at position col, row.
float N_get_array_3d_f_value(N_array_3d *data, int col, int row, int depth)
This function returns the value of type float at position col, row, depth.
N_array_3d * N_read_rast3d_to_array_3d(char *name, N_array_3d *array, int mask)
Read a volume map into a N_array_3d structure.
void * G_allocate_raster_buf(RASTER_MAP_TYPE data_type)
Allocate memory for a raster map of type data_type.
int G3d_closeCell(G3D_Map *map)
Closes g3d-file. If map is new and cache-mode is used for map then every tile which is not flushed be...
void N_put_array_3d_f_value(N_array_3d *data, int col, int row, int depth, float value)
This function writes a float value to the N_array_3d data at position col, row, depth.
int G3d_putDouble()
Is equivalent to G3d_putValue (map, x, y, z, &value, DCELL_TYPE).
int G3d_maskIsOn(G3D_Map *map)
Returns 1 if the mask for map is turned on. Returns 0 otherwise.
void N_write_array_3d_to_rast3d(N_array_3d *array, char *name, int mask)
Write a N_array_3d struct to a volume map.
double N_get_array_3d_d_value(N_array_3d *data, int col, int row, int depth)
This function returns the value of type float at position col, row, depth.
void * G3d_openCellOld(const char *name, const char *mapset, G3D_Region *window, int typeIntern, int cache)
Opens existing g3d-file name in mapset. Tiles are stored in memory with type which must be any of FCE...
DCELL N_get_array_2d_d_value(N_array_2d *data, int col, int row)
Returns the value of type DCELL at position col, row.
void N_write_array_2d_to_rast(N_array_2d *array, char *name)
Write a N_array_2d struct to a raster map.
void N_put_array_3d_d_value(N_array_3d *data, int col, int row, int depth, double value)
Writes a double value to the N_array_3d struct at position col, row, depth.
int G3d_maskFileExists()
Returns 1 if the 3d mask file exists.
CELL N_get_array_2d_c_value(N_array_2d *data, int col, int row)
Returns the value of type CELL at position col, row.
char * G_find_grid3(const char *name, const char *mapset)
int G3d_putFloat(G3D_Map *map, int x, int y, int z, float value)
Is equivalent to G3d_putValue (map, x, y, z, &value, FCELL_TYPE).
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
void G3d_fatalError(const char *,...)
This function prints the error message msg, and terminates the program with an error status...
int G_put_c_raster_row(int fd, const CELL *buf)
int G_open_raster_new(const char *name, RASTER_MAP_TYPE wr_type)
Opens a new raster map.
void * G3d_openCellNew(const char *name, int typeIntern, int cache, G3D_Region *region)
Opens new g3d-file with name in the current mapset. Tiles are stored in memory with type which must b...
int G_put_f_raster_row(int fd, const FCELL *buf)