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

« back to all changes in this revision

Viewing changes to raster/r.out.ppm3/main.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:
18
18
#include <stdlib.h>
19
19
 
20
20
#include <grass/gis.h>
 
21
#include <grass/raster.h>
21
22
#include <grass/glocale.h>
22
23
 
23
24
#define DEF_RED 255
42
43
    struct band B[3];
43
44
    struct GModule *module;
44
45
    struct Option *ppm_file;
45
 
 
46
 
    /* please, remove before GRASS 7 released */
47
 
    struct Flag *bequiet, *comment;
 
46
    struct Flag *comment;
48
47
    struct Cell_head w;
49
48
    FILE *fp;
50
49
    unsigned char *dummy;
51
50
    int row, col;
52
51
    int i;
 
52
    char *tmpstr1, *tmpstr2;
53
53
 
54
54
    G_gisinit(argv[0]);
55
55
 
56
56
    module = G_define_module();
57
 
    module->keywords = _("raster");
58
 
    module->description =
59
 
        _("Converts 3 GRASS raster layers (R,G,B) to a PPM image file "
60
 
          "at the pixel resolution of the CURRENTLY DEFINED REGION.");
 
57
    G_add_keyword(_("raster"));
 
58
    G_add_keyword(_("export"));
 
59
    module->description = _("Converts 3 GRASS raster layers (R,G,B) to a PPM image file.");
61
60
 
62
61
    for (i = 0; i < 3; i++) {
63
62
        char buff[80];
82
81
    ppm_file->multiple = NO;
83
82
    ppm_file->answer = NULL;
84
83
    ppm_file->description =
85
 
        _("Name for new PPM file. (use out=- for stdout)");
86
 
 
87
 
    /* please, remove before GRASS 7 released */
88
 
    bequiet = G_define_flag();
89
 
    bequiet->key = 'q';
90
 
    bequiet->description = _("Run quietly");
 
84
        _("Name for new PPM file. (use '-' for stdout)");
91
85
 
92
86
    comment = G_define_flag();
93
87
    comment->key = 'c';
96
90
    if (G_parser(argc, argv))
97
91
        exit(EXIT_FAILURE);
98
92
 
99
 
    /* please, remove before GRASS 7 released */
100
 
    if (bequiet->answer) {
101
 
        putenv("GRASS_VERBOSE=0");
102
 
        G_warning(_("The '-q' flag is superseded and will be removed "
103
 
                    "in future. Please use '--quiet' instead."));
104
 
    }
105
 
 
106
 
 
107
93
    G_get_window(&w);
108
94
 
109
 
    G_message(_("rows = %d, cols = %d"), w.rows, w.cols);
 
95
    G_asprintf(&tmpstr1, _n("row = %d", "rows = %d", w.rows), w.rows);
 
96
    /* GTC Raster columns */
 
97
    G_asprintf(&tmpstr2, _n("column = %d", "columns = %d", w.cols), w.cols);
 
98
    G_message("%s, %s", tmpstr1, tmpstr2);
 
99
    G_free(tmpstr1);
 
100
    G_free(tmpstr2); 
110
101
 
111
102
    /* open raster map for reading */
112
103
    for (i = 0; i < 3; i++) {
113
104
        /* Get name of layer */
114
105
        char *name = B[i].opt->answer;
115
 
        char *mapset;
116
 
 
117
 
        /* Get mapset of layer */
118
 
        mapset = G_find_cell2(name, "");
119
 
        if (!mapset)
120
 
            G_fatal_error(_("Raster map <%s> not found"), name);
121
106
 
122
107
        /* Open raster map */
123
 
        if ((B[i].file = G_open_cell_old(name, mapset)) == -1)
124
 
            G_fatal_error(_("Unable to open raster map <%s>"), name);
 
108
        B[i].file = Rast_open_old(name, "");
125
109
 
126
110
        /* Get map type (CELL/FCELL/DCELL) */
127
 
        B[i].type = G_get_raster_map_type(B[i].file);
 
111
        B[i].type = Rast_get_map_type(B[i].file);
128
112
 
129
113
        /* Get color table */
130
 
        if (G_read_colors(name, mapset, &B[i].colors) == -1)
 
114
        if (Rast_read_colors(name, "", &B[i].colors) == -1)
131
115
            G_fatal_error(_("Color file for <%s> not available"), name);
132
116
 
133
117
        /* Allocate input buffer */
134
 
        B[i].array = G_allocate_raster_buf(B[i].type);
 
118
        B[i].array = Rast_allocate_buf(B[i].type);
135
119
 
136
120
        /* Allocate output buffers */
137
121
        B[i].buf = (unsigned char *)G_malloc(w.cols);
179
163
        G_percent(row, w.rows, 5);
180
164
 
181
165
        for (i = 0; i < 3; i++) {
182
 
            if (G_get_raster_row(B[i].file, B[i].array, row, B[i].type) < 0)
183
 
                G_fatal_error("G_get_raster_row failed");
 
166
            Rast_get_row(B[i].file, B[i].array, row, B[i].type);
184
167
 
185
 
            G_lookup_raster_colors(B[i].array,
 
168
            Rast_lookup_colors(B[i].array,
186
169
                                   (i == 0) ? B[i].buf : dummy,
187
170
                                   (i == 1) ? B[i].buf : dummy,
188
171
                                   (i == 2) ? B[i].buf : dummy,
207
190
    fclose(fp);
208
191
 
209
192
    for (i = 0; i < 3; i++) {
210
 
        G_free_colors(&B[i].colors);
 
193
        Rast_free_colors(&B[i].colors);
211
194
        G_free(B[i].array);
212
195
        G_free(B[i].buf);
213
196
        G_free(B[i].mask);
214
 
        G_close_cell(B[i].file);
 
197
        Rast_close(B[i].file);
215
198
    }
216
199
 
217
200
    exit(EXIT_SUCCESS);