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

« back to all changes in this revision

Viewing changes to raster/r.recode/main.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
 
1
2
/****************************************************************************
2
3
 *
3
4
 * MODULE:       r.recode
12
13
 *               comes with GRASS for details.
13
14
 *
14
15
 *****************************************************************************/
15
 
#define MAIN
 
16
 
16
17
#include <stdio.h>
17
18
#include <stdlib.h>
18
19
#include <string.h>
21
22
#include <grass/glocale.h>
22
23
#include "global.h"
23
24
 
 
25
RASTER_MAP_TYPE in_type;
 
26
RASTER_MAP_TYPE out_type;
 
27
struct FPReclass rcl_struct;
 
28
CELL old_min, old_max;
 
29
DCELL old_dmin, old_dmax;
 
30
int in_fd, out_fd, no_mask, align_wind, make_dcell, nrules, rule_size;
 
31
char *name, *result, *title;
 
32
char **rules;
 
33
 
24
34
int main(int argc, char *argv[])
25
35
{
26
36
    char *title;
32
42
        struct Flag *a, *d;
33
43
    } parm;
34
44
 
35
 
    /* any interaction must run in a term window */
36
 
    G_putenv("GRASS_UI_TERM", "1");
37
 
 
38
45
    G_gisinit(argv[0]);
39
46
 
40
47
    module = G_define_module();
41
 
    module->keywords = _("raster, recode category");
 
48
    G_add_keyword(_("raster"));
 
49
    G_add_keyword(_("recode categories"));
42
50
    module->description = _("Recodes categorical raster maps.");
43
51
 
44
52
    parm.input = G_define_standard_option(G_OPT_R_INPUT);
48
56
 
49
57
    parm.rules = G_define_standard_option(G_OPT_F_INPUT);
50
58
    parm.rules->key = "rules";
51
 
    parm.rules->required = NO;
52
59
    parm.rules->label = _("File containing recode rules");
53
 
    parm.rules->description = _("\"-\" to read from stdin");
54
 
    parm.rules->guisection = _("Required");
 
60
    parm.rules->description = _("'-' for standard input");
55
61
    
56
62
    parm.title = G_define_option();
57
63
    parm.title->key = "title";
76
82
    align_wind = parm.a->answer;
77
83
    make_dcell = parm.d->answer;
78
84
 
79
 
    mapset = G_find_cell2(name, "");
80
 
    if (mapset == NULL)
81
 
        G_fatal_error(_("Raster map <%s> not found"), name);
82
 
 
83
 
    if (G_legal_filename(result) < 0)
84
 
        G_fatal_error(_("<%s> is an illegal file name"), result);
85
 
 
86
 
    if (strcmp(name, result) == 0 && strcmp(mapset, G_mapset()) == 0)
87
 
        G_fatal_error(_("Input map can NOT be the same as output map"));
88
 
 
89
85
    srcfp = stdin;
90
 
    if (parm.rules->answer && strcmp("-", parm.rules->answer) != 0) {
 
86
    if (strcmp(parm.rules->answer, "-") != 0) {
91
87
        srcfp = fopen(parm.rules->answer, "r");
92
88
        if (!srcfp)
93
89
            G_fatal_error(_("Unable to open file <%s>"),
107
103
    do_recode();
108
104
 
109
105
    if(title)
110
 
        G_put_cell_title(result, title);
111
 
 
112
 
    G_done_msg(_("Raster map <%s> created."),
113
 
               result);
 
106
        Rast_put_cell_title(result, title);
114
107
 
115
108
    exit(EXIT_SUCCESS);
116
109
}