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

« back to all changes in this revision

Viewing changes to raster/r.out.gridatb/file_io.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
 
#include <stdlib.h>
2
 
#include <grass/glocale.h>
3
 
#include "local_proto.h"
4
 
 
5
 
 
6
 
void rdwr_gridatb(void)
7
 
{
8
 
    FILE *fp;
9
 
    int fd, row, col;
10
 
    int adjcellhdval;
11
 
    CELL *cell;
12
 
    DCELL *dcell;
13
 
    FCELL *fcell;
14
 
    RASTER_MAP_TYPE data_type;
15
 
 
16
 
    fd = G_open_cell_old(iname, mapset);
17
 
    if (fd < 0)
18
 
        G_fatal_error("%s - could not read", iname);
19
 
 
20
 
    data_type = G_get_raster_map_type(fd);
21
 
    switch (data_type) {
22
 
    case CELL_TYPE:
23
 
        cell = G_allocate_c_raster_buf();
24
 
        break;
25
 
    case FCELL_TYPE:
26
 
        fcell = G_allocate_f_raster_buf();
27
 
        break;
28
 
    case DCELL_TYPE:
29
 
        dcell = G_allocate_d_raster_buf();
30
 
        break;
31
 
    }
32
 
 
33
 
    G_get_cellhd(iname, mapset, &cellhd);
34
 
 
35
 
    adjcellhdval = adjcellhd(&cellhd);
36
 
    switch (adjcellhdval) {
37
 
    case 1:
38
 
        G_fatal_error(_("Setting window header"));
39
 
        break;
40
 
    case 2:
41
 
        G_fatal_error(_("Rows changed"));
42
 
        break;
43
 
    case 3:
44
 
        G_fatal_error(_("Cols changed"));
45
 
        break;
46
 
    }
47
 
 
48
 
    fp = fopen(file, "w");
49
 
 
50
 
    fprintf(fp, "%s\n", G_get_cell_title(iname, mapset));
51
 
    fprintf(fp, "%d %d %lf\n", cellhd.cols, cellhd.rows, cellhd.ns_res);
52
 
 
53
 
    for (row = 0; row < cellhd.rows; row++) {
54
 
        G_percent(row, cellhd.rows, 2);
55
 
        switch (data_type) {
56
 
        case CELL_TYPE:
57
 
            if (G_get_c_raster_row(fd, cell, row) < 0) {
58
 
                G_close_cell(fd);
59
 
                exit(1);
60
 
            }
61
 
 
62
 
            for (col = 0; col < cellhd.cols; col++) {
63
 
                if (G_is_c_null_value(&cell[col]))
64
 
                    fprintf(fp, "  9999.00 ");
65
 
                else
66
 
                    fprintf(fp, "%9.2f ", (float)cell[col]);
67
 
                if (!((col + 1) % 8) || col == cellhd.cols - 1)
68
 
                    fprintf(fp, "\n");
69
 
            }
70
 
            break;
71
 
        case FCELL_TYPE:
72
 
            if (G_get_f_raster_row(fd, fcell, row) < 0) {
73
 
                G_close_cell(fd);
74
 
                exit(1);
75
 
            }
76
 
 
77
 
            for (col = 0; col < cellhd.cols; col++) {
78
 
                if (G_is_f_null_value(&fcell[col]))
79
 
                    fprintf(fp, "  9999.00 ");
80
 
                else
81
 
                    fprintf(fp, "%9.2f ", (float)fcell[col]);
82
 
                if (!((col + 1) % 8) || col == cellhd.cols - 1)
83
 
                    fprintf(fp, "\n");
84
 
            }
85
 
            break;
86
 
        case DCELL_TYPE:
87
 
            if (G_get_d_raster_row(fd, dcell, row) < 0) {
88
 
                G_close_cell(fd);
89
 
                exit(1);
90
 
            }
91
 
 
92
 
            for (col = 0; col < cellhd.cols; col++) {
93
 
                if (G_is_d_null_value(&dcell[col]))
94
 
                    fprintf(fp, "  9999.00 ");
95
 
                else
96
 
                    fprintf(fp, "%9.2lf ", (double)dcell[col]);
97
 
                if (!((col + 1) % 8) || col == cellhd.cols - 1)
98
 
                    fprintf(fp, "\n");
99
 
            }
100
 
            break;
101
 
        }
102
 
    }
103
 
    G_close_cell(fd);
104
 
 
105
 
    return;
106
 
}