gis.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. /*
  2. *****************************************************************************
  3. *
  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-2022 by the GRASS Development Team
  11. *
  12. * This program is free software under the GNU General Public
  13. * License (>=v2). Read the file COPYING that comes with GRASS
  14. * for details.
  15. *
  16. *****************************************************************************/
  17. #ifndef GRASS_GIS_H
  18. #define GRASS_GIS_H
  19. /*============================= Include Files ==============================*/
  20. /* System include files */
  21. #include <stdio.h>
  22. #include <stdarg.h>
  23. #include <stdbool.h>
  24. /* Grass and local include files */
  25. #include <grass/config.h>
  26. #include <grass/datetime.h>
  27. #include <grass/version.h>
  28. /*=========================== Constants/Defines ============================*/
  29. #if !defined __GNUC__ || __GNUC__ < 2
  30. #undef __attribute__
  31. #define __attribute__(x)
  32. #endif
  33. static const char *GRASS_copyright __attribute__ ((unused))
  34. = "GRASS GNU GPL licensed Software";
  35. /* GRASS version, GRASS date, git short hash of last change in GRASS headers
  36. * (and anything else in include)
  37. */
  38. #define GIS_H_VERSION GRASS_HEADERS_VERSION
  39. /* git date of last change in GRASS headers
  40. * (and anything else in include)
  41. */
  42. #define GIS_H_DATE GRASS_HEADERS_DATE
  43. #define G_gisinit(pgm) G__gisinit(GIS_H_VERSION, (pgm))
  44. #define G_no_gisinit() G__no_gisinit(GIS_H_VERSION)
  45. /* For boolean values and comparisons use the C99 type 'bool' with values 'true' */
  46. /* and 'false' For historical reasons 'TRUE' and 'FALSE' are still valid. */
  47. #ifndef TRUE
  48. #define TRUE true
  49. #endif
  50. #ifndef FALSE
  51. #define FALSE false
  52. #endif
  53. #if (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) || (__APPLE__ && __LP64__)
  54. #define PRI_OFF_T "lld"
  55. #else
  56. #define PRI_OFF_T "ld"
  57. #endif
  58. /*! \brief Cross-platform Newline Character */
  59. #define NEWLINE '\n'
  60. #ifdef __MINGW32__
  61. # define HOST_NEWLINE "\r\n"
  62. #else
  63. # define HOST_NEWLINE "\n"
  64. #endif
  65. /*! \brief Generate warning if function return value is unused */
  66. #if __GNUC__ && (__GNUC__ >= 3 && __GNUC_MINOR__ >= 4)
  67. # define WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
  68. #else
  69. # define WARN_UNUSED_RESULT
  70. #endif
  71. /*!
  72. \brief List of units
  73. */
  74. #define U_UNDEFINED -1
  75. #define U_UNKNOWN 0
  76. #define U_ACRES 1
  77. #define U_HECTARES 2
  78. #define U_KILOMETERS 3
  79. #define U_METERS 4
  80. #define U_MILES 5
  81. #define U_FEET 6
  82. #define U_RADIANS 7
  83. #define U_DEGREES 8
  84. #define U_USFEET 9
  85. /* Temporal units from the datetime library */
  86. #define U_YEARS DATETIME_YEAR
  87. #define U_MONTHS DATETIME_MONTH
  88. #define U_DAYS DATETIME_DAY
  89. #define U_HOURS DATETIME_HOUR
  90. #define U_MINUTES DATETIME_MINUTE
  91. #define U_SECONDS DATETIME_SECOND
  92. /*! \brief Projection code - XY coordinate system (unreferenced data) */
  93. #define PROJECTION_XY 0
  94. /*! \brief Projection code - UTM */
  95. #define PROJECTION_UTM 1
  96. /*! \brief Projection code - State Plane */
  97. #define PROJECTION_SP 2
  98. /*! \brief Projection code - Latitude-Longitude */
  99. #define PROJECTION_LL 3
  100. /*! \brief Projection code - other projection (other then noted above) */
  101. #define PROJECTION_OTHER 99
  102. #define PROJECTION_FILE "PROJ_INFO"
  103. #define UNIT_FILE "PROJ_UNITS"
  104. #define EPSG_FILE "PROJ_EPSG"
  105. #define WKT_FILE "PROJ_WKT"
  106. #define SRID_FILE "PROJ_SRID"
  107. #ifdef __MINGW32__
  108. #define CONFIG_DIR "GRASS8"
  109. #else
  110. #define CONFIG_DIR ".grass8"
  111. #endif
  112. #ifdef MAX
  113. #undef MAX
  114. #endif
  115. #define MAX(a, b) ((a) > (b) ? (a) : (b))
  116. #ifdef MIN
  117. #undef MIN
  118. #endif
  119. #define MIN(a, b) ((a) < (b) ? (a) : (b))
  120. /* define PI and friends */
  121. #undef M_PI
  122. #define M_PI 3.14159265358979323846 /* pi */
  123. #undef M_PI_2
  124. #define M_PI_2 1.57079632679489661923 /* pi/2 */
  125. #undef M_PI_4
  126. #define M_PI_4 0.78539816339744830962 /* pi/4 */
  127. #undef M_R2D
  128. #define M_R2D 57.295779513082320877 /* 180/pi */
  129. #undef M_D2R
  130. #define M_D2R 0.017453292519943295769 /* pi/180 */
  131. /* epsilon (IEEE: 2.220446e-16) */
  132. #define GRASS_EPSILON 1.0e-15
  133. /* Location of envariment variables */
  134. #define G_VAR_GISRC 0
  135. #define G_VAR_MAPSET 1
  136. /* Where to find/store variables */
  137. #define G_GISRC_MODE_FILE 0 /* files */
  138. #define G_GISRC_MODE_MEMORY 1 /* memory only */
  139. /* for G_parser() */
  140. #define TYPE_INTEGER 1
  141. #define TYPE_DOUBLE 2
  142. #define TYPE_STRING 3
  143. #define YES 1
  144. #define NO 0
  145. /* File/directory name lengths */
  146. #define GNAME_MAX 256
  147. #define GMAPSET_MAX 256
  148. #define GPATH_MAX 4096
  149. /* Basename default separator */
  150. #define GBASENAME_SEP "_"
  151. /* Macros for type size independent integers */
  152. /* Use these for portability to ensure integers are truly 32bit */
  153. /* and are handled in a uniform manner */
  154. /* Convert integer to 4 bytes - little endian */
  155. #define serialize_int32_le(buf, x) do { \
  156. (buf)[0] = ((x) >> 0) & 0xFF; \
  157. (buf)[1] = ((x) >> 8) & 0xFF; \
  158. (buf)[2] = ((x) >> 16) & 0xFF; \
  159. (buf)[3] = ((x) >> 24) & 0xFF; \
  160. } while(0)
  161. /* Convert 4 bytes to an integer - little endian */
  162. #define deserialize_int32_le(buf) (((buf)[0] << 0) | \
  163. ((buf)[1] << 8) | \
  164. ((buf)[2] << 16) | \
  165. ((buf)[3] << 24))
  166. /* Convert integer to 4 bytes - big endian */
  167. #define serialize_int32_be(buf, x) do { \
  168. (buf)[0] = ((x) >> 24) & 0xFF; \
  169. (buf)[1] = ((x) >> 16) & 0xFF; \
  170. (buf)[2] = ((x) >> 8) & 0xFF; \
  171. (buf)[3] = ((x) >> 0) & 0xFF; \
  172. } while(0)
  173. /* Convert 4 bytes to an integer - big endian */
  174. #define deserialize_int32_be(buf) (((buf)[0] << 24) | \
  175. ((buf)[1] << 16) | \
  176. ((buf)[2] << 8) | \
  177. ((buf)[3] << 0))
  178. /* Cross-platform Directory Separator Character and null device stuff */
  179. #define GRASS_DIRSEP '/'
  180. #ifdef __MINGW32__
  181. # define HOST_DIRSEP '\\'
  182. # define G_DEV_NULL "NUL:"
  183. #else
  184. # define HOST_DIRSEP '/'
  185. # define G_DEV_NULL "/dev/null"
  186. #endif
  187. /*!
  188. \typedef STD_OPT
  189. \brief Standard option identifiers (enum)
  190. Identifies of all recognized standard options.
  191. The term <em>old</em> in the descriptions means existing map which
  192. is supposed to exist before the module is called.
  193. On the other hand, the term <em>new</em> in the descriptions means
  194. that the map is not supposed to exist and that module will create one.
  195. Used by the G_parser() system.
  196. IMPORTANT NOTE: when adding new item to STD_OPT you should also
  197. update STD_OPT_STRINGS array in general/g.parser/standard_option.c.
  198. */
  199. typedef enum
  200. {
  201. G_OPT_UNDEFINED,
  202. G_OPT_DB_SQL, /*!< SQL statements */
  203. G_OPT_DB_WHERE, /*!< SQL where conditions */
  204. G_OPT_DB_TABLE, /*!< table name */
  205. G_OPT_DB_DRIVER, /*!< driver name */
  206. G_OPT_DB_DATABASE, /*!< database name */
  207. G_OPT_DB_SCHEMA, /*!< database schema */
  208. G_OPT_DB_COLUMN, /*!< one attr column */
  209. G_OPT_DB_COLUMNS, /*!< one or more attr columns */
  210. G_OPT_DB_KEYCOLUMN, /*!< key column */
  211. G_OPT_I_GROUP, /*!< old input imagery group */
  212. G_OPT_I_SUBGROUP, /*!< old input imagery subgroup */
  213. G_OPT_MEMORYMB, /*!< Maximum memory to be used (in MB): cache size for raster rows */
  214. G_OPT_R_INPUT, /*!< old input raster map */
  215. G_OPT_R_INPUTS, /*!< old input raster maps */
  216. G_OPT_R_OUTPUT, /*!< new output raster map */
  217. G_OPT_R_OUTPUTS, /*!< new output raster maps */
  218. G_OPT_R_MAP, /*!< old input raster map */
  219. G_OPT_R_MAPS, /*!< old input rasters map */
  220. G_OPT_R_BASE, /*!< old input base raster map */
  221. G_OPT_R_COVER, /*!< old input cover raster map */
  222. G_OPT_R_ELEV, /*!< old input elevation raster map */
  223. G_OPT_R_ELEVS, /*!< old input elevation raster maps */
  224. G_OPT_R_TYPE, /*!< raster map type */
  225. G_OPT_R_INTERP_TYPE, /*!< interpolation type */
  226. G_OPT_R_BASENAME_INPUT, /*!< old input basename raster maps */
  227. G_OPT_R_BASENAME_OUTPUT, /*!< new output basename raster maps */
  228. G_OPT_R3_INPUT, /*!< old input raster3d map */
  229. G_OPT_R3_INPUTS, /*!< old input raster3d maps */
  230. G_OPT_R3_OUTPUT, /*!< new output raster3d map */
  231. G_OPT_R3_MAP, /*!< old input raster3d map */
  232. G_OPT_R3_MAPS, /*!< old input raster3d maps */
  233. G_OPT_R3_TYPE, /*!< Type (FCELL or DCELL) of a new created raster3d map */
  234. G_OPT_R3_PRECISION, /*!< The precision of the new generated raster3d map */
  235. G_OPT_R3_TILE_DIMENSION, /*!< The tile dimension of a new generated raster3d map */
  236. G_OPT_R3_COMPRESSION, /*!< The kind of compression of a new created raster3d map */
  237. G_OPT_V_INPUT, /*!< old input vector map */
  238. G_OPT_V_INPUTS, /*!< old input vector maps */
  239. G_OPT_V_OUTPUT, /*!< new output vector map */
  240. G_OPT_V_MAP, /*!< old input vector map */
  241. G_OPT_V_MAPS, /*!< old input vector maps */
  242. G_OPT_V_TYPE, /*!< primitive type */
  243. G_OPT_V3_TYPE, /*!< primitive type, 2D and 3D */
  244. G_OPT_V_FIELD, /*!< layer number (layers used to be called fields) */
  245. G_OPT_V_FIELD_ALL, /*!< layer number (layers used to be called fields) */
  246. G_OPT_V_CAT, /*!< one category */
  247. G_OPT_V_CATS, /*!< more categories */
  248. G_OPT_V_ID, /*!< one feature id */
  249. G_OPT_V_IDS, /*!< more feature ids */
  250. G_OPT_F_INPUT, /*!< old input file */
  251. G_OPT_F_BIN_INPUT, /*!< old binary input file */
  252. G_OPT_F_OUTPUT, /*!< new output file */
  253. G_OPT_F_SEP, /*!< data field separator */
  254. G_OPT_C, /*!< color */
  255. G_OPT_CN, /*!< color or none */
  256. G_OPT_M_UNITS, /*!< units */
  257. G_OPT_M_DATATYPE, /*!< datatype */
  258. G_OPT_M_MAPSET, /*!< mapset */
  259. G_OPT_M_LOCATION, /*!< location */
  260. G_OPT_M_DBASE, /*!< dbase */
  261. G_OPT_M_COORDS, /*!< coordinates */
  262. G_OPT_M_COLR, /*!< color rules */
  263. G_OPT_M_DIR, /*!< directory input */
  264. G_OPT_M_REGION, /*!< saved region */
  265. G_OPT_M_NULL_VALUE, /*!< null value string */
  266. G_OPT_M_NPROCS, /*!< number of threads for parallel computing */
  267. G_OPT_STDS_INPUT, /*!< old input space time dataset of type strds, str3ds or stvds */
  268. G_OPT_STDS_INPUTS, /*!< old input space time datasets */
  269. G_OPT_STDS_OUTPUT, /*!< new output space time dataset */
  270. G_OPT_STRDS_INPUT, /*!< old input space time raster dataset */
  271. G_OPT_STRDS_INPUTS, /*!< old input space time raster datasets */
  272. G_OPT_STRDS_OUTPUT, /*!< new output space time raster dataset */
  273. G_OPT_STRDS_OUTPUTS, /*!< new output space time raster datasets */
  274. G_OPT_STR3DS_INPUT, /*!< old input space time raster3d dataset */
  275. G_OPT_STR3DS_INPUTS, /*!< old input space time raster3d datasets */
  276. G_OPT_STR3DS_OUTPUT, /*!< new output space time raster3d dataset */
  277. G_OPT_STVDS_INPUT, /*!< old input space time vector dataset */
  278. G_OPT_STVDS_INPUTS, /*!< old input space time vector datasets */
  279. G_OPT_STVDS_OUTPUT, /*!< new output space time vector dataset */
  280. G_OPT_MAP_INPUT, /*!< old input map of type raster, vector or raster3d */
  281. G_OPT_MAP_INPUTS, /*!< old input maps of type raster, vector or raster3d */
  282. G_OPT_STDS_TYPE, /*!< the type of a space time dataset: strds, str3ds, stvds */
  283. G_OPT_MAP_TYPE, /*!< The type of an input map: raster, vect, rast3d */
  284. G_OPT_T_TYPE, /*!< The temporal type of a space time dataset */
  285. G_OPT_T_WHERE, /*!< A temporal GIS framework SQL WHERE statement */
  286. G_OPT_T_SAMPLE /*!< Temporal sample methods */
  287. } STD_OPT;
  288. /*!
  289. \typedef STD_FLG
  290. \brief Standard flag identifiers (enum)
  291. Identifies of all recognized standard flags.
  292. Used by the G_parser() system.
  293. */
  294. /**/ typedef enum
  295. {
  296. G_FLG_UNDEFINED,
  297. G_FLG_V_TABLE, /*!< do not create attribute table */
  298. G_FLG_V_TOPO /*!< do not build topology */
  299. } STD_FLG;
  300. /* Parser rules for G__option_rule() */
  301. enum rule_type {
  302. RULE_EXCLUSIVE,
  303. RULE_REQUIRED,
  304. RULE_REQUIRES,
  305. RULE_REQUIRES_ALL,
  306. RULE_EXCLUDES,
  307. RULE_COLLECTIVE
  308. };
  309. /* Message format */
  310. #define G_INFO_FORMAT_STANDARD 0 /* GRASS_MESSAGE_FORMAT=standard or not defined */
  311. #define G_INFO_FORMAT_GUI 1 /* GRASS_MESSAGE_FORMAT=gui */
  312. #define G_INFO_FORMAT_SILENT 2 /* GRASS_MESSAGE_FORMAT=silent */
  313. #define G_INFO_FORMAT_PLAIN 3 /* GRASS_MESSAGE_FORMAT=plain */
  314. /* Icon types */
  315. #define G_ICON_CROSS 0
  316. #define G_ICON_BOX 1
  317. #define G_ICON_ARROW 2
  318. /* default colors */
  319. #define DEFAULT_FG_COLOR "black"
  320. #define DEFAULT_BG_COLOR "white"
  321. #define DEFAULT_COLOR_TABLE "viridis"
  322. /* error codes */
  323. #define G_FATAL_EXIT 0
  324. #define G_FATAL_PRINT 1
  325. #define G_FATAL_RETURN 2
  326. /*! \brief Endian check */
  327. #define ENDIAN_LITTLE 0
  328. #define ENDIAN_BIG 1
  329. #define ENDIAN_OTHER 2
  330. /* for vector maps */
  331. /*!
  332. \brief Name of default key column
  333. */
  334. #define GV_KEY_COLUMN "cat"
  335. /*!
  336. \brief Element types identifiers (enum)
  337. Identifies various element types. Element can be raster map,
  338. vector map, etc.
  339. */
  340. enum
  341. { /* Dir */
  342. G_ELEMENT_RASTER = 1, /*!< raster */
  343. G_ELEMENT_RASTER3D = 2, /*!< 3d raster */
  344. G_ELEMENT_VECTOR = 3, /*!< vector */
  345. G_ELEMENT_ASCIIVECTOR = 4, /*!< ASCII vector */
  346. G_ELEMENT_LABEL = 5, /*!< labels */
  347. G_ELEMENT_REGION = 6, /*!< region */
  348. G_ELEMENT_GROUP = 7 /*!< group */
  349. };
  350. /*=========================== Typedefs/Structures ==========================*/
  351. /*!
  352. \brief 2D/3D raster map header (used also for region)
  353. */
  354. struct Cell_head
  355. {
  356. /*! \brief Max number of bytes per raster data value minus 1 (raster header only)
  357. Note: -1 for FP raster maps
  358. */
  359. int format;
  360. /*! \brief Compression mode (raster header only)
  361. - 0: uncompressed
  362. - 1: compressed
  363. - -1: pre GRASS 3.0
  364. */
  365. int compressed;
  366. /*! \brief Number of rows for 2D data */
  367. int rows;
  368. /*! \brief Number of rows for 3D data */
  369. int rows3;
  370. /*! \brief Number of columns for 2D data */
  371. int cols;
  372. /*! \brief Number of columns for 3D data */
  373. int cols3;
  374. /*! \brief number of depths for 3D data */
  375. int depths;
  376. /*! \brief Projection code
  377. - PROJECTION_XY
  378. - PROJECTION_UTM
  379. - PROJECTION_SP
  380. - PROJECTION_LL
  381. - PROJECTION_OTHER
  382. */
  383. int proj;
  384. /*! \brief Projection zone (UTM) */
  385. int zone;
  386. /*! \brief Resolution - east to west cell size for 2D data */
  387. double ew_res;
  388. /*! \brief Resolution - east to west cell size for 3D data */
  389. double ew_res3;
  390. /*! \brief Resolution - north to south cell size for 2D data */
  391. double ns_res;
  392. /*! \brief Resolution - north to south cell size for 3D data */
  393. double ns_res3;
  394. /*! \brief Resolution - top to bottom cell size for 3D data */
  395. double tb_res;
  396. /*! \brief Extent coordinates (north) */
  397. double north;
  398. /*! \brief Extent coordinates (south) */
  399. double south;
  400. /*! \brief Extent coordinates (east) */
  401. double east;
  402. /*! \brief Extent coordinates (west) */
  403. double west;
  404. /*! \brief Extent coordinates (top) - 3D data*/
  405. double top;
  406. /*! \brief Extent coordinates (bottom) - 3D data */
  407. double bottom;
  408. };
  409. /*
  410. ** Structure for I/O of 3dview files (view.c)
  411. */
  412. struct G_3dview
  413. {
  414. char pgm_id[40]; /* user-provided identifier */
  415. float from_to[2][3]; /* eye position & lookat position */
  416. float fov; /* field of view */
  417. float twist; /* right_hand rotation about from_to */
  418. float exag; /* terrain elevation exageration */
  419. int mesh_freq; /* cells per grid line */
  420. int poly_freq; /* cells per polygon */
  421. int display_type; /* 1 for mesh, 2 for poly, 3 for both */
  422. int lightson; /* boolean */
  423. int dozero; /* boolean */
  424. int colorgrid; /* boolean */
  425. int shading; /* boolean */
  426. int fringe; /* boolean */
  427. int surfonly; /* boolean */
  428. int doavg; /* boolean */
  429. char grid_col[40]; /* colors */
  430. char bg_col[40]; /* colors */
  431. char other_col[40]; /* colors */
  432. float lightpos[4]; /* east, north, height, 1.0 for local 0.0 infin */
  433. float lightcol[3]; /* values between 0.0 to 1.0 for red, grn, blu */
  434. float ambient;
  435. float shine;
  436. struct Cell_head vwin;
  437. };
  438. struct Key_Value
  439. {
  440. int nitems;
  441. int nalloc;
  442. char **key;
  443. char **value;
  444. };
  445. /*!
  446. \brief Structure that stores option information
  447. The descriptions member contains pairs of option and option
  448. descriptions separated by semicolon ';'.
  449. For example, when options member is set using:
  450. \code
  451. opt->options = "break,rmdupl"
  452. \endcode
  453. the descriptions member should be set to:
  454. \verbatim
  455. "break;break lines on intersections;"
  456. "rmdupl;remove duplicates"
  457. \endverbatim
  458. Parsed descriptions are stored in the same order as options.
  459. GUI dependency is a list of options (separated by commas) to be updated
  460. if the value is changed.
  461. Used by the G_parser() system.
  462. */
  463. struct Option
  464. {
  465. const char *key; /*!< Key word used on command line */
  466. int type; /*!< Option type */
  467. int required; /*!< REQUIRED or OPTIONAL */
  468. int multiple; /*!< Multiple entries OK */
  469. const char *options; /*!< Approved values or range or NULL */
  470. const char **opts; /*!< NULL or NULL terminated array of parsed options */
  471. const char *key_desc; /*!< one word describing the key */
  472. const char *label; /*!< Optional short label, used in GUI as item label */
  473. const char *description; /*!< String describing option */
  474. const char *descriptions; /*!< ';' separated pairs of option and option descriptions */
  475. const char **descs; /*!< parsed descriptions, array of either NULL or string */
  476. char *answer; /*!< Option answer */
  477. const char *def; /*!< Where original answer gets saved */
  478. char **answers; /*!< Option answers (for multiple=YES) */
  479. struct Option *next_opt; /*!< Pointer to next option struct */
  480. const char *gisprompt; /*!< Interactive prompt guidance */
  481. const char *guisection; /*!< GUI Layout guidance: ';' delimited hierarchical tree position */
  482. const char *guidependency; /*!< GUI dependency */
  483. int (*checker)(const char *);/*!< Routine to check answer or NULL */
  484. int count;
  485. };
  486. /*!
  487. \brief Structure that stores flag info
  488. Used by the G_parser() system.
  489. */
  490. struct Flag
  491. {
  492. char key; /*!< Key char used on command line */
  493. char answer; /*!< Stores flag state: 0/1 */
  494. char suppress_required; /*!< Suppresses checking of required options */
  495. char suppress_overwrite; /*!< Suppresses checking of existing output */
  496. const char *label; /*!< Optional short label, used in GUI as item label */
  497. const char *description; /*!< String describing flag meaning */
  498. const char *guisection; /*!< GUI Layout guidance: ';' delimited hierarchical tree position */
  499. struct Flag *next_flag; /*!< Pointer to next flag struct */
  500. };
  501. /*!
  502. \brief Structure that stores module info
  503. Used by the G_parser() system.
  504. */
  505. struct GModule
  506. {
  507. const char *label; /*!< Optional short description for GUI */
  508. const char *description; /*!< String describing module */
  509. const char **keywords; /*!< Keywords describing module */
  510. /* further items are possible: author(s), version, year */
  511. int overwrite; /*!< overwrite old files */
  512. int verbose; /*!< print all information about progress and so on */
  513. };
  514. struct TimeStamp
  515. {
  516. DateTime dt[2]; /* two datetimes */
  517. int count;
  518. };
  519. struct Counter {
  520. int value;
  521. };
  522. struct Popen {
  523. FILE *fp;
  524. int pid;
  525. };
  526. typedef int CELL;
  527. typedef double DCELL;
  528. typedef float FCELL;
  529. /* 64 bit signed integer */
  530. #if HAVE_INT64_T
  531. #include <sys/types.h>
  532. typedef int64_t grass_int64;
  533. #elif defined(__MINGW32__)
  534. typedef __int64 grass_int64;
  535. #elif HAVE_LONG_LONG_INT
  536. typedef long long int grass_int64;
  537. #elif HAVE_LARGEFILES
  538. typedef off_t grass_int64;
  539. #else
  540. #error "no 64 bit integer available"
  541. #endif
  542. /* LCELL = large CELL, proposed new raster data type */
  543. typedef grass_int64 LCELL;
  544. struct _Color_Value_
  545. {
  546. DCELL value;
  547. unsigned char red;
  548. unsigned char grn;
  549. unsigned char blu;
  550. };
  551. struct _Color_Rule_
  552. {
  553. struct _Color_Value_ low, high;
  554. struct _Color_Rule_ *next;
  555. struct _Color_Rule_ *prev;
  556. };
  557. struct _Color_Info_
  558. {
  559. struct _Color_Rule_ *rules;
  560. int n_rules;
  561. struct
  562. {
  563. unsigned char *red;
  564. unsigned char *grn;
  565. unsigned char *blu;
  566. unsigned char *set;
  567. int nalloc;
  568. int active;
  569. } lookup;
  570. struct
  571. {
  572. DCELL *vals;
  573. /* pointers to color rules corresponding to the intervals btwn vals */
  574. struct _Color_Rule_ **rules;
  575. int nalloc;
  576. int active;
  577. } fp_lookup;
  578. DCELL min, max;
  579. };
  580. struct Colors
  581. {
  582. int version; /* set by read_colors: -1=old,1=new */
  583. DCELL shift;
  584. int invert;
  585. int is_float; /* defined on floating point raster data? */
  586. int null_set; /* the colors for null are set? */
  587. unsigned char null_red;
  588. unsigned char null_grn;
  589. unsigned char null_blu;
  590. int undef_set; /* the colors for cells not in range are set? */
  591. unsigned char undef_red;
  592. unsigned char undef_grn;
  593. unsigned char undef_blu;
  594. struct _Color_Info_ fixed;
  595. struct _Color_Info_ modular;
  596. DCELL cmin;
  597. DCELL cmax;
  598. int organizing;
  599. };
  600. /*!
  601. \brief List of integers
  602. */
  603. struct ilist
  604. {
  605. /*!
  606. \brief Array of values
  607. */
  608. int *value;
  609. /*!
  610. \brief Number of values in the list
  611. */
  612. int n_values;
  613. /*!
  614. \brief Allocated space for values
  615. */
  616. int alloc_values;
  617. };
  618. /*============================== Prototypes ================================*/
  619. /* Since there are so many prototypes for the gis library they are stored */
  620. /* in the file gisdefs.h */
  621. #include <grass/defs/gis.h>
  622. #endif /* GRASS_GIS_H */