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)
281 int x, y, z,
cols, rows, depths,
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) {