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

« back to all changes in this revision

Viewing changes to raster3d/r3.support/check.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
#include <grass/raster.h>
 
4
#include <grass/raster3d.h>
 
5
#include <grass/glocale.h>
 
6
#include "local_proto.h"
 
7
 
 
8
 
 
9
/*
 
10
 * check_stats() - Check and update statistics 
 
11
 *
 
12
 * RETURN: EXIT_SUCCESS / EXIT_FAILURE
 
13
 */
 
14
int check_stats(const char *name)
 
15
{
 
16
    struct Categories cats;
 
17
    struct FPRange fprange;
 
18
    int cats_ok;
 
19
 
 
20
    G_message(_("Updating statistics for <%s>"), name);
 
21
    
 
22
    /* Get category status and max */
 
23
    cats_ok = (Rast3d_read_cats(name, "", &cats) >= 0);
 
24
    Rast3d_read_range(name, "", &fprange);
 
25
 
 
26
    /* Further category checks */
 
27
    if (!cats_ok)
 
28
        Rast_init_cats("", &cats);
 
29
    else if (cats.num != fprange.max) {
 
30
        cats.num = fprange.max;
 
31
        cats_ok = 0;
 
32
    }
 
33
 
 
34
    /* Update categories if needed */
 
35
    if (!cats_ok) {
 
36
        G_message(_("Updating the number of categories for <%s>"), name);
 
37
        Rast3d_write_cats(name, &cats);
 
38
    }
 
39
    Rast_free_cats(&cats);
 
40
 
 
41
    return 0;
 
42
}