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

1.3.1 by Bas Couwenberg
Import upstream version 7.0.0~rc1+ds1
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
}