2
*****************************************************************************
4
* MODULE: Grass Include Files
5
* AUTHOR(S): Original author unknown - probably CERL
6
* Justin Hickey - Thailand - jhickey@hpcc.nectec.or.th
7
* PURPOSE: This file contains definitions of variables and data types
8
* for use with most, if not all, Grass programs. This file is
9
* usually included in every Grass program.
10
* COPYRIGHT: (C) 2000 by the GRASS Development Team
12
* This program is free software under the GNU General Public
13
* License (>=v2). Read the file COPYING that comes with GRASS
16
*****************************************************************************/
21
/*============================= Include Files ==============================*/
23
/* System include files */
27
/* Grass and local include files */
28
#include <grass/config.h>
29
#include <grass/datetime.h>
31
/*=========================== Constants/Defines ============================*/
33
#if !defined __GNUC__ || __GNUC__ < 2
35
#define __attribute__(x)
38
static const char *GRASS_copyright __attribute__ ((unused))
39
= "GRASS GNU GPL licensed Software";
41
/* Define TRUE and FALSE for boolean comparisons */
53
#define RECLASS_TABLE 1
54
#define RECLASS_RULES 2
55
#define RECLASS_SCALE 3
65
#define PROJECTION_XY 0
66
#define PROJECTION_UTM 1
67
#define PROJECTION_SP 2
68
#define PROJECTION_LL 3
69
#define PROJECTION_OTHER 99
71
#define PROJECTION_FILE "PROJ_INFO"
72
#define UNIT_FILE "PROJ_UNITS"
74
/* define PI and friends */
76
#define M_PI 3.14159265358979323846 /* pi */
79
#define M_PI_2 1.57079632679489661923 /* pi/2 */
82
#define M_PI_4 0.78539816339744830962 /* pi/4 */
84
/* epsilon (IEEE: 2.220446e-16) */
85
#define GRASS_EPSILON 1.0e-15
87
/* Location of envariment variables */
89
#define G_VAR_MAPSET 1
91
/* Where to find/store variables */
92
#define G_GISRC_MODE_FILE 0 /* files */
93
#define G_GISRC_MODE_MEMORY 1 /* memory only */
96
#define TYPE_INTEGER 1
101
#define GISPROMPT_COLOR "color,grass,color"
103
/* File/directory name lengths */
104
#define GNAME_MAX 256
105
#define GMAPSET_MAX 256
107
#define GPATH_MAX 4096
109
/* Macros for type size independent integers */
110
/* Use these for portability to ensure integers are truly 32bit */
111
/* and are handled in a uniform manner */
113
/* Convert integer to 4 bytes - little endian */
114
#define serialize_int32_le(buf, x) do { \
115
(buf)[0] = ((x) >> 0) & 0xFF; \
116
(buf)[1] = ((x) >> 8) & 0xFF; \
117
(buf)[2] = ((x) >> 16) & 0xFF; \
118
(buf)[3] = ((x) >> 24) & 0xFF; \
121
/* Convert 4 bytes to an integer - little endian */
122
#define deserialize_int32_le(buf) (((buf)[0] << 0) | \
127
/* Convert integer to 4 bytes - big endian */
128
#define serialize_int32_be(buf, x) do { \
129
(buf)[0] = ((x) >> 24) & 0xFF; \
130
(buf)[1] = ((x) >> 16) & 0xFF; \
131
(buf)[2] = ((x) >> 8) & 0xFF; \
132
(buf)[3] = ((x) >> 0) & 0xFF; \
135
/* Convert 4 bytes to an integer - big endian */
136
#define deserialize_int32_be(buf) (((buf)[0] << 24) | \
141
/* Cross-platform Directory Separator Character and null device stuff */
142
#define GRASS_DIRSEP '/'
144
# define HOST_DIRSEP '\\'
145
# define G_DEV_NULL 'NUL:'
147
# define HOST_DIRSEP '/'
148
# define G_DEV_NULL '/dev/null'
153
G_OPT_WHERE, /* SQL where conditions */
154
G_OPT_COLUMN, /* one attr column */
155
G_OPT_COLUMNS, /* one or more attr columns */
157
G_OPT_I_GROUP, /* old input imagery group */
158
G_OPT_R_INPUT, /* old input raster map */
159
G_OPT_R_INPUTS, /* old input raster maps */
160
G_OPT_R_OUTPUT, /* new output raster map */
161
G_OPT_R_MAP, /* old input raster map */
162
G_OPT_R_MAPS, /* old input rasters map */
163
G_OPT_R_BASE, /* old input base raster map */
164
G_OPT_R_COVER, /* old input cover raster map */
165
G_OPT_R_ELEV, /* old input elevation raster map */
166
G_OPT_R_ELEVS, /* old input elevation raster maps */
168
G_OPT_R3_INPUT, /* old input raster3d map */
169
G_OPT_R3_INPUTS, /* old input raster3d maps */
170
G_OPT_R3_OUTPUT, /* new output raster3d map */
172
G_OPT_V_INPUT, /* old input vector map */
173
G_OPT_V_INPUTS, /* old input vector maps */
174
G_OPT_V_OUTPUT, /* new output vector map */
175
G_OPT_V_MAP, /* old input vector map */
176
G_OPT_V_TYPE, /* primitive type */
177
G_OPT_V_FIELD, /* field number */
178
G_OPT_V_CAT, /* one category */
179
G_OPT_V_CATS, /* more categories */
181
G_OPT_F_INPUT, /* old input file */
182
G_OPT_F_OUTPUT, /* new output file */
183
G_OPT_F_SEP, /* data field separator */
185
G_OPT_C_FG, /* foreground color */
186
G_OPT_C_BG /* background color */
190
#define G_INFO_FORMAT_STANDARD 0 /* GRASS_MESSAGE_FORMAT=standard or not defined */
191
#define G_INFO_FORMAT_GUI 1 /* GRASS_MESSAGE_FORMAT=gui */
192
#define G_INFO_FORMAT_SILENT 2 /* GRASS_MESSAGE_FORMAT=silent */
195
#define G_ICON_CROSS 0
197
#define G_ICON_ARROW 2
200
#define DEFAULT_FG_COLOR "black"
201
#define DEFAULT_BG_COLOR "white"
203
/* for G_get_raster_sample(), INTERP_TYPE */
205
#define NEAREST 1 /* nearest neighbor interpolation */
206
#define BILINEAR 2 /* bilinear interpolation */
207
#define CUBIC 3 /* cubic interpolation */
209
/* for raster maps */
210
#define GR_FATAL_EXIT 0
211
#define GR_FATAL_PRINT 1
212
#define GR_FATAL_RETURN 2
217
G_ELEMENT_RASTER = 1, /* cell */
218
G_ELEMENT_VECTOR = 2, /* vector */
219
G_ELEMENT_GROUP = 3, /* group */
220
G_ELEMENT_REGION = 4 /* window */
223
/*=========================== Typedefs/Structures ==========================*/
226
typedef double DCELL;
228
extern CELL CELL_NODATA;
230
typedef int RASTER_MAP_TYPE;
232
/* for G_get_raster_sample() */
233
typedef int INTERP_TYPE;
237
int format; /* max numer of bytes per cell minus 1 */
238
int compressed; /* 0 = uncompressed, 1 = compressed, -1 pre 3.0 */
239
int rows; /* number of rows in the data 2D */
240
int rows3; /* number of rows in the data 3D */
241
int cols; /* number of columns in the data 2D */
242
int cols3; /* number of columns in the data 3D */
243
int depths; /* number of depths in data */
244
int proj; /* Projection (see #defines above) */
245
int zone; /* Projection zone */
246
double ew_res; /* East to West cell size 2D */
247
double ew_res3; /* East to West cell size 3D */
248
double ns_res; /* North to South cell size 2D */
249
double ns_res3; /* North to South cell size 3D */
250
double tb_res; /* Top to Bottom cell size */
251
double north; /* coordinates of layer */
269
struct _Color_Rule_ *next;
270
struct _Color_Rule_ *prev;
275
struct _Color_Rule_ *rules;
291
/* pointers to color rules corresponding to the intervals btwn vals */
292
struct _Color_Rule_ **rules;
302
int version; /* set by read_colors: -1=old,1=new */
305
int is_float; /* defined on floating point raster data? */
306
int null_set; /* the colors for null are set? */
307
unsigned char null_red;
308
unsigned char null_grn;
309
unsigned char null_blu;
310
int undef_set; /* the colors for cells not in range are set? */
311
unsigned char undef_red;
312
unsigned char undef_grn;
313
unsigned char undef_blu;
314
struct _Color_Info_ fixed;
315
struct _Color_Info_ modular;
323
unsigned char r, g, b, a; /* red, green, blue, and alpha */
326
typedef RGBA_Color RGB_Color;
328
/* RGBA_Color alpha presets */
329
#define RGBA_COLOR_OPAQUE 255
330
#define RGBA_COLOR_TRANSPARENT 0
331
#define RGBA_COLOR_NONE 0
336
char *name; /* name of raster map being reclassed */
337
char *mapset; /* mapset in which "name" is found */
338
int type; /* type of reclass */
339
int num; /* size of reclass table */
340
CELL min; /* table min */
341
CELL max; /* table max */
342
CELL *table; /* reclass table */
345
struct FPReclass_table
347
DCELL dLow; /* domain low */
348
DCELL dHigh; /* domain high */
349
DCELL rLow; /* range low */
350
DCELL rHigh; /* range high */
353
/* reclass structure from double to double used by r.recode to reclass */
354
/* between types: int to double, float to int,... */
357
int defaultDRuleSet; /* 1 if default domain rule set */
358
int defaultRRuleSet; /* 1 if default range rule set */
359
int infiniteLeftSet; /* 1 if negative infinite interval rule exists */
360
int infiniteRightSet; /* 1 if positive infinite interval rule exists */
361
int rRangeSet; /* 1 if range range (i.e. interval) is set */
364
DCELL defaultDMin; /* default domain minimum value */
365
DCELL defaultDMax; /* default domain maximum value */
366
DCELL defaultRMin; /* default range minimum value */
367
DCELL defaultRMax; /* default range maximum value */
368
DCELL infiniteDLeft; /* neg infinite rule */
369
DCELL infiniteDRight; /* neg infinite rule */
370
DCELL infiniteRLeft; /* pos infinite rule */
371
DCELL infiniteRRight; /* pos infinite rule */
372
DCELL dMin; /* minimum domain values in rules */
373
DCELL dMax; /* maximum domain values in rules */
374
DCELL rMin; /* minimum range values in rules */
375
DCELL rMax; /* maximum range values in rules */
376
struct FPReclass_table *table;
394
int infiniteRightSet;
403
DCELL infiniteDRight;
410
struct Quant_table *table;
416
/* pointers to quant rules corresponding to the intervals btwn vals */
417
struct Quant_table **rules;
424
/* all values smaller than inf_dmin become inf_min */
425
/* all values larger than inf_dmax become inf_max */
426
/* inf_min and/or inf_max can be NULL if there are no inf rules */
432
CELL ncats; /* total number of categories */
433
CELL num; /* the highest cell values. Only exists
434
for backwards compatibility = (CELL)
435
max_fp_values in quant rules */
436
char *title; /* name of data layer */
437
char *fmt; /* printf-like format to generate labels */
438
float m1; /* Multiplication coefficient 1 */
439
float a1; /* Addition coefficient 1 */
440
float m2; /* Multiplication coefficient 2 */
441
float a2; /* Addition coefficient 2 */
442
struct Quant q; /* rules mapping cell values to index in
444
char **labels; /* array of labels of size num */
445
int *marks; /* was the value with this label was used? */
447
int last_marked_rule;
448
/* NOTE: to get a rule corresponfing to cats.labels[i], use */
449
/* G_get_ith_c/f/d_raster_cat (pcats, i, val1, val2) */
451
/* G_quant_get_ith_rule(&cats->q, i, val1, val2, &index, &index); */
452
/* and idex ==i, because rule is added at the same time as a */
453
/* label, and quant rules are never reordered. Olga apr,95 */
458
char mapid[RECORD_LEN];
459
char title[RECORD_LEN];
460
char mapset[RECORD_LEN];
461
char creator[RECORD_LEN];
462
char maptype[RECORD_LEN];
463
char datsrc_1[RECORD_LEN];
464
char datsrc_2[RECORD_LEN];
465
char keywrd[RECORD_LEN];
467
char edhist[MAXEDLINES][RECORD_LEN];
472
struct Cell_stats_node
478
} *node; /* tree of values */
480
int tlen; /* allocated tree size */
481
int N; /* number of actual nodes in tree */
483
long null_data_count;
491
struct Histogram_list
502
int first_time; /* whether or not range was updated */
509
int first_time; /* whether or not range was updated */
513
** Structure for I/O of 3dview files (view.c)
517
char pgm_id[40]; /* user-provided identifier */
518
float from_to[2][3]; /* eye position & lookat position */
519
float fov; /* field of view */
520
float twist; /* right_hand rotation about from_to */
521
float exag; /* terrain elevation exageration */
522
int mesh_freq; /* cells per grid line */
523
int poly_freq; /* cells per polygon */
524
int display_type; /* 1 for mesh, 2 for poly, 3 for both */
525
int lightson; /* boolean */
526
int dozero; /* boolean */
527
int colorgrid; /* boolean */
528
int shading; /* boolean */
529
int fringe; /* boolean */
530
int surfonly; /* boolean */
531
int doavg; /* boolean */
532
char grid_col[40]; /* colors */
533
char bg_col[40]; /* colors */
534
char other_col[40]; /* colors */
535
float lightpos[4]; /* east, north, height, 1.0 for local 0.0 infin */
536
float lightcol[3]; /* values between 0.0 to 1.0 for red, grn, blu */
539
struct Cell_head vwin;
550
struct Option /* Structure that stores option info */
552
char *key; /* Key word used on command line */
553
int type; /* Option type */
554
int required; /* REQUIRED or OPTIONAL */
555
int multiple; /* Multiple entries OK */
556
char *options; /* Approved values or range or NULL */
557
char **opts; /* NULL or NULL terminated array of parsed options */
558
char *key_desc; /* one word describing the key */
559
char *label; /* Optional short label, used in GUI as item label */
560
char *description; /* String describing option */
561
char *descriptions; /* ';' separated pairs of option and option descriptions */
562
/* For example: (with ->options = "break,rmdupl")
563
* "break;break lines on intersections;"
564
* "rmdupl;remove duplicates"
566
char **descs; /* parsed descriptions, array of either NULL or string */
567
/* in the same order as options */
568
char *answer; /* Option answer */
569
char *def; /* Where original answer gets saved */
570
char **answers; /* Option answers (for multiple=YES) */
571
struct Option *next_opt; /* Pointer to next option struct */
572
char *gisprompt; /* Interactive prompt guidance */
573
char *guisection; /* GUI Layout guidance: ';' delimited heirarchical tree position */
574
int (*checker) (); /* Routine to check answer or NULL */
578
struct Flag /* Structure that stores flag info */
580
char key; /* Key char used on command line */
581
char answer; /* Stores flag state: 0/1 */
582
char *label; /* Optional short label, used in GUI as item label */
583
char *description; /* String describing flag meaning */
584
char *guisection; /* GUI Layout guidance: ';' delimited heirarchical tree position */
585
struct Flag *next_flag; /* Pointer to next flag struct */
588
struct GModule /* Structure that stores module info */
590
char *label; /* Optional short description for GUI */
591
char *description; /* String describing module */
592
char *keywords; /* Keywords describing module */
593
/* further items are possible: author(s), version */
594
int overwrite; /* overwrite old files */
595
int verbose; /* print all informations about progress and so on */
600
DateTime dt[2]; /* two datetimes */
604
/*============================== Prototypes ================================*/
606
/* Since there are so many prototypes for the gis library they are stored */
607
/* in the file gisdefs.h */
608
#include <grass/gisdefs.h>
610
#endif /* GRASS_GIS_H */