R.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #include <grass/config.h>
  2. #include <grass/gis.h>
  3. #ifdef HAVE_GDAL
  4. #include <gdal.h>
  5. #endif
  6. #define XDR_FLOAT_NBYTES 4
  7. #define XDR_DOUBLE_NBYTES 8
  8. #define NULL_ROWS_INMEM 8
  9. /* if short is 16 bits, then
  10. * short will allow 32767 cols
  11. * unsigned short will allow 65536 cols
  12. * use int if you need more columns (but this will take more memory).
  13. *
  14. */
  15. typedef int COLUMN_MAPPING;
  16. struct GDAL_link
  17. {
  18. char *filename;
  19. int band_num;
  20. DCELL null_val;
  21. int hflip;
  22. int vflip;
  23. #ifdef HAVE_GDAL
  24. GDALDatasetH data;
  25. GDALRasterBandH band;
  26. GDALDataType type;
  27. #endif
  28. };
  29. #ifdef HAVE_GDAL
  30. extern CPLErr Rast_gdal_raster_IO(GDALRasterBandH, GDALRWFlag,
  31. int, int, int, int,
  32. void *, int, int, GDALDataType, int, int);
  33. #endif
  34. struct tileinfo /* Information for tiles */
  35. {
  36. char *name; /* Name of open file */
  37. char *mapset; /* Mapset of open file */
  38. struct Cell_head cellhd; /* Cell header */
  39. struct ilist *clist; /* columns inside current region */
  40. };
  41. struct R_vrt
  42. {
  43. int tilecount;
  44. struct tileinfo *tileinfo;
  45. struct ilist *tlist;
  46. };
  47. struct fileinfo /* Information for opened cell files */
  48. {
  49. int open_mode; /* see defines below */
  50. struct Cell_head cellhd; /* Cell header */
  51. struct Reclass reclass; /* Table reclass */
  52. struct Cell_stats statf; /* Cell stats */
  53. struct Range range; /* Range structure */
  54. struct FPRange fp_range; /* float Range structure */
  55. int want_histogram;
  56. int reclass_flag; /* Automatic reclass flag */
  57. off_t *row_ptr; /* File row addresses */
  58. COLUMN_MAPPING *col_map; /* Data to window col mapping */
  59. double C1, C2; /* Data to window row constants */
  60. int cur_row; /* Current data row in memory */
  61. int null_cur_row; /* Current null row in memory */
  62. int cur_nbytes; /* nbytes per cell for current row */
  63. unsigned char *data; /* Decompressed data buffer */
  64. int null_fd; /* Null bitmap fd */
  65. unsigned char *null_bits; /* Null bitmap buffer */
  66. int nbytes; /* bytes per cell */
  67. RASTER_MAP_TYPE map_type; /* type: int, float or double map */
  68. char *temp_name; /* Temporary name for NEW files */
  69. char *null_temp_name; /* Temporary name for NEW NULL files */
  70. int null_file_exists; /* for existing raster maps */
  71. char *name; /* Name of open file */
  72. char *mapset; /* Mapset of open file */
  73. int io_error; /* io error warning given */
  74. struct Quant quant;
  75. struct GDAL_link *gdal;
  76. int data_fd; /* Raster data fd */
  77. off_t *null_row_ptr; /* Null file row addresses */
  78. struct R_vrt *vrt;
  79. };
  80. struct R__ /* Structure of library globals */
  81. {
  82. RASTER_MAP_TYPE fp_type; /* type for writing floating maps */
  83. int mask_fd; /* File descriptor for automatic mask */
  84. int auto_mask; /* Flag denoting automatic masking */
  85. int want_histogram;
  86. int nbytes;
  87. int compression_type;
  88. int compress_nulls;
  89. int window_set; /* Flag: window set? */
  90. int split_window; /* Separate windows for input and output */
  91. struct Cell_head rd_window; /* Window used for input */
  92. struct Cell_head wr_window; /* Window used for output */
  93. int fileinfo_count;
  94. struct fileinfo *fileinfo;
  95. };
  96. extern struct R__ R__; /* allocated in init */
  97. #define OPEN_OLD 1
  98. #define OPEN_NEW_COMPRESSED 2
  99. #define OPEN_NEW_UNCOMPRESSED 3