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

« back to all changes in this revision

Viewing changes to vector/v.vol.rst/user1.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:
28
28
 
29
29
#include <stdio.h>
30
30
#include <stdlib.h>
 
31
#include <sys/types.h>
31
32
#include <math.h>
32
33
#include <grass/gis.h>
33
 
#include <grass/G3d.h>
 
34
#include <grass/raster.h>
 
35
#include <grass/raster3d.h>
34
36
#include <grass/dbmi.h>
35
 
#include <grass/Vect.h>
 
37
#include <grass/vector.h>
36
38
#include <grass/bitmap.h>
37
39
#include <grass/glocale.h>
38
40
#include "oct.h"
70
72
    double deltx, delty, deltz;
71
73
    int first_time = 1;
72
74
    CELL *cellmask;
73
 
    char *mapsetm;
 
75
    const char *mapsetm;
74
76
    char buf[500];
75
77
    int cat, intval;
76
78
    struct field_info *Fi;
107
109
        G_fatal_error(_("Column type of wcolumn is not supported (must be integer or double)"));
108
110
 
109
111
    if (nrec < 0)
110
 
        G_fatal_error("Unable to select data from table");
 
112
        G_fatal_error(_("Unable to select data from table"));
111
113
    G_message("%d records selected from table", nrec);
112
114
 
113
115
    if (scol != NULL) {
118
120
        sctype = cvarr.ctype;
119
121
 
120
122
        if (sctype == -1)
121
 
            G_fatal_error("Cannot read column type of smooth column");
 
123
            G_fatal_error(_("Cannot read column type of smooth column"));
122
124
        if (sctype == DB_C_TYPE_DATETIME)
123
125
            G_fatal_error
124
 
                ("Column type of smooth column (datetime) is not supported");
 
126
                (_("Column type of smooth column (datetime) is not supported"));
125
127
        if (sctype != DB_C_TYPE_INT && sctype != DB_C_TYPE_DOUBLE)
126
128
            G_fatal_error(_("Column type of smooth column is not supported (must be integer or double)"));
127
129
    }
135
137
        int ival, type, ret;
136
138
 
137
139
        if (-1 == (type = Vect_read_next_line(In, Points, Cats)))
138
 
            G_fatal_error("Unable to read vector map");
 
140
            G_fatal_error(_("Unable to read vector map"));
139
141
 
140
142
        if (type == -2)
141
143
            break;              /* EOF */
145
147
 
146
148
        Vect_cat_get(Cats, 1, &cat);
147
149
        if (cat < 0) {
148
 
            G_warning("Point without category");
 
150
            G_warning(_("Point without category"));
149
151
            continue;
150
152
        }
151
153
 
203
205
            ((c1 >= 0) && (c2 >= 0) && (c3 >= 0) && (c4 >= 0) && (c5 >= 0) &&
204
206
             (c6 >= 0))) {
205
207
            if (!OUTRANGE) {
206
 
                G_warning("some points outside of region -- will ignore...");
 
208
                G_warning(_("Some points outside of region -- will ignore..."));
207
209
            }
208
210
            OUTRANGE++;
209
211
        }
210
212
        else {
211
213
            if (!(point = point_new(x, y, z, w, sm))) {
212
 
                clean_fatal_error("Cannot allocate memory for point");
 
214
                clean();
 
215
                G_fatal_error(_("Cannot allocate memory for point"));
213
216
            }
214
217
 
215
218
            a = OT_insert_oct(point, root);
217
220
                NPOINT++;
218
221
            }
219
222
            if (a < 0) {
220
 
                G_warning("Can't insert %lf,%lf,%lf,%lf,%lf a=%d\n", x, y, z,
 
223
                G_warning(_("Can't insert %lf,%lf,%lf,%lf,%lf a=%d"), x, y, z,
221
224
                          w, sm, a);
222
225
                return -1;
223
226
            }
264
267
 
265
268
        if (!once) {
266
269
            once = 1;
267
 
            G_warning("strip exists with insufficient data");
 
270
            G_warning(_("Strip exists with insufficient data"));
268
271
        }
269
272
    }
270
273
 
272
275
    totsegm = translate_oct(root, ((struct octdata *)(root->data))->x_orig,
273
276
                            ((struct octdata *)(root->data))->y_orig,
274
277
                            ((struct octdata *)(root->data))->z_orig, nz);
275
 
    if (!totsegm)
