R.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. };
  67. struct R__ /* Structure of library globals */
  68. {
  69. RASTER_MAP_TYPE fp_type; /* type for writing floating maps */
  70. int mask_fd; /* File descriptor for automatic mask */
  71. int auto_mask; /* Flag denoting automatic masking */
  72. int want_histogram;
  73. int nbytes;
  74. int compression_type;
  75. int window_set; /* Flag: window set? */
  76. int split_window; /* Separate windows for input and output */
  77. struct Cell_head rd_window; /* Window used for input */
  78. struct Cell_head wr_window; /* Window used for ouput */
  79. int fileinfo_count;
  80. struct fileinfo *fileinfo;
  81. };
  82. extern struct R__ R__; /* allocated in init */
  83. #define OPEN_OLD 1
  84. #define OPEN_NEW_COMPRESSED 2
  85. #define OPEN_NEW_UNCOMPRESSED 3