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

« back to all changes in this revision

Viewing changes to raster/r.digit/get_label.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
 
 *
4
 
 * MODULE:       r.digit
5
 
 *
6
 
 * AUTHOR(S):    Michael Shapiro - CERL
7
 
 *
8
 
 * PURPOSE:      Interactive tool used to draw and save vector features
9
 
 *               on a graphics monitor using a pointing device (mouse)
10
 
 *               and save to a raster map.
11
 
 *
12
 
 * COPYRIGHT:    (C) 2006 by the GRASS Development Team
13
 
 *
14
 
 *               This program is free software under the GNU General Public
15
 
 *               License (>=v2). Read the file COPYING that comes with GRASS
16
 
 *               for details.
17
 
 *
18
 
 ***************************************************************************/
19
 
 
20
 
#include <grass/gis.h>
21
 
#include <grass/raster.h>
22
 
#include <grass/glocale.h>
23
 
 
24
 
 
25
 
long get_cat(char *type)
26
 
{
27
 
    char buffer[256];
28
 
    long cat;
29
 
 
30
 
    for (;;) {
31
 
        fprintf(stdout, _("Enter the category number for this %s: "), type);
32
 
        if (!G_gets(buffer))
33
 
            continue;;
34
 
        if (sscanf(buffer, "%ld", &cat) != 1)
35
 
            continue;
36
 
        break;
37
 
    }
38
 
    return cat;
39
 
}
40
 
 
41
 
char *get_label(long cat, struct Categories *labels)
42
 
{
43
 
    static char buffer[1024];
44
 
 
45
 
    for (;;) {
46
 
        fprintf(stdout, _("Enter a label for category %ld [%s] "),
47
 
                cat, G_get_cat((CELL) cat, labels));
48
 
        if (!G_gets(buffer))
49
 
            continue;;
50
 
        G_strip(buffer);
51
 
        break;
52
 
    }
53
 
    return buffer;
54
 
}
55
 
 
56
 
int get_category(FILE * fd, char *type, struct Categories *labels)
57
 
{
58
 
    long cat;
59
 
    char *lbl;
60
 
 
61
 
    R_stabilize();              /* force out all graphics */
62
 
    do {
63
 
        fprintf(stdout, "\n");
64
 
        cat = get_cat(type);
65
 
        lbl = get_label(cat, labels);
66
 
        fprintf(stdout, "%ld [%s]\n", cat,
67
 
                *lbl ? lbl : G_get_cat((CELL) cat, labels));
68
 
    } while (!G_yes(_("Look ok? "), 1));
69
 
    if (*lbl)
70
 
        G_set_cat((CELL) cat, lbl, labels);
71
 
 
72
 
    fprintf(fd, "= %ld %s\n", cat, lbl);
73
 
    return (0);
74
 
}