2
#include <grass/glocale.h>
3
#include "local_proto.h"
6
void rdwr_gridatb(void)
14
RASTER_MAP_TYPE data_type;
16
fd = G_open_cell_old(iname, mapset);
18
G_fatal_error("%s - could not read", iname);
20
data_type = G_get_raster_map_type(fd);
23
cell = G_allocate_c_raster_buf();
26
fcell = G_allocate_f_raster_buf();
29
dcell = G_allocate_d_raster_buf();
33
G_get_cellhd(iname, mapset, &cellhd);
35
adjcellhdval = adjcellhd(&cellhd);
36
switch (adjcellhdval) {
38
G_fatal_error(_("Setting window header"));
41
G_fatal_error(_("Rows changed"));
44
G_fatal_error(_("Cols changed"));
48
fp = fopen(file, "w");
50
fprintf(fp, "%s\n", G_get_cell_title(iname, mapset));
51
fprintf(fp, "%d %d %lf\n", cellhd.cols, cellhd.rows, cellhd.ns_res);
53
for (row = 0; row < cellhd.rows; row++) {
54
G_percent(row, cellhd.rows, 2);
57
if (G_get_c_raster_row(fd, cell, row) < 0) {
62
for (col = 0; col < cellhd.cols; col++) {
63
if (G_is_c_null_value(&cell[col]))
64
fprintf(fp, " 9999.00 ");
66
fprintf(fp, "%9.2f ", (float)cell[col]);
67
if (!((col + 1) % 8) || col == cellhd.cols - 1)
72
if (G_get_f_raster_row(fd, fcell, row) < 0) {
77
for (col = 0; col < cellhd.cols; col++) {
78
if (G_is_f_null_value(&fcell[col]))
79
fprintf(fp, " 9999.00 ");
81
fprintf(fp, "%9.2f ", (float)fcell[col]);
82
if (!((col + 1) % 8) || col == cellhd.cols - 1)
87
if (G_get_d_raster_row(fd, dcell, row) < 0) {
92
for (col = 0; col < cellhd.cols; col++) {
93
if (G_is_d_null_value(&dcell[col]))
94
fprintf(fp, " 9999.00 ");
96
fprintf(fp, "%9.2lf ", (double)dcell[col]);
97
if (!((col + 1) % 8) || col == cellhd.cols - 1)