276
 
        clean_fatal_error("Zero segments!");
 
278
    if (!totsegm) {
 
279
        clean();
 
280
        G_fatal_error(_("Zero segments!"));
 
281
    }
277
282
 
278
283
    ((struct octdata *)(root->data))->x_orig = 0;
279
284
    ((struct octdata *)(root->data))->y_orig = 0;
303
308
    fprintf(stderr, "\n");
304
309
    if (OUTRANGE > 0)
305
310
        G_warning
306
 
            ("There are points outside specified 2D/3D region--ignored %d points (total points: %d)",
 
311
            (_("There are points outside specified 2D/3D region--ignored %d points (total points: %d)"),
307
312
             OUTRANGE, k);
308
313
    if (NPOINT > 0)
309
314
        G_warning
310
 
            ("Points are more dense than specified 'DMIN'--ignored %d points (remain %d)",
 
315
            (_("Points are more dense than specified 'DMIN'--ignored %d points (remain %d)"),
311
316
             NPOINT, k - NPOINT);
312
317
    NPOINT = k - NPOINT - NPT - OUTRANGE;
313
318
    if (NPOINT < KMIN) {
314
319
        if (NPOINT != 0) {
315
320
            G_warning
316
 
                ("%d points given for interpolation (after thinning) is less than given NPMIN=%d",
 
321
                (_("%d points given for interpolation (after thinning) is less than given NPMIN=%d"),
317
322
                 NPOINT, KMIN);
318
323
            KMIN = NPOINT;
319
324
        }
333
338
 
334
339
    if (NPOINT < KMAXPOINTS && KMAX != KMAXPOINTS)
335
340
        G_warning
336
 
            ("There is less than %d points for interpolation, no segmentation is necessary, to run the program faster, set segmax=%d (see manual)",
 
341
            (_("There is less than %d points for interpolation, no segmentation is necessary, to run the program faster, set segmax=%d (see manual)"),
337
342
             KMAXPOINTS, KMAXPOINTS);
338
343
 
339
344
    deltx = xmax - xmin;
357
362
 
358
363
  /** create a bitmap mask from given raster map **/
359
364
    if (maskmap != NULL) {
360
 
        mapsetm = G_find_cell2(maskmap, "");
 
365
        mapsetm = G_find_raster2(maskmap, "");
361
366
        if (!mapsetm) {
362
 
            sprintf(buf, "mask raster map [%s] not found\n", maskmap);
363
 
            clean_fatal_error(buf);
 
367
            clean();
 
368
            G_fatal_error(_("Mask raster map [%s] not found"), maskmap);
364
369
        }
365
370
        bitmask = BM_create(nsizc, nsizr);
366
 
        cellmask = G_allocate_cell_buf();
367
 
        cfmask = G_open_cell_old(maskmap, mapsetm);
 
371
        cellmask = Rast_allocate_c_buf();
 
372
        cfmask = Rast_open_old(maskmap, mapsetm);
368
373
        for (i = 0; i < nsizr; i++) {
369
374
            irev = nsizr - i - 1;
370
 
            G_get_map_row(cfmask, cellmask, i);
 
375
            Rast_get_c_row(cfmask, cellmask, i);
371
376
            for (j = 0; j < nsizc; j++) {
372
 
                if ((cellmask[j] == 0) || G_is_c_null_value(&cellmask[j]))
 
377
                if ((cellmask[j] == 0) || Rast_is_c_null_value(&cellmask[j]))
373
378
                    BM_set(bitmask, j, irev, 0);
374
379
                else
375
380
                    BM_set(bitmask, j, irev, 1);
376
381
            }
377
382
        }
378
 
        G_message("bitmap mask created");
 
383
        G_message(_("Bitmap mask created"));
379
384
    }
380
385
 
381
386
    return 1;
392
397
    FCELL *cell;
393
398
    float *data;
394
399
    int i, iarc, cnt;
395
 
    char buff[1024];
396
400
    int bmask = 1;
397
401
    int x, y;
398
402
    float value;
399
403
 
400
404
    if ((cellinp != NULL) && (cellout != NULL)) {
401
 
        cell = G_allocate_f_raster_buf();
 
405
        cell = Rast_allocate_f_buf();
402
406
 
403
407
        for (i = 0; i < nsizr; i++) {
404
408
            /* seek to the right row */
405
 
            if (fseek
406
 
                (Tmp_fd_cell, (long)((nsizr - 1 - i) * nsizc * sizeof(FCELL)),
407
 
                 0) == -1)
408
 
                G_fatal_error("cannot fseek to the right spot");
 
409
            G_fseek
 
410
                (Tmp_fd_cell, ((off_t)(nsizr - 1 - i) * nsizc * sizeof(FCELL)),
 
411
                 0);
409
412
            fread(cell, sizeof(FCELL), nsizc, Tmp_fd_cell);
410
 
            G_put_f_raster_row(fdcout, cell);
 
413
            Rast_put_f_row(fdcout, cell);
411
414
        }
412
415
    }
413
416
 
416
419
    current_region.top = nsizl * tb_res_in + z_orig_in;
417
420
 
418
421
    if (!(data = (float *)G_malloc(sizeof(float) * nsizr * nsizc * nsizl))) {
419
 
        clean_fatal_error("Error: out of memory");
 
422
        clean();
 
423
        G_fatal_error(_("Out of memory"));
420
424
    }
421
425
 
422
426
  /*** Write elevation results ***/
423
427
    if (outz != NULL) {
424
428
 
425
 
        cf1 = G3d_openCellNew(outz, FCELL_TYPE,
426
 
                              G3D_USE_CACHE_DEFAULT, &current_region);
 
429
        cf1 = Rast3d_open_new_opt_tile_size(outz, RASTER3D_USE_CACHE_DEFAULT, &current_region, FCELL_TYPE, 32); 
427
430
        if (cf1 == NULL) {
428
 
            sprintf(buff, "Can't open %s for writing ", outz);
429
 
            clean_fatal_error(buff);
 
431
            clean();
 
432
            G_fatal_error(_("Unable to open %s for writing"), outz);
430
433
        }
431
434
 
432
435
        /* seek to the beginning */
433
 
        fseek(Tmp_fd_z, 0L, 0);
 
436
        G_fseek(Tmp_fd_z, 0L, 0);
434
437
 
435
438
        /* Read data in from temp file */
436
439
        read_val =
437
440
            fread(data, sizeof(float), nsizr * nsizc * nsizl, Tmp_fd_z);
438
 
        if (read_val < 0)
439
 
            clean_fatal_error("Cannot read data from temp file");
 
441
        if (read_val < 0) {
 
442
            clean();
 
443
            G_fatal_error(_("Unable to read data from temp file"));
 
444
        }
440
445
 
441
446
        cnt = 0;
442
447
        for (iarc = 0; iarc < nsizl; iarc++) {
449
454
                        bmask = 1;
450
455
                    value = data[cnt];
451
456
                    if (!bmask)
452
 
                        G3d_setNullValue(&value, 1, FCELL_TYPE);
453
 
                    if (G3d_putFloat(cf1, x, y, iarc, value) == 0) {
454
 
                        sprintf(buff,
455
 
                                "Error writing cell (%d,%d,%d) with value %f",
 
457
                        Rast3d_set_null_value(&value, 1, FCELL_TYPE);
 
458
                    if (Rast3d_put_float(cf1, x, y, iarc, value) == 0) {
 
459
                        clean();
 
460
                        G_fatal_error(
 
461
                                _("Error writing cell (%d,%d,%d) with value %f"),
456
462
                                x, y, iarc, value);
457
 
                        clean_fatal_error(buff);
458
463
                    }
459
464
 
460
465
                    cnt++;
464
469
        }
465
470
 
466
471
        /* Close the file */
467
 
        if (G3d_closeCell(cf1) == 0) {
468
 
            sprintf(buff, "Error closing output file %s ", outz);
469
 
            clean_fatal_error(buff);
 
472
        if (Rast3d_close(cf1) == 0) {
 
473
            clean();
 
474
            G_fatal_error(_("Error closing output file %s"), outz);
470
475
        } else
471
476
            G_message(_("3D raster map <%s> created"), outz);
472
477
    }
474
479
  /*** Write out the gradient results ***/
475
480
    if (gradient != NULL) {
476
481
 
477
 
        cf2 = G3d_openCellNew(gradient, FCELL_TYPE,
478
 
                              G3D_USE_CACHE_DEFAULT, &current_region);
 
482
        cf2 = Rast3d_open_new_opt_tile_size(gradient, RASTER3D_USE_CACHE_DEFAULT, &current_region, FCELL_TYPE, 32); 
479
483
        if (cf2 == NULL) {
480
 
            sprintf(buff, "Can't open %s for writing ", gradient);
481
 
            clean_fatal_error(buff);
 
484
            clean();
 
485
            G_fatal_error(_("Unable to open %s for writing"), gradient);
482
486
        }
483
487
 
484
488
        /* seek to the beginning */
485
 
        fseek(Tmp_fd_dx, 0L, 0);
 
489
        G_fseek(Tmp_fd_dx, 0L, 0);
486
490
 
487
491
        /* Read data in from temp file */
488
492
        read_val =
489
493
            fread(data, sizeof(float), nsizr * nsizc * nsizl, Tmp_fd_dx);
490
 
        if (read_val < 0)
491
 
            clean_fatal_error("Cannot read data from temp file");
 
494
        if (read_val < 0) {
 
495
            clean();
 
496
            G_fatal_error(_("Unable to read data from temp file"));
 
497
        }
492
498
 
493
499
        cnt = 0;
494
500
        for (iarc = 0; iarc < nsizl; iarc++) {
501
507
                        bmask = 1;
502
508
                    value = data[cnt];
503
509
                    if (!bmask)
504
 
                        G3d_setNullValue(&value, 1, FCELL_TYPE);
505
 
                    if (G3d_putFloat(cf2, x, y, iarc, value) == 0) {
506
 
                        sprintf(buff,
507
 
                                "Error writing cell (%d,%d,%d) with value %f",
 
510
                        Rast3d_set_null_value(&value, 1, FCELL_TYPE);
 
511
                    if (Rast3d_put_float(cf2, x, y, iarc, value) == 0) {
 
512
                        clean();
 
513
                        G_fatal_error(
 
514
                                _("Error writing cell (%d,%d,%d) with value %f"),
508
515
                                x, y, iarc, value);
509
 
                        clean_fatal_error(buff);
510
516
                    }
511
517
 
512
518
                    cnt++;
516
522
        }
517
523
 
518
524
        /* Close the file */
519
 
        if (G3d_closeCell(cf2) == 0) {
520
 
            sprintf(buff, "Error closing output file %s ", gradient);
521
 
            clean_fatal_error(buff);
 
525
        if (Rast3d_close(cf2) == 0) {
 
526
            clean();
 
527
            G_fatal_error(_("Error closing output file %s"), gradient);
522
528
        } else
523
529
            G_message(_("3D raster map <%s> created"), gradient);
524
530
    }
526
532
  /*** Write out aspect1 results ***/
527
533
    if (aspect1 != NULL) {
528
534
 
529
 
        cf3 = G3d_openCellNew(aspect1, FCELL_TYPE,
530
 
                              G3D_USE_CACHE_DEFAULT, &current_region);
 
535
        cf3 = Rast3d_open_new_opt_tile_size(aspect1, RASTER3D_USE_CACHE_DEFAULT, &current_region, FCELL_TYPE, 32); 
531
536
        if (cf3 == NULL) {
532
 
            sprintf(buff, "Can't open %s for writing ", aspect1);
533
 
            clean_fatal_error(buff);
 
537
            clean();
 
538
            G_fatal_error(_("Unable to open %s for writing"), aspect1);
534
539
        }
535
540
 
536
541
        /* seek to the beginning */
537
 
        fseek(Tmp_fd_dy, 0L, 0);
 
542
        G_fseek(Tmp_fd_dy, 0L, 0);
538
543
 
539
544
        /* Read data in from temp file */
540
545
        read_val =
541
546
            fread(data, sizeof(float), nsizr * nsizc * nsizl, Tmp_fd_dy);
542
 
        if (read_val < 0)
543
 
            clean_fatal_error("Cannot read data from temp file");
 
547
        if (read_val < 0) {
 
548
            clean();
 
549
            G_fatal_error(_("Unable to read data from temp file"));
 
550
        }
544
551
 
545
552
        cnt = 0;
546
553
        for (iarc = 0; iarc < nsizl; iarc++) {
551
558
                        bmask = BM_get(bitmask, x, nsizr - y - 1);
552
559
                    else
553
560
                        bmask = 1;
554
 
                    value = data[cnt];
 
561
                    value = data[cnt] * 180 / M_PI;
555
562
                    if (!bmask)
556
 
                        G3d_setNullValue(&value, 1, FCELL_TYPE);
557
 
                    if (G3d_putFloat(cf3, x, y, iarc, value) == 0) {
558
 
                        sprintf(buff,
559
 
                                "Error writing cell (%d,%d,%d) with value %f",
 
563
                        Rast3d_set_null_value(&value, 1, FCELL_TYPE);
 
564
                    if (Rast3d_put_float(cf3, x, y, iarc, value) == 0) {
 
565
                        clean();
 
566
                        G_fatal_error(
 
567
                                _("Error writing cell (%d,%d,%d) with value %f"),
560
568
                                x, y, iarc, value);
561
 
                        clean_fatal_error(buff);
562
569
                    }
563
570
 
564
571
                    cnt++;
568
575
        }
569
576
 
570
577
        /* Close the file */
571
 
        if (G3d_closeCell(cf3) == 0) {
572
 
            sprintf(buff, "Error closing output file %s ", aspect1);
573
 
            clean_fatal_error(buff);
 
578
        if (Rast3d_close(cf3) == 0) {
 
579
            clean();
 
580
            G_fatal_error(_("Error closing output file %s"), aspect1);
574
581
        } else
575
582
            G_message(_("3D raster map <%s> created"), aspect1);
576
583
    }
578
585
  /*** Write out aspect2 results ***/
579
586
    if (aspect2 != NULL) {
580
587
 
581
 
        cf4 = G3d_openCellNew(aspect2, FCELL_TYPE,
582
 
                              G3D_USE_CACHE_DEFAULT, &current_region);
 
588
        cf4 = Rast3d_open_new_opt_tile_size(aspect2, RASTER3D_USE_CACHE_DEFAULT, &current_region, FCELL_TYPE, 32); 
583
589
        if (cf4 == NULL) {
584
 
            sprintf(buff, "Can't open %s for writing ", aspect2);
585
 
            clean_fatal_error(buff);
 
590
            clean();
 
591
            G_fatal_error(_("Unable to open %s for writing"), aspect2);
586
592
        }
587
593
 
588
594
        /* seek to the beginning */
589
 
        fseek(Tmp_fd_dz, 0L, 0);
 
595
        G_fseek(Tmp_fd_dz, 0L, 0);
590
596
 
591
597
        /* Read data in from temp file */
592
598
        read_val =
593
599
            fread(data, sizeof(float), nsizr * nsizc * nsizl, Tmp_fd_dz);
594
 
        if (read_val < 0)
595
 
            clean_fatal_error("Cannot read data from temp file");
 
600
        if (read_val < 0) {
 
601
            clean();
 
602
            G_fatal_error(_("Unable to read data from temp file"));
 
603
        }
596
604
 
597
605
        cnt = 0;
598
606
        for (iarc = 0; iarc < nsizl; iarc++) {
603
611
                        bmask = BM_get(bitmask, x, nsizr - y - 1);
604
612
                    else
605
613
                        bmask = 1;
606
 
                    value = data[cnt];
 
614
                    value = data[cnt] * 180 / M_PI;
607
615
                    if (!bmask)
608
 
                        G3d_setNullValue(&value, 1, FCELL_TYPE);
609
 
                    if (G3d_putFloat(cf4, x, y, iarc, value) == 0) {
610
 
                        sprintf(buff,
611
 
                                "Error writing cell (%d,%d,%d) with value %f",
 
616
                        Rast3d_set_null_value(&value, 1, FCELL_TYPE);
 
617
                    if (Rast3d_put_float(cf4, x, y, iarc, value) == 0) {
 
618
                        clean();
 
619
                        G_fatal_error(
 
620
                                _("Error writing cell (%d,%d,%d) with value %f"),
612
621
                                x, y, iarc, value);
613
 
                        clean_fatal_error(buff);
614
622
                    }
615
623
 
616
624
                    cnt++;
620
628
        }
621
629
 
622
630
        /* Close the file */
623
 
        if (G3d_closeCell(cf4) == 0) {
624
 
            sprintf(buff, "Error closing output file %s ", aspect2);
625
 
            clean_fatal_error(buff);
 
631
        if (Rast3d_close(cf4) == 0) {
 
632
            clean();
 
633
            G_fatal_error(_("Error closing output file %s"), aspect2);
626
634
        } else
627
635
            G_message(_("3D raster map <%s> created"), aspect2);
628
636
    }
630
638
  /*** Write out ncurv results ***/
631
639
    if (ncurv != NULL) {
632
640
 
633
 
        cf5 = G3d_openCellNew(ncurv, FCELL_TYPE,
634
 
                              G3D_USE_CACHE_DEFAULT, &current_region);
 
641
        cf5 = Rast3d_open_new_opt_tile_size(ncurv, RASTER3D_USE_CACHE_DEFAULT, &current_region, FCELL_TYPE, 32); 
635
642
        if (cf5 == NULL) {
636
 
            sprintf(buff, "Can't open %s for writing ", ncurv);
637
 
            clean_fatal_error(buff);
 
643
            clean();
 
644
            G_fatal_error(_("Unable to open %s for writing"), ncurv);
638
645
        }
639
646
 
640
647
        /* seek to the beginning */
641
 
        fseek(Tmp_fd_xx, 0L, 0);
 
648
        G_fseek(Tmp_fd_xx, 0L, 0);
642
649
 
643
650
        /* Read data in from temp file */
644
651
        read_val =
645
652
            fread(data, sizeof(float), nsizr * nsizc * nsizl, Tmp_fd_xx);
646
 
        if (read_val < 0)
647
 
            clean_fatal_error("Cannot read data from temp file");
 
653
        if (read_val < 0) {
 
654
            clean();
 
655
            G_fatal_error(_("Unable to read data from temp file"));
 
656
        }
648
657
 
649
658
        cnt = 0;
650
659
        for (iarc = 0; iarc < nsizl; iarc++) {
657
666
                        bmask = 1;
658
667
                    value = data[cnt];
659
668
                    if (!bmask)
660
 
                        G3d_setNullValue(&value, 1, FCELL_TYPE);
661
 
                    if (G3d_putFloat(cf5, x, y, iarc, value) == 0) {
662
 
                        sprintf(buff,
663
 
                                "Error writing cell (%d,%d,%d) with value %f",
 
669
                        Rast3d_set_null_value(&value, 1, FCELL_TYPE);
 
670
                    if (Rast3d_put_float(cf5, x, y, iarc, value) == 0) {
 
671
                        clean();
 
672
                        G_fatal_error(
 
673
                                _("Error writing cell (%d,%d,%d) with value %f"),
664
674
                                x, y, iarc, value);
665
 
                        clean_fatal_error(buff);
666
675
                    }
667
676
 
668
677
                    cnt++;
672
681
        }
673
682
 
674
683
        /* Close the file */
675
 
        if (G3d_closeCell(cf5) == 0) {
676
 
            sprintf(buff, "Error closing output file %s ", ncurv);
677
 
            clean_fatal_error(buff);
 
684
        if (Rast3d_close(cf5) == 0) {
 
685
            clean();
 
686
            G_fatal_error(_("Error closing output file %s"), ncurv);
678
687
        } else
679
688
            G_message(_("3D raster map <%s> created"), ncurv);
680
689
    }
682
691
  /*** Write out gcurv results ***/
683
692
    if (gcurv != NULL) {
684
693
 
685
 
        cf6 = G3d_openCellNew(gcurv, FCELL_TYPE,
686
 
                              G3D_USE_CACHE_DEFAULT, &current_region);
 
694
        cf6 = Rast3d_open_new_opt_tile_size(gcurv, RASTER3D_USE_CACHE_DEFAULT, &current_region, FCELL_TYPE, 32); 
687
695
        if (cf6 == NULL) {
688
 
            sprintf(buff, "Can't open %s for writing ", gcurv);
689
 
            clean_fatal_error(buff);
 
696
            clean();
 
697
            G_fatal_error(_("Unable to open %s for writing"), gcurv);
690
698
        }
691
699
 
692
700
        /* seek to the beginning */
693
 
        fseek(Tmp_fd_yy, 0L, 0);
 
701
        G_fseek(Tmp_fd_yy, 0L, 0);
694
702
 
695
703
        /* Read data in from temp file */
696
704
        read_val =
697
705
            fread(data, sizeof(float), nsizr * nsizc * nsizl, Tmp_fd_yy);
698
 
        if (read_val < 0)
699
 
            clean_fatal_error("Cannot read data from temp file");
 
706
        if (read_val < 0) {
 
707
            clean();
 
708
            G_fatal_error(_("Unable to read data from temp file"));
 
709
        }
700
710
 
701
711
        cnt = 0;
702
712
        for (iarc = 0; iarc < nsizl; iarc++) {
709
719
                        bmask = 1;
710
720
                    value = data[cnt];
711
721
                    if (!bmask)
712
 
                        G3d_setNullValue(&value, 1, FCELL_TYPE);
713
 
                    if (G3d_putFloat(cf6, x, y, iarc, value) == 0) {
714
 
                        sprintf(buff,
715
 
                                "Error writing cell (%d,%d,%d) with value %f",
 
722
                        Rast3d_set_null_value(&value, 1, FCELL_TYPE);
 
723
                    if (Rast3d_put_float(cf6, x, y, iarc, value) == 0) {
 
724
                        clean();
 
725
                        G_fatal_error(
 
726
                                _("Error writing cell (%d,%d,%d) with value %f"),
716
727
                                x, y, iarc, value);
717
 
                        clean_fatal_error(buff);
718
728
                    }
719
729
 
720
730
                    cnt++;
724
734
        }
725
735
 
726
736
        /* Close the file */
727
 
        if (G3d_closeCell(cf6) == 0) {
728
 
            sprintf(buff, "Error closing output file %s ", gcurv);
729
 
            clean_fatal_error(buff);
 
737
        if (Rast3d_close(cf6) == 0) {
 
738
            clean();
 
739
            G_fatal_error(_("Error closing output file %s"), gcurv);
730
740
        } else
731
741
            G_message(_("3D raster map <%s> created"), gcurv);
732
742
    }
734
744
  /*** Write mcurv results ***/
735
745
    if (mcurv != NULL) {
736
746
 
737
 
        cf7 = G3d_openCellNew(mcurv, FCELL_TYPE,
738
 
                              G3D_USE_CACHE_DEFAULT, &current_region);
 
747
        cf7 = Rast3d_open_new_opt_tile_size(mcurv, RASTER3D_USE_CACHE_DEFAULT, &current_region, FCELL_TYPE, 32); 
739
748
        if (cf7 == NULL) {
740
 
            sprintf(buff, "Can't open %s for writing ", mcurv);
741
 
            clean_fatal_error(buff);
 
749
            clean();
 
750
            G_fatal_error(_("Unable to open %s for writing"), mcurv);
742
751
        }
743
752
 
744
753
        /* seek to the beginning */
745
 
        fseek(Tmp_fd_xy, 0L, 0);
 
754
        G_fseek(Tmp_fd_xy, 0L, 0);
746
755
 
747
756
        /* Read data in from temp file */
748
757
        read_val =
749
758
            fread(data, sizeof(float), nsizr * nsizc * nsizl, Tmp_fd_xy);
750
 
        if (read_val < 0)
751
 
            clean_fatal_error("Cannot read data from temp file");
 
759
        if (read_val < 0) {
 
760
            clean();
 
761
            G_fatal_error(_("Unable to read data from temp file"));
 
762
        }
752
763
 
753
764
        cnt = 0;
754
765
        for (iarc = 0; iarc < nsizl; iarc++) {
761
772
                        bmask = 1;
762
773
                    value = data[cnt];
763
774
                    if (!bmask)
764
 
                        G3d_setNullValue(&value, 1, FCELL_TYPE);
765
 
                    if (G3d_putFloat(cf7, x, y, iarc, value) == 0) {
766
 
                        sprintf(buff,
767
 
                                "Error writing cell (%d,%d,%d) with value %f",
 
775
                        Rast3d_set_null_value(&value, 1, FCELL_TYPE);
 
776
                    if (Rast3d_put_float(cf7, x, y, iarc, value) == 0) {
 
777
                        clean();
 
778
                        G_fatal_error(
 
779
                                _("Error writing cell (%d,%d,%d) with value %f"),
768
780
                                x, y, iarc, value);
769
 
                        clean_fatal_error(buff);
770
781
                    }
771
782
 
772
783
                    cnt++;
776
787
        }
777
788
 
778
789
        /* Close the file */
779
 
        if (G3d_closeCell(cf7) == 0) {
780
 
            sprintf(buff, "Error closing output file %s ", mcurv);
781
 
            clean_fatal_error(buff);
 
790
        if (Rast3d_close(cf7) == 0) {
 
791
            clean();
 
792
            G_fatal_error(_("Error closing output file %s"), mcurv);
782
793
        } else
783
794
            G_message(_("3D raster map <%s> created"), mcurv);
784
795
    }