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

« back to all changes in this revision

Viewing changes to raster/r.volume/centroids.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:
17
17
 * col = sigma(col)/n.
18
18
 */
19
19
#include <grass/gis.h>
 
20
#include <grass/raster.h>
20
21
 
21
22
int centroids(int fd,           /* File descriptor of map layer to process */
22
23
              /* This file is assumed to be opened before calling */
27
28
{                               /* Highest positive cat number in map layer */
28
29
    CELL *cell_buf, v;
29
30
    int i, adjusted, numb, left, right;
30
 
    int *count;
 
31
    long int *count;
31
32
    int row, col, rows, cols;
32
33
 
33
34
    adjusted = 0;
34
35
 
35
 
    cell_buf = G_allocate_cell_buf();
 
36
    cell_buf = Rast_allocate_c_buf();
36
37
    /* space to accumulate counts */
37
 
    count = (int *)G_malloc((max + 1) * sizeof(int));
 
38
    count = (long int *)G_malloc((max + 1) * sizeof(long int));
38
39
 
39
40
    /* zero the count totals */
40
41
    for (i = 1; i <= max; i++) {
45
46
 
46
47
    /* do rows and columns through window and mask */
47
48
    /*  to do counting */
48
 
    rows = G_window_rows();
49
 
    cols = G_window_cols();
 
49
    rows = Rast_window_rows();
 
50
    cols = Rast_window_cols();
50
51
    for (row = 0; row < rows; row++) {
51
 
        G_get_map_row(fd, cell_buf, row);       /* get a row */
 
52
        Rast_get_c_row(fd, cell_buf, row);      /* get a row */
52
53
        for (col = 0; col < cols; col++) {
53
54
            v = cell_buf[col];  /* next cell value in row */
54
55
            if (v < 1)
78
79
                row = n[i];
79
80
                col = e[i];
80
81
                /* get cell at row,col */
81
 
                G_get_map_row(fd, cell_buf, row);
 
82
                Rast_get_c_row(fd, cell_buf, row);
82
83
                v = cell_buf[col];
83
84
                if (v > 0) {
84
85
                    if (v == i)
96
97
 
97
98
    /* go through map again */
98
99
    for (row = 0; row < rows; row++) {
99
 
        G_get_map_row(fd, cell_buf, row);
 
100
        Rast_get_c_row(fd, cell_buf, row);
100
101
        for (col = 0; col < cols; col++) {
101
102
            v = cell_buf[col];
102
103
            if (v < 1)