3
#include <grass/glocale.h>
4
#include "raster3d_intern.h"
6
/*----------------------------------------------------------------------------*/
12
struct Option *precision;
13
struct Option *compression;
14
struct Option *dimension;
19
/*----------------------------------------------------------------------------*/
21
static Rast3d_paramType *param;
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}).
41
void Rast3d_set_standard3d_input_params()
43
param = Rast3d_malloc(sizeof(Rast3d_paramType));
45
param->type = G_define_standard_option(G_OPT_R3_TYPE);
47
param->precision = G_define_standard_option(G_OPT_R3_PRECISION);
49
param->compression = G_define_standard_option(G_OPT_R3_COMPRESSION);
51
param->dimension = G_define_standard_option(G_OPT_R3_TILE_DIMENSION);
54
/*----------------------------------------------------------------------------*/
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,
63
*useTypeDefault = *useCompressionDefault = 0;
64
*usePrecisionDefault = *useDimensionDefault = 0;
66
Rast3d_init_defaults();
68
if (strcmp(param->type->answer, "double") == 0)
70
else if (strcmp(param->type->answer, "float") == 0)
73
*type = Rast3d_get_file_type();
77
Rast3d_get_compression_mode(doCompression, precision);
79
if (strcmp(param->precision->answer, "default") != 0) {
80
if (strcmp(param->precision->answer, "max") == 0)
82
else if ((sscanf(param->precision->answer, "%d", precision) != 1) ||
84
Rast3d_error(_("Rast3d_get_standard3d_params: precision value invalid"));
89
*usePrecisionDefault = 1;
92
if (strcmp(param->compression->answer, "default") != 0) {
93
if (strcmp(param->compression->answer, "zip") == 0)
94
*doCompression = RASTER3D_COMPRESSION;
96
*doCompression = RASTER3D_NO_COMPRESSION;
98
*useCompressionDefault = 1;
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"));
110
*useDimensionDefault = 1;
117
/*----------------------------------------------------------------------------*/
119
static struct Option *windowParam = NULL;
121
void Rast3d_set_window_params(void)
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");
132
/*----------------------------------------------------------------------------*/
134
char *Rast3d_get_window_params(void)
136
if (windowParam == NULL)
138
if (windowParam->answer == NULL)
140
if (strcmp(windowParam->answer, RASTER3D_WINDOW_ELEMENT) == 0)
141
return G_store(RASTER3D_WINDOW_ELEMENT);
142
return G_store(windowParam->answer);