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

« back to all changes in this revision

Viewing changes to raster/r.to.rast3/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:
1
1
 
2
2
/****************************************************************************
3
 
*
4
 
* MODULE:       r.to.rast3 
5
 
*               
6
 
* AUTHOR(S):    Original author 
7
 
*               Soeren Gebbert soerengebbert@gmx.de
8
 
*               08 01 2005 Berlin
9
 
* PURPOSE:      Converts 2D raster map slices to one 3D volume map  
10
 
*
11
 
* COPYRIGHT:    (C) 2005 by the GRASS Development Team
12
 
*
13
 
*               This program is free software under the GNU General Public
14
 
*               License (>=v2). Read the file COPYING that comes with GRASS
15
 
*               for details.
16
 
*
17
 
*****************************************************************************/
 
3
 *
 
4
 * MODULE:       r.to.rast3 
 
5
 *              
 
6
 * AUTHOR(S):    Original author 
 
7
 *               Soeren Gebbert soerengebbert@gmx.de
 
8
 *              08 01 2005 Berlin
 
9
 * PURPOSE:      Converts 2D raster map slices to one 3D volume map  
 
10
 *
 
11
 * COPYRIGHT:    (C) 2005 by the GRASS Development Team
 
12
 *
 
13
 *               This program is free software under the GNU General Public
 
14
 *              License (>=v2). Read the file COPYING that comes with GRASS
 
15
 *              for details.
 
16
 *
 
17
 *****************************************************************************/
18
18
#include <stdio.h>
19
19
#include <stdlib.h>
20
20
#include <string.h>
21
21
#include <grass/gis.h>
22
 
#include <grass/G3d.h>
 
22
#include <grass/raster.h>
 
23
#include <grass/raster3d.h>
23
24
#include <grass/glocale.h>
24
25
#include <grass/config.h>
25
26
 
26
27
/*- params and global variables -----------------------------------------*/
27
 
typedef struct
28
 
