G.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include <grass/gis.h>
  2. #include <rpc/types.h>
  3. #include <rpc/xdr.h>
  4. #define XDR_FLOAT_NBYTES 4
  5. #define XDR_DOUBLE_NBYTES 8
  6. #define NULL_ROWS_INMEM 8
  7. /* if short is 16 bits, then
  8. * short will allow 32767 cols
  9. * unsigned short will allow 65536 cols
  10. * use int if you need more columns (but this will take more memory).
  11. *
  12. */
  13. typedef int COLUMN_MAPPING;
  14. struct fileinfo /* Information for opened cell files */
  15. {
  16. int open_mode; /* see defines below */
  17. struct Cell_head cellhd; /* Cell header */
  18. struct Reclass reclass; /* Table reclass */
  19. struct Cell_stats statf; /* Cell stats */
  20. struct Range range; /* Range structure */
  21. struct FPRange fp_range; /* float Range structure */
  22. int want_histogram;
  23. int reclass_flag; /* Automatic reclass flag */
  24. off_t *row_ptr; /* File row addresses */
  25. COLUMN_MAPPING *col_map; /* Data to window col mapping */
  26. double C1, C2; /* Data to window row constants */
  27. int cur_row; /* Current data row in memory */
  28. int null_cur_row; /* Current null row in memory */
  29. int cur_nbytes; /* nbytes per cell for current row */
  30. unsigned char *data; /* Decompressed data buffer */
  31. int nbytes; /* bytes per cell */
  32. RASTER_MAP_TYPE map_type; /* type: int, float or double map */
  33. char *temp_name; /* Temporary name for NEW files */
  34. char *null_temp_name; /* Temporary name for NEW NULL files */
  35. int null_file_exists; /* for existing raster maps */
  36. char *name; /* Name of open file */
  37. char *mapset; /* Mapset of open file */
  38. int io_error; /* io error warning given */
  39. XDR xdrstream; /* xdr stream for reading fp */
  40. unsigned char *NULL_ROWS[NULL_ROWS_INMEM];
  41. unsigned char *null_work_buf; /* data buffer for reading null rows */
  42. int min_null_row; /* Minimum row null row number in memory */
  43. struct Quant quant;
  44. };
  45. struct G__ /* Structure of library globals */
  46. {
  47. int fp_nbytes; /* size of cell in floating maps */
  48. RASTER_MAP_TYPE fp_type; /* type for writing floating maps */
  49. struct Cell_head window; /* Contains the current window */
  50. int window_set; /* Flag: window set? */
  51. int mask_fd; /* File descriptor for automatic mask */
  52. int auto_mask; /* Flag denoting automatic masking */
  53. CELL *mask_buf;
  54. char *null_buf; /* buffer for reading null rows */
  55. CELL *temp_buf;
  56. unsigned char *compressed_buf; /* Pre/post compressed data buffer */
  57. int compressed_buf_size; /* sizeof compressed_buf */
  58. unsigned char *work_buf; /* work data buffer */
  59. int work_buf_size; /* sizeof work_buf */
  60. int null_buf_size; /* sizeof null_buf */
  61. int mask_buf_size; /* sizeof mask_buf */
  62. int temp_buf_size; /* sizeof temp_buf */
  63. int want_histogram;
  64. int fileinfo_count;
  65. struct fileinfo *fileinfo;
  66. };
  67. extern struct G__ G__; /* allocated in gisinit */
  68. #define OPEN_OLD 1
  69. #define OPEN_NEW_COMPRESSED 2
  70. #define OPEN_NEW_UNCOMPRESSED 3
  71. #define OPEN_NEW_RANDOM 4