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

« back to all changes in this revision

Viewing changes to vector/v.digit/cat.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
 
/* ***************************************************************
2
 
 * *
3
 
 * * MODULE:       v.digit
4
 
 * * 
5
 
 * * AUTHOR(S):    Radim Blazek
6
 
 * *               
7
 
 * * PURPOSE:      Edit vector
8
 
 * *              
9
 
 * * COPYRIGHT:    (C) 2001 by the GRASS Development Team
10
 
 * *
11
 
 * *               This program is free software under the 
12
 
 * *               GNU General Public License (>=v2). 
13
 
 * *               Read the file COPYING that comes with GRASS
14
 
 * *               for details.
15
 
 * *
16
 
 * **************************************************************/
17
 
#include <stdio.h>
18
 
#include <stdlib.h>
19
 
#include <string.h>
20
 
#include <grass/gis.h>
21
 
#include <grass/colors.h>
22
 
#include <grass/raster.h>
23
 
#include <grass/display.h>
24
 
#include "global.h"
25
 
#include "proto.h"
26
 
 
27
 
 
28
 
/* Init cats */
29
 
void cat_init(void)
30
 
{
31
 
    int i, line, nlines;
32
 
    struct line_cats *Cats;
33
 
 
34
 
    G_debug(2, "cat_init()");
35
 
    Cats = Vect_new_cats_struct();
36
 
 
37
 
    /* Max cats */
38
 
    nMaxFieldCat = 0;
39
 
    aMaxFieldCat = 10;          /* allocated space */
40
 
    MaxFieldCat = (void *)G_malloc((aMaxFieldCat) * sizeof(int) * 2);
41
 
 
42
 
    /* Read the map and set maximum categories */
43
 
    nlines = Vect_get_num_lines(&Map);
44
 
    for (line = 1; line <= nlines; line++) {
45
 
        Vect_read_line(&Map, NULL, Cats, line);
46
 
        for (i = 0; i < Cats->n_cats; i++) {
47
 
            if ((cat_max_get(Cats->field[i])) < Cats->cat[i]) {
48
 
                cat_max_set(Cats->field[i], Cats->cat[i]);
49
 
            }
50
 
        }
51
 
    }
52
 
}
53
 
 
54
 
/* get maximum cat for field */
55
 
int cat_max_get(int field)
56
 
{
57
 
    int i;
58
 
 
59
 
    G_debug(2, "cat_max_get() field = %d", field);
60
 
 
61
 
    for (i = 0; i < nMaxFieldCat; i++) {
62
 
        if (MaxFieldCat[i][0] == field) {
63
 
            return (MaxFieldCat[i][1]);
64
 
        }
65
 
    }
66
 
 
67
 
    return 0;
68
 
}
69
 
 
70
 
/* set maximum cat for field */
71
 
void cat_max_set(int field, int cat)
72
 
{
73
 
    int i;
74
 
 
75
 
    G_debug(2, "cat_max_set() field = %d cat = %d", field, cat);
76
 
 
77
 
    for (i = 0; i < nMaxFieldCat; i++) {
78
 
        if (MaxFieldCat[i][0] == field) {
79
 
            MaxFieldCat[i][1] = cat;
80
 
            return;
81
 
        }
82
 
    }
83
 
    /* Field not found -> add new */
84
 
    if (nMaxFieldCat == aMaxFieldCat) {
85
 
        aMaxFieldCat += 10;
86
 
        MaxFieldCat =
87
 
            (void *)G_realloc(MaxFieldCat, (aMaxFieldCat) * sizeof(int) * 2);
88
 
    }
89
 
    MaxFieldCat[nMaxFieldCat][0] = field;
90
 
    MaxFieldCat[nMaxFieldCat][1] = cat;
91
 
    nMaxFieldCat++;
92
 
}