{
29
 
    struct Option *input, *output;
 
28
typedef struct {
 
29
    struct Option *input, *output, *tilesize;
30
30
    struct Flag *mask;
31
31
} paramType;
32
32
 
33
 
paramType param;                /*params */
 
33
paramType param; /*params */
34
34
int globalRastMapType;
35
35
int globalG3dMapType;
36
36
 
37
37
 
38
38
/*- prototypes --------------------------------------------------------------*/
39
 
void fatal_error(void *map, int *fd, int depths, char *errorMsg);       /*Simple Error message */
40
 
void set_params();              /*Fill the paramType structure */
41
 
void raster_to_g3d(void *map, G3D_Region region, int *fd);      /*Write the raster */
42
 
int open_input_raster_map(char *name, char *mapset);    /*opens the outputmap */
43
 
void close_input_raster_map(int fd);    /*close the map */
 
39
void fatal_error(void *map, int *fd, int depths, char *errorMsg); /*Simple Error message */
 
40
void set_params(); /*Fill the paramType structure */
 
41
void raster_to_g3d(void *map, RASTER3D_Region region, int *fd); /*Write the raster */
 
42
int open_input_raster_map(const char *name); /*opens the outputmap */
 
43
void close_input_raster_map(int fd); /*close the map */
44
44
 
45
45
 
46
46
 
47
47
/* ************************************************************************* */
48
48
/* Error handling ********************************************************** */
 
49
 
49
50
/* ************************************************************************* */
50
51
void fatal_error(void *map, int *fd, int depths, char *errorMsg)
51
52
{
53
54
 
54
55
    /* Close files and exit */
55
56
    if (map != NULL) {
56
 
        /* should unopen map here! but this functionality is not jet implemented */
57
 
        if (!G3d_closeCell(map))
58
 
            G3d_fatalError(_("Could not close the map"));
 
57
        /* should unopen map here! but this functionality is not jet implemented */
 
58
        if (!Rast3d_close(map))
 
59
            Rast3d_fatal_error(_("Could not close the map"));
59
60
    }
60
61
 
61
62
    if (fd != NULL) {
62
 
        for (i = 0; i < depths; i++)
63
 
            close_input_raster_map(fd[i]);
 
63
        for (i = 0; i < depths; i++)
 
64
            close_input_raster_map(fd[i]);
64
65
    }
65
66
 
66
 
    G3d_fatalError(errorMsg);
 
67
    Rast3d_fatal_error(errorMsg);
67
68
    exit(EXIT_FAILURE);
68
69
 
69
70
}
70
71
 
71
72
/* ************************************************************************* */
72
73
/* Setg up the arguments we are expecting ********************************** */
 
74
 
73
75
/* ************************************************************************* */
74
76
void set_params()
75
77
{
76
78
    param.input = G_define_standard_option(G_OPT_R_INPUTS);
77
 
    param.input->description = _("2d raster maps which represent the slices");
 
79
    param.input->description = _("2D raster maps which represent the slices");
78
80
 
79
81
    param.output = G_define_standard_option(G_OPT_R3_OUTPUT);
80
82
 
 
83
    param.tilesize = G_define_option();
 
84
    param.tilesize->description = _("The maximum tile size in kilo bytes. Default is 32KB.");
 
85
    param.tilesize->key = "tilesize";
 
86
    param.tilesize->answer = "32";
 
87
    param.tilesize->type = TYPE_INTEGER;
 
88
    param.tilesize->required = NO;
 
89
    param.tilesize->multiple = NO;
 
90
 
81
91
    param.mask = G_define_flag();
82
92
    param.mask->key = 'm';
83
 
    param.mask->description = _("Use G3D mask (if exists) with output map");
 
93
    param.mask->description = _("Use 3D raster mask (if exists) with output map");
84
94
 
85
95
}
86
96
 
87
97
 
88
98
 
89
99
/* ************************************************************************* */
90
 
/* Write the raster maps into one G3D map ********************************** */
 
100
/* Write the raster maps into one RASTER3D map ********************************** */
 
101
 
91
102
/* ************************************************************************* */
92
 
void raster_to_g3d(void *map, G3D_Region region, int *fd)
 
103
void raster_to_g3d(void *map, RASTER3D_Region region, int *fd)
93
104
{
94
105
    int x, y, z;
95
106
    int rows, cols, depths;
102
113
    cols = region.cols;
103
114
    depths = region.depths;
104
115
 
105
 
    rast = G_allocate_raster_buf(globalRastMapType);
 
116
    rast = Rast_allocate_buf(globalRastMapType);
106
117
 
107
118
    G_debug(3, "raster_to_g3d: Writing %i raster maps with %i rows %i cols.",
108
 
            depths, rows, cols);
 
119
            depths, rows, cols);
109
120
 
110
121
    /*Every Rastermap */
111
 
    for (z = 0; z < depths; z++) {      /*From the bottom to the top */
112
 
        G_debug(4, "Writing g3d slice %i", z + 1);
113
 
        for (y = 0; y < rows; y++) {
114
 
            G_percent(y, rows - 1, 10);
115
 
 
116
 
            if (!G_get_raster_row(fd[z], rast, y, globalRastMapType))
117
 
                fatal_error(map, fd, depths, _("Could not get raster row"));
118
 
 
119
 
            for (x = 0, ptr = rast; x < cols; x++,
120
 
                 ptr =
121
 
                 G_incr_void_ptr(ptr, G_raster_size(globalRastMapType))) {
122
 
                if (globalRastMapType == CELL_TYPE) {
123
 
                    if (G_is_null_value(ptr, globalRastMapType)) {
124
 
                        G3d_setNullValue(&dvalue, 1, DCELL_TYPE);
125
 
                    }
126
 
                    else {
127
 
                        dvalue = *(CELL *) ptr;
128
 
                    }
129
 
                    if (G3d_putValue
130
 
                        (map, x, y, z, (char *)&dvalue, DCELL_TYPE) < 0)
131
 
                        fatal_error(map, fd, depths,
132
 
                                    "Error writing double data");
133
 
                }
134
 
                else if (globalRastMapType == FCELL_TYPE) {
135
 
                    if (G_is_null_value(ptr, globalRastMapType)) {
136
 
                        G3d_setNullValue(&fvalue, 1, FCELL_TYPE);
137
 
                    }
138
 
                    else {
139
 
                        fvalue = *(FCELL *) ptr;
140
 
                    }
141
 
                    if (G3d_putValue
142
 
                        (map, x, y, z, (char *)&fvalue, FCELL_TYPE) < 0)
143
 
                        fatal_error(map, fd, depths,
144
 
                                    "Error writing float data");
145
 
 
146
 
                }
147
 
                else if (globalRastMapType == DCELL_TYPE) {
148
 
                    if (G_is_null_value(ptr, globalRastMapType)) {
149
 
                        G3d_setNullValue(&dvalue, 1, DCELL_TYPE);
150
 
                    }
151
 
                    else {
152
 
                        dvalue = *(DCELL *) ptr;
153
 
                    }
154
 
                    if (G3d_putValue
155
 
                        (map, x, y, z, (char *)&dvalue, DCELL_TYPE) < 0)
156
 
                        fatal_error(map, fd, depths,
157
 
                                    "Error writing double data");
158
 
 
159
 
                }
160
 
 
161
 
            }
162
 
        }
163
 
        G_debug(2, "\nDone\n");
 
122
    for (z = 0; z < depths; z++) { /*From the bottom to the top */
 
123
        G_percent(z, depths, 1);
 
124
        G_debug(4, "Writing g3d slice %i", z + 1);
 
125
        for (y = 0; y < rows; y++) { /* From north to south */
 
126
 
 
127
            Rast_get_row(fd[z], rast, y, globalRastMapType);
 
128
 
 
129
            for (x = 0, ptr = rast; x < cols; x++,
 
130
                ptr =
 
131
                G_incr_void_ptr(ptr, Rast_cell_size(globalRastMapType))) {
 
132
                if (globalRastMapType == CELL_TYPE) {
 
133
                    if (Rast_is_null_value(ptr, globalRastMapType)) {
 
134
                        Rast3d_set_null_value(&dvalue, 1, DCELL_TYPE);
 
135
                    } else {
 
136
                        dvalue = *(CELL *) ptr;
 
137
                    }
 
138
                    if (Rast3d_put_value
 
139
                        (map, x, y, z, (char *) &dvalue, DCELL_TYPE) < 0)
 
140
                        fatal_error(map, fd, depths,
 
141
                                    "Error writing double data");
 
142
                } else if (globalRastMapType == FCELL_TYPE) {
 
143
                    if (Rast_is_null_value(ptr, globalRastMapType)) {
 
144
                        Rast3d_set_null_value(&fvalue, 1, FCELL_TYPE);
 
145
                    } else {
 
146
                        fvalue = *(FCELL *) ptr;
 
147
                    }
 
148
                    if (Rast3d_put_value
 
149
                        (map, x, y, z, (char *) &fvalue, FCELL_TYPE) < 0)
 
150
                        fatal_error(map, fd, depths,
 
151
                                    "Error writing float data");
 
152
                } else if (globalRastMapType == DCELL_TYPE) {
 
153
                    if (Rast_is_null_value(ptr, globalRastMapType)) {
 
154
                        Rast3d_set_null_value(&dvalue, 1, DCELL_TYPE);
 
155
                    } else {
 
156
                        dvalue = *(DCELL *) ptr;
 
157
                    }
 
158
                    if (Rast3d_put_value
 
159
                        (map, x, y, z, (char *) &dvalue, DCELL_TYPE) < 0)
 
160
                        fatal_error(map, fd, depths,
 
161
                                    "Error writing double data");
 
162
                }
 
163
            }
 
164
        }
164
165
    }
165
166
 
 
167
        G_percent(1, 1, 1);
166
168
 
167
169
    if (rast)
168
 
        G_free(rast);
 
170
        G_free(rast);
169
171
 
170
172
}
171
173
 
172
174
 
173
175
/* ************************************************************************* */
174
 
/* Main function, open the raster maps and create the G3D raster map ******* */
 
176
/* Main function, open the raster maps and create the RASTER3D raster map ******* */
 
177
 
175
178
/* ************************************************************************* */
176
179
int main(int argc, char *argv[])
177
180
{
178
 
    G3D_Region region;
 
181
    RASTER3D_Region region;
179
182
    struct Cell_head window2d;
180
183
    struct GModule *module;
181
 
    void *map = NULL;           /*The 3D Rastermap */
 
184
    void *map = NULL; /*The 3D Rastermap */
182
185
    int i = 0;
183
 
    int *fd = NULL;             /*The filehandler array for the 2D inputmaps */
 
186
    int *fd = NULL; /*The filehandler array for the 2D inputmaps */
184
187
    int cols, rows, opencells;
185
188
    char *name;
186
 
    char *mapset;
187
189
    int changemask = 0;
188
190
    int maptype_tmp, nofile = 0;
 
191
    int maxSize;
189
192
 
190
193
    /* Initialize GRASS */
191
194
    G_gisinit(argv[0]);
192
195
 
193
196
    module = G_define_module();
194
 
    module->keywords = _("raster, volume, conversion");
 
197
    G_add_keyword(_("raster"));
 
198
    G_add_keyword(_("conversion"));
 
199
    G_add_keyword(_("voxel"));
195
200
    module->description =
196
 
        _("Converts 2D raster map slices to one 3D raster volume map.");
 
201
        _("Converts 2D raster map slices to one 3D raster volume map.");
197
202
 
198
203
    /* Get parameters from user */
199
204
    set_params();
200
205
 
201
206
    /* Have GRASS get inputs */
202
207
    if (G_parser(argc, argv))
203
 
        exit(EXIT_FAILURE);
 
208
        exit(EXIT_FAILURE);
204
209
 
205
210
 
206
211
    /*Check for output */
207
212
    if (param.output->answer == NULL)
208
 
        G3d_fatalError(_("No output map"));
 
213
        Rast3d_fatal_error(_("No output map"));
 
214
 
 
215
    /* Get the tile size */
 
216
    maxSize = atoi(param.tilesize->answer);
209
217
 
210
218
    /* Figure out the region from the map */
211
 
    G3d_initDefaults();
212
 
    G3d_getWindow(&region);
 
219
    Rast3d_init_defaults();
 
220
    Rast3d_get_window(&region);
213
221
 
214
222
    /*Check if the g3d-region is equal to the 2d rows and cols */
215
 
    rows = G_window_rows();
216
 
    cols = G_window_cols();
 
223
    rows = Rast_window_rows();
 
224
    cols = Rast_window_cols();
217
225
 
218
 
    G_debug(2, "Check the 2d and 3d region settings");
 
226
    G_debug(2, "Check the 2D and 3D region settings");
219
227
 
220
228
    /*If not equal, set the 2D windows correct */
221
229
    if (rows != region.rows || cols != region.cols) {
222
 
        G_message(_("The 2d and 3d region settings are different. I will use the g3d settings to adjust the 2d region."));
223
 
        G_get_set_window(&window2d);
224
 
        window2d.ns_res = region.ns_res;
225
 
        window2d.ew_res = region.ew_res;
226
 
        window2d.rows = region.rows;
227
 
        window2d.cols = region.cols;
228
 
        G_set_window(&window2d);
 
230
        G_message(_("The 2D and 3D region settings are different. Using the 3D region settings to adjust the 2D region."));
 
231
        G_get_set_window(&window2d);
 
232
        window2d.ns_res = region.ns_res;
 
233
        window2d.ew_res = region.ew_res;
 
234
        window2d.rows = region.rows;
 
235
        window2d.cols = region.cols;
 
236
        Rast_set_window(&window2d);
229
237
    }
230
238
 
231
239
 
232
240
    /*prepare the filehandler */
233
 
    fd = (int *)G_malloc(region.depths * sizeof(int));
 
241
    fd = (int *) G_malloc(region.depths * sizeof (int));
234
242
 
235
243
    if (fd == NULL)
236
 
        fatal_error(map, NULL, 0, _("Out of memory"));
237
 
 
238
 
    if (G_legal_filename(param.output->answer) < 0)
239
 
        fatal_error(map, NULL, 0, _("Illegal output file name"));
240
 
 
241
 
 
242
 
    mapset = NULL;
 
244
        fatal_error(map, NULL, 0, _("Out of memory"));
 
245
 
243
246
    name = NULL;
244
247
 
245
248
    globalRastMapType = DCELL_TYPE;
246
249
    globalG3dMapType = DCELL_TYPE;
247
250
    maptype_tmp = DCELL_TYPE;
248
251
 
249
 
    opencells = 0;              /*Number of opened maps */
 
252
    opencells = 0; /*Number of opened maps */
250
253
    /*Loop over all output maps! open */
251
254
    for (i = 0; i < region.depths; i++) {
252
 
        /*Open only existing maps */
253
 
        if (param.input->answers[i] != NULL && nofile == 0) {
254
 
            mapset = NULL;
255
 
            name = NULL;
256
 
            name = param.input->answers[i];
257
 
            mapset = G_find_cell2(name, "");
258
 
 
259
 
            if (mapset == NULL) {
260
 
                fatal_error(map, fd, opencells, _("Cell file not found"));
261
 
            }
262
 
        }
263
 
        else {
264
 
            nofile = 1;
265
 
        }
266
 
 
267
 
        /*if only one map is given, open it depths - times */
268
 
        G_message(_("Open raster map %s - one time for each depth (%d/%d)"),
269
 
                  name, i + 1, region.depths);
270
 
        fd[i] = open_input_raster_map(name, mapset);
271
 
        opencells++;
272
 
 
273
 
        maptype_tmp = G_get_raster_map_type(fd[i]);
274
 
 
275
 
        /*maptype */
276
 
        if (i == 0)
277
 
            globalRastMapType = maptype_tmp;
278
 
 
279
 
        if (maptype_tmp != globalRastMapType) {
280
 
            fatal_error(map, fd, opencells,
281
 
                        _("Input maps have to be from the same type. CELL, FCELL or DCELL!"));
282
 
        }
 
255
        /*Open only existing maps */
 
256
        if (nofile == 0 && param.input->answers[i])
 
257
            name = param.input->answers[i];
 
258
        else
 
259
            nofile = 1;
 
260
 
 
261
        /*if only one map is given, open it depths - times */
 
262
        G_verbose_message(_("Open raster map %s - one time for each depth (%d/%d)"),
 
263
                          name, i + 1, region.depths);
 
264
        fd[i] = open_input_raster_map(name);
 
265
        opencells++;
 
266
 
 
267
        maptype_tmp = Rast_get_map_type(fd[i]);
 
268
 
 
269
        /*maptype */
 
270
        if (i == 0)
 
271
            globalRastMapType = maptype_tmp;
 
272
 
 
273
        if (maptype_tmp != globalRastMapType) {
 
274
            fatal_error(map, fd, opencells,
 
275
                        _("Input maps have to be from the same type. CELL, FCELL or DCELL!"));
 
276
        }
283
277
    }
284
278
 
285
279
    G_message(_("Creating 3D raster map"));
286
280
    map = NULL;
287
281
 
 
282
    /* Set the map type depending from the arster maps type */
 
283
    if (globalRastMapType == CELL_TYPE || globalRastMapType == DCELL_TYPE)
 
284
        globalG3dMapType = DCELL_TYPE;
 
285
    else
 
286
        globalG3dMapType = FCELL_TYPE;
288
287
 
289
 
    if (globalRastMapType == CELL_TYPE) {
290
 
        map =
291
 
            G3d_openCellNew(param.output->answer, DCELL_TYPE,
292
 
                            G3D_USE_CACHE_DEFAULT, &region);
293
 
        globalG3dMapType = DCELL_TYPE;
294
 
    }
295
 
    else if (globalRastMapType == FCELL_TYPE) {
296
 
        map =
297
 
            G3d_openCellNew(param.output->answer, FCELL_TYPE,
298
 
                            G3D_USE_CACHE_DEFAULT, &region);
299
 
        globalG3dMapType = FCELL_TYPE;
300
 
    }
301
 
    else if (globalRastMapType == DCELL_TYPE) {
302
 
        map =
303
 
            G3d_openCellNew(param.output->answer, DCELL_TYPE,
304
 
                            G3D_USE_CACHE_DEFAULT, &region);
305
 
        globalG3dMapType = DCELL_TYPE;
306
 
    }
 
288
    map = Rast3d_open_new_opt_tile_size(param.output->answer, RASTER3D_USE_CACHE_XY, &region, globalG3dMapType, maxSize);
307
289
 
308
290
    if (map == NULL)
309
 
        fatal_error(map, fd, opencells, _("Error opening 3d raster map"));
 
291
        fatal_error(map, fd, opencells, _("Error opening 3D raster map"));
310
292
 
311
293
    /*if requested set the Mask on */
312
294
    if (param.mask->answer) {
313
 
        if (G3d_maskFileExists()) {
314
 
            changemask = 0;
315
 
            if (G3d_maskIsOff(map)) {
316
 
                G3d_maskOn(map);
317
 
                changemask = 1;
318
 
            }
319
 
        }
 
295
        if (Rast3d_mask_file_exists()) {
 
296
            changemask = 0;
 
297
            if (Rast3d_mask_is_off(map)) {
 
298
                Rast3d_mask_on(map);
 
299
                changemask = 1;
 
300
            }
 
301
        }
320
302
    }
321
303
 
322
 
    /*Create the G3D Rastermap */
 
304
    /*Create the RASTER3D Rastermap */
323
305
    raster_to_g3d(map, region, fd);
324
306
 
325
307
    /*We set the Mask off, if it was off before */
326
308
    if (param.mask->answer) {
327
 
        if (G3d_maskFileExists())
328
 
            if (G3d_maskIsOn(map) && changemask)
329
 
                G3d_maskOff(map);
 
309
        if (Rast3d_mask_file_exists())
 
310
            if (Rast3d_mask_is_on(map) && changemask)
 
311
                Rast3d_mask_off(map);
330
312
    }
331
313
 
332
314
    /*Loop over all output maps! close */
333
315
    for (i = 0; i < region.depths; i++)
334
 
        close_input_raster_map(fd[i]);
 
316
        close_input_raster_map(fd[i]);
335
317
 
336
318
    if (fd)
337
 
        G_free(fd);
 
319
        G_free(fd);
338
320
 
 
321
    /* Flush all tile */
 
322
    if (!Rast3d_flush_all_tiles(map))
 
323
        Rast3d_fatal_error("Error flushing tiles with Rast3d_flush_all_tiles");
339
324
    /* Close files and exit */
340
 
    if (!G3d_closeCell(map))
341
 
        G3d_fatalError(_("Error closing 3d raster map"));
 
325
    if (!Rast3d_close(map))
 
326
        Rast3d_fatal_error(_("Error closing 3d raster map"));
342
327
 
343
328
    map = NULL;
344
329
 
351
336
 
352
337
/* ************************************************************************* */
353
338
/* Open the raster input map *********************************************** */
 
339
 
354
340
/* ************************************************************************* */
355
 
int open_input_raster_map(char *name, char *mapset)
 
341
int open_input_raster_map(const char *name)
356
342
{
357
 
    int fd;
358
 
 
359
 
    G_debug(3, "Open Raster file %s in Mapset %s", name, mapset);
360
 
 
361
 
 
362
 
    /* open raster map */
363
 
    fd = G_open_cell_old(name, mapset);
364
 
 
365
 
    if (fd < 0)
366
 
        G_fatal_error(_("Unable to open raster map <%s>"), name);
367
 
 
368
 
 
369
 
    return fd;
 
343
    G_debug(3, "Open Raster file %s", name);
 
344
 
 
345
    return Rast_open_old(name, "");
370
346
}
371
347
 
372
348
/* ************************************************************************* */
373
349
/* Close the raster input map ********************************************** */
 
350
 
374
351
/* ************************************************************************* */
375
352
void close_input_raster_map(int fd)
376
353
{
377
 
    if (G_close_cell(fd) < 0)
378
 
        G_fatal_error(_("Unable to close input map"));
 
354
    Rast_close(fd);
379
355
}