~ubuntu-branches/ubuntu/wily/grass/wily

« back to all changes in this revision

Viewing changes to raster/r.watershed/seg/cseg_write.c

Tags: 7.0.0~rc1+ds1-1~exp1
* New upstream release candidate.
* Repack upstream tarball, remove precompiled Python objects.
* Add upstream metadata.
* Update gbp.conf and Vcs-Git URL to use the experimental branch.
* Update watch file for GRASS 7.0.
* Drop build dependencies for Tcl/Tk, add build dependencies:
  python-numpy, libnetcdf-dev, netcdf-bin, libblas-dev, liblapack-dev
* Update Vcs-Browser URL to use cgit instead of gitweb.
* Update paths to use grass70.
* Add configure options: --with-netcdf, --with-blas, --with-lapack,
  remove --with-tcltk-includes.
* Update patches for GRASS 7.
* Update copyright file, changes:
  - Update copyright years
  - Group files by license
  - Remove unused license sections
* Add patches for various typos.
* Fix desktop file with patch instead of d/rules.
* Use minimal dh rules.
* Bump Standards-Version to 3.9.6, no changes.
* Use dpkg-maintscript-helper to replace directories with symlinks.
  (closes: #776349)
* Update my email to use @debian.org address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include <grass/gis.h>
 
2
#include <grass/raster.h>
2
3
#include <grass/segment.h>
3
 
#include "cseg.h"
4
 
 
5
 
static char *me = "cseg_write_cell";
 
4
#include "Gwater.h"
6
5
 
7
6
int cseg_write_cellfile(CSEG * cseg, char *map_name)
8
7
{
9
8
    int map_fd;
10
 
    int row, nrows;
 
9
    GW_LARGE_INT row, nrows;
11
10
    CELL *buffer;
12
11
 
13
 
    map_fd = G_open_cell_new(map_name);
14
 
    if (map_fd < 0) {
15
 
        G_warning("%s(): unable to open new map layer [%s]", me, map_name);
16
 
        return -1;
17
 
    }
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) {
24
 
            G_free(buffer);
25
 
            G_unopen_cell(map_fd);
26
 
            G_warning("%s(): unable to write new map layer [%s], row %d",
27
 
                      me, map_name, row);
28
 
            return -2;
29
 
        }
 
17
        G_percent(row, nrows, 1);
 
18
        Segment_get_row(&(cseg->seg), buffer, row);
 
19
        Rast_put_row(map_fd, buffer, CELL_TYPE);
30
20
    }
 
21
    G_percent(row, nrows, 1);    /* finish it */
31
22
    G_free(buffer);
32
 
    G_close_cell(map_fd);
 
23
    Rast_close(map_fd);
33
24
    return 0;
34
25
}