1
1
#include <grass/gis.h>
2
#include <grass/raster.h>
2
3
#include <grass/segment.h>
5
static char *me = "cseg_write_cell";
7
6
int cseg_write_cellfile(CSEG * cseg, char *map_name)
9
GW_LARGE_INT row, nrows;
13
map_fd = G_open_cell_new(map_name);
15
G_warning("%s(): unable to open new map layer [%s]", me, map_name);
18
nrows = G_window_rows();
19
buffer = G_allocate_cell_buf();
20
segment_flush(&(cseg->seg));
12
map_fd = Rast_open_c_new(map_name);
13
nrows = Rast_window_rows();
14
buffer = Rast_allocate_c_buf();
15
Segment_flush(&(cseg->seg));
21
16
for (row = 0; row < nrows; row++) {
22
segment_get_row(&(cseg->seg), buffer, row);
23
if (G_put_raster_row(map_fd, buffer, CELL_TYPE) < 0) {
25
G_unopen_cell(map_fd);
26
G_warning("%s(): unable to write new map layer [%s], row %d",
17
G_percent(row, nrows, 1);
18
Segment_get_row(&(cseg->seg), buffer, row);
19
Rast_put_row(map_fd, buffer, CELL_TYPE);
21
G_percent(row, nrows, 1); /* finish it */