R.h 3.2 KB

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