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

« back to all changes in this revision

Viewing changes to imagery/i.smap/write_img.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
#include <grass/raster.h>
 
2
#include <grass/imagery.h>
 
3
#include <grass/glocale.h>
 
4
 
 
5
#include "bouman.h"
 
6
 
 
7
int write_img(unsigned char **img, float **goodness, int ncols, int nrows,
 
8
              struct SigSet *S, /* class parameters */
 
9
              struct parms *parms,      /* parms: command line parameters */
 
10
              struct files *files)
 
11
{                               /* files: contains file to output */
 
12
    int row, col;
 
13
    FCELL *fcellbuf = NULL;
 
14
 
 
15
    G_important_message(_("Writing output raster map(s)..."));
 
16
 
 
17
    /* write goodness of fit */
 
18
    if (parms->goodness_map)
 
19
        fcellbuf = Rast_allocate_f_buf();
 
20
 
 
21
    for (row = 0; row < nrows; row++) {
 
22
        G_percent(row, nrows, 2);
 
23
        for (col = 0; col < ncols; col++) {
 
24
            int class = (int)img[row][col];
 
25
                
 
26
            G_debug(3, "class: [%d] row/col: [%d][%d]", class, row, col);
 
27
            files->outbuf[col] = (CELL) S->ClassSig[class].classnum;
 
28
            
 
29
            if (parms->goodness_map)
 
30
                fcellbuf[col] = goodness[row][col];
 
31
        }
 
32
        Rast_put_row(files->output_fd, files->outbuf, CELL_TYPE);
 
33
        if (parms->goodness_map)
 
34
            Rast_put_row(files->goodness_fd, fcellbuf, FCELL_TYPE);
 
35
    }
 
36
    G_percent(1, 1, 1);
 
37
 
 
38
    return 0;
 
39
}