~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to raster/r.support/front/histo.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <stdlib.h>
2
 
#include <grass/gis.h>
3
 
 
4
 
 
5
 
/* 
6
 
 * do_histogram() - Creates histogram for CELL
7
 
 *
8
 
 * RETURN: EXIT_SUCCESS / EXIT_FAILURE
9
 
 */
10
 
int do_histogram(char *name, char *mapset)
11
 
{
12
 
    CELL *cell;
13
 
    struct Cell_head cellhd;
14
 
    struct Cell_stats statf;
15
 
    int nrows, ncols;
16
 
    int row;
17
 
    int fd;
18
 
 
19
 
    if (G_get_cellhd(name, mapset, &cellhd) < 0)
20
 
        return EXIT_FAILURE;
21
 
 
22
 
    G_set_window(&cellhd);
23
 
    if ((fd = G_open_cell_old(name, mapset)) < 0)
24
 
        return EXIT_FAILURE;
25
 
 
26
 
    nrows = G_window_rows();
27
 
    ncols = G_window_cols();
28
 
    cell = G_allocate_cell_buf();
29
 
 
30
 
    G_init_cell_stats(&statf);
31
 
    for (row = 0; row < nrows; row++) {
32
 
        if (G_get_map_row_nomask(fd, cell, row) < 0)
33
 
            break;
34
 
 
35
 
        G_update_cell_stats(cell, ncols, &statf);
36
 
    }
37
 
 
38
 
    if (row == nrows)
39
 
        G_write_histogram_cs(name, &statf);
40
 
 
41
 
    G_free_cell_stats(&statf);
42
 
    G_close_cell(fd);
43
 
    G_free(cell);
44
 
 
45
 
    if (row == nrows)
46
 
        return EXIT_SUCCESS;
47
 
 
48
 
    return EXIT_FAILURE;
49
 
}