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

« back to all changes in this revision

Viewing changes to raster/r.reclass/stats.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 "rule.h"
3
4
 
4
5
#define LIST struct Histogram_list
5
6
 
6
 
void new_stats(char *name, struct Reclass *reclass)
 
7
void new_stats(const char *name, struct Reclass *reclass)
7
8
{
8
9
    struct Histogram histo, histo2;
9
10
    struct Range range;
16
17
 
17
18
    /* read histogram for original file */
18
19
    G_suppress_warnings(1);
19
 
    i = G_read_histogram(reclass->name, reclass->mapset, &histo);
 
20
    i = Rast_read_histogram(reclass->name, reclass->mapset, &histo);
20
21
    G_suppress_warnings(0);
21
22
    if (i <= 0)
22
23
        return;
23
24
 
24
25
    /* compute data rage for reclass */
25
 
    G_init_range(&range);
 
26
    Rast_init_range(&range);
26
27
 
27
28
    for (i = 0; i < histo.num; i++) {
28
29
        cat = histo.list[i].cat;
29
30
        if (cat < min || cat > max)
30
31
            continue;
31
32
        cat2 = reclass->table[cat - min];
32
 
        G_update_range(cat2, &range);
 
33
        Rast_update_range(cat2, &range);
33
34
    }
34
 
    G_write_range(name, &range);
 
35
    Rast_write_range(name, &range);
35
36
 
36
37
    /* now generate a histogram from the original */
37
38
 
51
52
    for (i = 0; i < histo.num; i++) {
52
53
        cat = histo.list[i].cat;
53
54
        if (cat < min || cat > max)
54
 
            G_set_c_null_value(&cat, 1);
 
55
            Rast_set_c_null_value(&cat, 1);
55
56
        else
56
57
            cat2 = reclass->table[cat - min];
57
 
        if (!G_is_c_null_value(&cat))
 
58
        if (!Rast_is_c_null_value(&cat))
58
59
            histo2.list[cat2 - range.min].count += histo.list[i].count;
59
60
    }
60
 
    G_write_histogram(name, &histo2);
 
61
    Rast_write_histogram(name, &histo2);
61
62
}