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

« back to all changes in this revision

Viewing changes to raster/r.reclass/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:
7
7
 *               Hamish Bowman <hamish_b yahoo.com>, Jan-Oliver Wagner <jan intevation.de>,
8
8
 *               Markus Neteler <neteler itc.it>
9
9
 * PURPOSE:      
10
 
 * COPYRIGHT:    (C) 1999-2013 by the GRASS Development Team
 
10
 * COPYRIGHT:    (C) 1999-2006, 2010 by the GRASS Development Team
11
11
 *
12
12
 *               This program is free software under the GNU General Public
13
13
 *               License (>=v2). Read the file COPYING that comes with GRASS
19
19
#include <string.h>
20
20
#include <unistd.h>
21
21
#include <grass/gis.h>
 
22
#include <grass/raster.h>
22
23
#include <grass/glocale.h>
23
24
#include "rule.h"
24
25
 
31
32
    char buf[1024];
32
33
    RULE *rules, *tail;
33
34
    int any;
34
 
    char *old_mapset;
 
35
    const char *old_mapset;
35
36
    FILE *srcfp;
36
37
    int tty;
37
38
    struct GModule *module;
46
47
    G_gisinit(argv[0]);
47
48
 
48
49
    module = G_define_module();
49
 
    module->keywords = _("raster, reclassification");
 
50
    G_add_keyword(_("raster"));
 
51
    G_add_keyword(_("reclassification"));
50
52
    module->label = _("Reclassify raster map based on category values.");
51
53
    module->description =
52
54
        _("Creates a new raster map whose category values are based "
53
55
          "upon a reclassification of the categories in an existing "
54
56
          "raster map.");
55
 
    
 
57
 
56
58
    parm.input = G_define_standard_option(G_OPT_R_INPUT);
57
 
    parm.input->description = _("Raster map to be reclassified");
58
 
 
 
59
    parm.input->description = _("Name of raster map to be reclassified");
 
60
    
59
61
    parm.output = G_define_standard_option(G_OPT_R_OUTPUT);
60
 
 
 
62
    
61
63
    parm.rules = G_define_standard_option(G_OPT_F_INPUT);
62
64
    parm.rules->key = "rules";
63
65
    parm.rules->label = _("File containing reclass rules");
64
 
    parm.rules->description = _("\"-\" to read from stdin");
65
 
    parm.rules->required = NO;
66
 
    parm.rules->guisection = _("Required");
67
 
 
 
66
    parm.rules->description = _("'-' for standard input");
 
67
    
68
68
    parm.title = G_define_option();
69
69
    parm.title->key = "title";
70
70
    parm.title->required = NO;
71
71
    parm.title->type = TYPE_STRING;
72
 
    parm.title->description = _("Title for the resulting raster map");
 
72
    parm.title->description = _("Title for output raster map");
73
73
 
74
74
    if (G_parser(argc, argv))
75
75
        exit(EXIT_FAILURE);
76
76
 
77
 
    old_mapset = G_find_cell2(parm.input->answer, "");
 
77
    old_mapset = G_find_raster2(parm.input->answer, "");
78
78
    if (old_mapset == NULL)
79
79
        G_fatal_error(_("Raster map <%s> not found"), parm.input->answer);
80
80
 
81
 
    if (G_legal_filename(parm.output->answer) < 0)
82
 
        G_fatal_error(_("<%s> is an illegal file name"), parm.output->answer);
83
 
 
84
81
    if (strcmp(parm.input->answer, parm.output->answer) == 0 &&
85
82
        strcmp(old_mapset, G_mapset()) == 0)
86
83
        G_fatal_error(_("Input map can NOT be the same as output map"));
87
84
 
88
85
    srcfp = stdin;
89
 
    if (parm.rules->answer && strcmp("-", parm.rules->answer) != 0) {
 
86
    if (strcmp(parm.rules->answer, "-") != 0) {
90
87
        srcfp = fopen(parm.rules->answer, "r");
91
88
        if (!srcfp)
92
89
            G_fatal_error(_("Cannot open rules file <%s>"),
94
91
    }
95
92
    tty = isatty(fileno(srcfp));
96
93
 
97
 
    G_init_cats(0, "", &cats);
98
 
    map_type = G_raster_map_type(parm.input->answer, old_mapset);
99
 
    G_read_fp_range(parm.input->answer, old_mapset, &range);
100
 
    G_get_fp_range_min_max(&range, &min, &max);
 
94
    Rast_init_cats("", &cats);
 
95
    map_type = Rast_map_type(parm.input->answer, old_mapset);
 
96
    Rast_read_fp_range(parm.input->answer, old_mapset, &range);
 
97
    Rast_get_fp_range_min_max(&range, &min, &max);
101
98
    rules = tail = NULL;
102
99
    any = 0;
103
100
 
104
101
    if (tty) {
105
 
        fprintf(stdout,
 
102
        fprintf(stderr,
106
103
                _("Enter rule(s), \"end\" when done, \"help\" if you need it\n"));
107
104
        if (map_type == FCELL_TYPE)
108
 
            fprintf(stdout, _("FCELL: Data range is %.7g to %.7g\n"),
 
105
            fprintf(stderr, _("FCELL: Data range is %.7g to %.7g\n"),
109
106
                    (double)min, (double)max);
110
107
        else if (map_type == DCELL_TYPE)
111
 
            fprintf(stdout, _("DCELL: Data range is %.15g to %.15g\n"),
112
 
                    (double)min, (double)max);
 
108
            fprintf(stderr, _("DCELL: Data range is %.15g to %.15g\n"),
 
109
                    (double)min, (double)max);
113
110
        else
114
 
            fprintf(stdout, _("CELL: Data range is %ld to %ld\n"), (long)min,
 
111
            fprintf(stderr, _("CELL: Data range is %ld to %ld\n"), (long)min,
115
112
                    (long)max);
116
113
    }
117
114