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

« back to all changes in this revision

Viewing changes to lib/raster3d/param.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 <string.h>
 
2
#include <grass/gis.h>
 
3
#include <grass/glocale.h>
 
4
#include "raster3d_intern.h"
 
5
 
 
6
/*----------------------------------------------------------------------------*/
 
7
 
 
8
typedef struct
 
9
{
 
10
 
 
11
    struct Option *type;
 
12
    struct Option *precision;
 
13
    struct Option *compression;
 
14
    struct Option *dimension;
 
15
    struct Option *cache;
 
16
 
 
17
} Rast3d_paramType;
 
18
 
 
19
/*----------------------------------------------------------------------------*/
 
20
 
 
21
static Rast3d_paramType *param;
 
22
 
 
23
 
 
24
/*!
 
25
 * \brief 
 
26
 *
 
27
 * Initializes a parameter
 
28
 * structure for the subset of command line arguments which lets the user
 
29
 * overwrite the default properties of the new file.  Applications are
 
30
 * encouraged to use this function in order to provide a uniform style.  The
 
31
 * command line arguments provided are the <em>type</em> of the cell values, the
 
32
 * <em>precision</em>, the properties of the <em>compression</em>, and the dimension
 
33
 * of the tiles (<em>tiledimension</em>). Every of these values defaults to the
 
34
 * value described in RASTER3D Defaults.
 
35
 * This function has to be used in conjunction with
 
36
 * Rast3d_getStandard3dInputParams() (cf.{g3d:G3d.getStandard3dInputParams}).
 
37
 *
 
38
 *  \return void
 
39
 */
 
40
 
 
41
void Rast3d_set_standard3d_input_params()
 
42
{
 
43
    param = Rast3d_malloc(sizeof(Rast3d_paramType));
 
44
 
 
45
    param->type = G_define_standard_option(G_OPT_R3_TYPE);
 
46
 
 
47
    param->precision = G_define_standard_option(G_OPT_R3_PRECISION);
 
48
 
 
49
    param->compression = G_define_standard_option(G_OPT_R3_COMPRESSION);
 
50
 
 
51
    param->dimension = G_define_standard_option(G_OPT_R3_TILE_DIMENSION);
 
52
}
 
53
 
 
54
/*----------------------------------------------------------------------------*/
 
55
 
 
56
int Rast3d_get_standard3d_params(int *useTypeDefault, int *type,
 
57
                            int *useCompressionDefault, int *doCompression,
 
58
                            int *usePrecisionDefault, int *precision,
 
59
                            int *useDimensionDefault, int *tileX, int *tileY,
 
60
                            int *tileZ)
 
61
{
 
62
 
 
63
    *useTypeDefault = *useCompressionDefault = 0;
 
64
    *usePrecisionDefault = *useDimensionDefault = 0;
 
65
 
 
66
    Rast3d_init_defaults();
 
67
 
 
68
    if (strcmp(param->type->answer, "double") == 0)
 
69
        *type = DCELL_TYPE;
 
70
    else if (strcmp(param->type->answer, "float") == 0)
 
71
        *type = FCELL_TYPE;
 
72
    else {
 
73
        *type = Rast3d_get_file_type();
 
74
        *useTypeDefault = 1;
 
75
    }
 
76
 
 
77
    Rast3d_get_compression_mode(doCompression, precision);
 
78
 
 
79
    if (strcmp(param->precision->answer, "default") != 0) {
 
80
        if (strcmp(param->precision->answer, "max") == 0)
 
81
            *precision = -1;
 
82
        else if ((sscanf(param->precision->answer, "%d", precision) != 1) ||
 
83
                 (*precision < 0)) {
 
84
            Rast3d_error(_("Rast3d_get_standard3d_params: precision value invalid"));
 
85
            return 0;
 
86
        }
 
87
        }
 
88
        else
 
89
        *usePrecisionDefault = 1;
 
90
 
 
91
 
 
92
        if (strcmp(param->compression->answer, "default") != 0) {
 
93
                if (strcmp(param->compression->answer, "zip") == 0)
 
94
                        *doCompression = RASTER3D_COMPRESSION;
 
95
                else
 
96
                        *doCompression = RASTER3D_NO_COMPRESSION;
 
97
        } else {
 
98
                *useCompressionDefault = 1;
 
99
        }
 
100
 
 
101
    Rast3d_get_tile_dimension(tileX, tileY, tileZ);
 
102
    if (strcmp(param->dimension->answer, "default") != 0) {
 
103
        if (sscanf(param->dimension->answer, "%dx%dx%d",
 
104
                   tileX, tileY, tileZ) != 3) {
 
105
            Rast3d_error(_("Rast3d_get_standard3d_params: tile dimension value invalid"));
 
106
            return 0;
 
107
        }
 
108
    }
 
109
    else
 
110
        *useDimensionDefault = 1;
 
111
 
 
112
    Rast3d_free(param);
 
113
 
 
114
    return 1;
 
115
}
 
116
 
 
117
/*----------------------------------------------------------------------------*/
 
118
 
 
119
static struct Option *windowParam = NULL;
 
120
 
 
121
void Rast3d_set_window_params(void)
 
122
{
 
123
    windowParam = G_define_option();
 
124
    windowParam->key = "region3";
 
125
    windowParam->type = TYPE_STRING;
 
126
    windowParam->required = NO;
 
127
    windowParam->multiple = NO;
 
128
    windowParam->answer = NULL;
 
129
    windowParam->description = _("Window replacing the default");
 
130
}
 
131
 
 
132
/*----------------------------------------------------------------------------*/
 
133
 
 
134
char *Rast3d_get_window_params(void)
 
135
{
 
136
    if (windowParam == NULL)
 
137
        return NULL;
 
138
    if (windowParam->answer == NULL)
 
139
        return NULL;
 
140
    if (strcmp(windowParam->answer, RASTER3D_WINDOW_ELEMENT) == 0)
 
141
        return G_store(RASTER3D_WINDOW_ELEMENT);
 
142
    return G_store(windowParam->answer);
 
143
}