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

« back to all changes in this revision

Viewing changes to raster/r.out.ascii/formspecific.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
#include <stdio.h>
2
2
#include <grass/gis.h>
 
3
#include <grass/raster.h>
3
4
 
4
5
/* write the GRASS ASCII heading */
5
6
int writeGRASSheader(FILE * fp)
32
33
    void *ptr, *raster;
33
34
    char cell_buf[300];
34
35
 
35
 
    raster = G_allocate_raster_buf(out_type);
 
36
    raster = Rast_allocate_buf(out_type);
36
37
 
37
38
    for (row = 0; row < nrows; row++) {
38
39
        G_percent(row, nrows, 2);
39
40
 
40
 
        if (G_get_raster_row(fd, raster, row, out_type) < 0)
41
 
            return (row);
 
41
        Rast_get_row(fd, raster, row, out_type);
42
42
 
43
43
        for (col = 0, ptr = raster; col < ncols; col++,
44
 
             ptr = G_incr_void_ptr(ptr, G_raster_size(out_type))) {
45
 
            if (!G_is_null_value(ptr, out_type)) {
 
44
             ptr = G_incr_void_ptr(ptr, Rast_cell_size(out_type))) {
 
45
            if (!Rast_is_null_value(ptr, out_type)) {
46
46
                if (out_type == CELL_TYPE)
47
47
                    fprintf(fp, "%d", *((CELL *) ptr));
48
48
 
85
85
    int row, col, colcnt;
86
86
    void *ptr, *raster;
87
87
 
88
 
    raster = G_allocate_raster_buf(out_type);
 
88
    raster = Rast_allocate_buf(out_type);
89
89
 
90
90
    for (row = 0; row < nrows; row++) {
91
91
        G_percent(row, nrows, 2);
92
92
 
93
 
        if (G_get_raster_row(fd, raster, row, out_type) < 0)
94
 
            return (row);
 
93
        Rast_get_row(fd, raster, row, out_type);
95
94
 
96
95
        colcnt = 0;
97
96
        for (col = 0, ptr = raster; col < ncols; col++,
98
 
             ptr = G_incr_void_ptr(ptr, G_raster_size(out_type))) {
 
97
             ptr = G_incr_void_ptr(ptr, Rast_cell_size(out_type))) {
99
98
            if (out_type == CELL_TYPE) {
100
 
                if (G_is_null_value(ptr, out_type))
 
99
                if (Rast_is_null_value(ptr, out_type))
101
100
                    *((CELL *) ptr) = 0;
102
101
                fprintf(fp, " %d", *((CELL *) ptr));
103
102
            }
104
103
            else if (out_type == FCELL_TYPE) {
105
 
                if (G_is_null_value(ptr, out_type))
 
104
                if (Rast_is_null_value(ptr, out_type))
106
105
                    *((FCELL *) ptr) = 0;
107
106
                fprintf(fp, "%*.*e", dp + 6, dp - 1, *((FCELL *) ptr));
108
107
            }
109
108
            else if (out_type == DCELL_TYPE) {
110
 
                if (G_is_null_value(ptr, out_type))
 
109
                if (Rast_is_null_value(ptr, out_type))
111
110
                    *((DCELL *) ptr) = 0;
112
111
                fprintf(fp, "%*.*e", dp + 6, dp - 1, *((DCELL *) ptr));
113
112
            }
126
125
}
127
126
 
128
127
/* write the Surfer grid heading */
129
 
int writeGSheader(FILE * fp, char *name, char *mapset)
 
128
int writeGSheader(FILE * fp, const char *name)
130
129
{
131
130
    struct Cell_head region;
132
131
    char fromc[128], toc[128];
133
132
    struct FPRange range;
134
133
    DCELL Z_MIN, Z_MAX;
135
134
 
136
 
    if (G_read_fp_range(name, mapset, &range) < 0)
 
135
    if (Rast_read_fp_range(name, "", &range) < 0)
137
136
        return 1;
138
137
 
139
138
    fprintf(fp, "DSAA \n");
154
153
                      G_projection() == PROJECTION_LL ? -1 : 0);
155
154
    fprintf(fp, "%s %s\n", fromc, toc);
156
155
 
157
 
    G_get_fp_range_min_max(&range, &Z_MIN, &Z_MAX);
 
156
    Rast_get_fp_range_min_max(&range, &Z_MIN, &Z_MAX);
158
157
    fprintf(fp, "%f %f\n", (double)Z_MIN, (double)Z_MAX);
159
158
 
160
159
    return 0;
171
170
    void *ptr, *raster;
172
171
    char cell_buf[300];
173
172
 
174
 
    raster = G_allocate_raster_buf(out_type);
 
173
    raster = Rast_allocate_buf(out_type);
175
174
 
176
175
    for (row = nrows - 1; row >= 0; row--) {
177
176
        G_percent((row - nrows) * (-1), nrows, 2);
178
177
 
179
 
        if (G_get_raster_row(fd, raster, row, out_type) < 0)
180
 
            return (row);
 
178
        Rast_get_row(fd, raster, row, out_type);
181
179
 
182
180
        colcnt = 0;
183
181
        for (col = 0, ptr = raster; col < ncols; col++,
184
 
             ptr = G_incr_void_ptr(ptr, G_raster_size(out_type))) {
 
182
             ptr = G_incr_void_ptr(ptr, Rast_cell_size(out_type))) {
185
183
            colcnt += 1;
186
 
            if (!G_is_null_value(ptr, out_type)) {
 
184
            if (!Rast_is_null_value(ptr, out_type)) {
187
185
                if (out_type == CELL_TYPE)
188
186
                    fprintf(fp, "%d", *((CELL *) ptr));
189
187
                else if (out_type == FCELL_TYPE) {