32
33
void *ptr, *raster;
33
34
char cell_buf[300];
35
raster = G_allocate_raster_buf(out_type);
36
raster = Rast_allocate_buf(out_type);
37
38
for (row = 0; row < nrows; row++) {
38
39
G_percent(row, nrows, 2);
40
if (G_get_raster_row(fd, raster, row, out_type) < 0)
41
Rast_get_row(fd, raster, row, out_type);
43
43
for (col = 0, ptr = raster; col < ncols; col++,
44
ptr = G_incr_void_ptr(ptr, G_raster_size(out_type))) {
45
if (!G_is_null_value(ptr, out_type)) {
44
ptr = G_incr_void_ptr(ptr, Rast_cell_size(out_type))) {
45
if (!Rast_is_null_value(ptr, out_type)) {
46
46
if (out_type == CELL_TYPE)
47
47
fprintf(fp, "%d", *((CELL *) ptr));
85
85
int row, col, colcnt;
86
86
void *ptr, *raster;
88
raster = G_allocate_raster_buf(out_type);
88
raster = Rast_allocate_buf(out_type);
90
90
for (row = 0; row < nrows; row++) {
91
91
G_percent(row, nrows, 2);
93
if (G_get_raster_row(fd, raster, row, out_type) < 0)
93
Rast_get_row(fd, raster, row, out_type);
97
96
for (col = 0, ptr = raster; col < ncols; col++,
98
ptr = G_incr_void_ptr(ptr, G_raster_size(out_type))) {
97
ptr = G_incr_void_ptr(ptr, Rast_cell_size(out_type))) {
99
98
if (out_type == CELL_TYPE) {
100
if (G_is_null_value(ptr, out_type))
99
if (Rast_is_null_value(ptr, out_type))
101
100
*((CELL *) ptr) = 0;
102
101
fprintf(fp, " %d", *((CELL *) ptr));
104
103
else if (out_type == FCELL_TYPE) {
105
if (G_is_null_value(ptr, out_type))
104
if (Rast_is_null_value(ptr, out_type))
106
105
*((FCELL *) ptr) = 0;
107
106
fprintf(fp, "%*.*e", dp + 6, dp - 1, *((FCELL *) ptr));
109
108
else if (out_type == DCELL_TYPE) {
110
if (G_is_null_value(ptr, out_type))
109
if (Rast_is_null_value(ptr, out_type))
111
110
*((DCELL *) ptr) = 0;
112
111
fprintf(fp, "%*.*e", dp + 6, dp - 1, *((DCELL *) ptr));
128
127
/* write the Surfer grid heading */
129
int writeGSheader(FILE * fp, char *name, char *mapset)
128
int writeGSheader(FILE * fp, const char *name)
131
130
struct Cell_head region;
132
131
char fromc[128], toc[128];
133
132
struct FPRange range;
134
133
DCELL Z_MIN, Z_MAX;
136
if (G_read_fp_range(name, mapset, &range) < 0)
135
if (Rast_read_fp_range(name, "", &range) < 0)
139
138
fprintf(fp, "DSAA \n");
154
153
G_projection() == PROJECTION_LL ? -1 : 0);
155
154
fprintf(fp, "%s %s\n", fromc, toc);
157
G_get_fp_range_min_max(&range, &Z_MIN, &Z_MAX);
156
Rast_get_fp_range_min_max(&range, &Z_MIN, &Z_MAX);
158
157
fprintf(fp, "%f %f\n", (double)Z_MIN, (double)Z_MAX);
171
170
void *ptr, *raster;
172
171
char cell_buf[300];
174
raster = G_allocate_raster_buf(out_type);
173
raster = Rast_allocate_buf(out_type);
176
175
for (row = nrows - 1; row >= 0; row--) {
177
176
G_percent((row - nrows) * (-1), nrows, 2);
179
if (G_get_raster_row(fd, raster, row, out_type) < 0)
178
Rast_get_row(fd, raster, row, out_type);
183
181
for (col = 0, ptr = raster; col < ncols; col++,
184
ptr = G_incr_void_ptr(ptr, G_raster_size(out_type))) {
182
ptr = G_incr_void_ptr(ptr, Rast_cell_size(out_type))) {
186
if (!G_is_null_value(ptr, out_type)) {
184
if (!Rast_is_null_value(ptr, out_type)) {
187
185
if (out_type == CELL_TYPE)
188
186
fprintf(fp, "%d", *((CELL *) ptr));
189
187
else if (out_type == FCELL_TYPE) {