GRASS 8 Programmer's Manual 8.6.0dev(2026)-ddeab64dbf
Loading...
Searching...
No Matches
param.c
Go to the documentation of this file.
1#include <string.h>
2#include <grass/gis.h>
3#include <grass/glocale.h>
4#include "raster3d_intern.h"
5
6/*----------------------------------------------------------------------------*/
7
8typedef struct {
9
10 struct Option *type;
11 struct Option *precision;
12 struct Option *compression;
13 struct Option *dimension;
14 struct Option *cache;
15
16} Rast3d_paramType;
17
18/*----------------------------------------------------------------------------*/
19
20static Rast3d_paramType *param;
21
22/*!
23 * \brief
24 *
25 * Initializes a parameter
26 * structure for the subset of command line arguments which lets the user
27 * overwrite the default properties of the new file. Applications are
28 * encouraged to use this function in order to provide a uniform style. The
29 * command line arguments provided are the <em>type</em> of the cell values, the
30 * <em>precision</em>, the properties of the <em>compression</em>, and the
31 * dimension of the tiles (<em>tiledimension</em>). Every of these values
32 * defaults to the value described in RASTER3D Defaults. This function has to be
33 * used in conjunction with Rast3d_getStandard3dInputParams()
34 * (cf.{g3d:G3d.getStandard3dInputParams}).
35 *
36 * \return void
37 */
39{
40 param = Rast3d_malloc(sizeof(Rast3d_paramType));
41
43
45
47
49}
50
51/*----------------------------------------------------------------------------*/
52
55 int *usePrecisionDefault, int *precision,
56 int *useDimensionDefault, int *tileX,
57 int *tileY, int *tileZ)
58{
59
62
64
65 if (strcmp(param->type->answer, "double") == 0)
67 else if (strcmp(param->type->answer, "float") == 0)
69 else {
71 *useTypeDefault = 1;
72 }
73
75
76 if (strcmp(param->precision->answer, "default") != 0) {
77 if (strcmp(param->precision->answer, "max") == 0)
78 *precision = -1;
79 else if ((sscanf(param->precision->answer, "%d", precision) != 1) ||
80 (*precision < 0)) {
82 _("Rast3d_get_standard3d_params: precision value invalid"));
83 return 0;
84 }
85 }
86 else
88
89 if (strcmp(param->compression->answer, "default") != 0) {
90 if (strcmp(param->compression->answer, "zip") == 0)
92 else
94 }
95 else {
97 }
98
99 Rast3d_get_tile_dimension(tileX, tileY, tileZ);
100 if (strcmp(param->dimension->answer, "default") != 0) {
101 if (sscanf(param->dimension->answer, "%dx%dx%d", tileX, tileY, tileZ) !=
102 3) {
104 "Rast3d_get_standard3d_params: tile dimension value invalid"));
105 return 0;
106 }
107 }
108 else
110
111 Rast3d_free(param);
112
113 return 1;
114}
115
116/*----------------------------------------------------------------------------*/
117
118static struct Option *windowParam = NULL;
119
121{
122 windowParam = G_define_option();
123 windowParam->key = "region3";
124 windowParam->type = TYPE_STRING;
125 windowParam->required = NO;
126 windowParam->multiple = NO;
127 windowParam->answer = NULL;
128 windowParam->description = _("Window replacing the default");
129}
130
131/*----------------------------------------------------------------------------*/
132
134{
135 if (windowParam == NULL)
136 return NULL;
137 if (windowParam->answer == NULL)
138 return NULL;
139 if (strcmp(windowParam->answer, RASTER3D_WINDOW_ELEMENT) == 0)
141 return G_store(windowParam->answer);
142}
#define NULL
Definition ccmath.h:32
struct Option * G_define_standard_option(int)
Create standardised Option structure.
struct Option * G_define_option(void)
Initializes an Option struct.
Definition parser.c:210
char * G_store(const char *)
Copy string to allocated memory.
Definition strings.c:87
void Rast3d_free(void *)
Same as free (ptr).
void Rast3d_get_tile_dimension(int *, int *, int *)
get Tile Dimension
Definition defaults.c:252
int Rast3d_get_file_type(void)
get G3d file type
Definition defaults.c:212
void Rast3d_get_compression_mode(int *, int *)
Gets compression mode.
Definition defaults.c:125
void Rast3d_init_defaults(void)
Initializes the default values described in RASTER3D Defaults. Applications have to use this function...
Definition defaults.c:282
void * Rast3d_malloc(int)
Same as malloc (nBytes), except that in case of error Rast3d_error() is invoked.
void Rast3d_error(const char *,...) __attribute__((format(printf
#define TYPE_STRING
Definition gis.h:191
@ G_OPT_R3_TYPE
Definition gis.h:298
@ G_OPT_R3_PRECISION
Definition gis.h:299
@ G_OPT_R3_TILE_DIMENSION
Definition gis.h:300
@ G_OPT_R3_COMPRESSION
Definition gis.h:302
#define NO
Definition gis.h:193
#define _(str)
Definition glocale.h:10
unsigned short compression
Definition gsd_img_tif.c:42
char * Rast3d_get_window_params(void)
Definition param.c:133
int Rast3d_get_standard3d_params(int *useTypeDefault, int *type, int *useCompressionDefault, int *doCompression, int *usePrecisionDefault, int *precision, int *useDimensionDefault, int *tileX, int *tileY, int *tileZ)
Definition param.c:53
void Rast3d_set_standard3d_input_params(void)
Initializes a parameter structure for the subset of command line arguments which lets the user overwr...
Definition param.c:38
void Rast3d_set_window_params(void)
Definition param.c:120
#define RASTER3D_COMPRESSION
Definition raster3d.h:14
#define RASTER3D_NO_COMPRESSION
Definition raster3d.h:13
#define RASTER3D_WINDOW_ELEMENT
Definition raster3d.h:40
#define FCELL_TYPE
Definition raster.h:12
#define DCELL_TYPE
Definition raster.h:13
Structure that stores option information.
Definition gis.h:563
int type
Definition gis.h:565