G.h 3.0 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 G_gdal_raster_IO(
  33. GDALRasterBandH, GDALRWFlag,
  34. int, int, int, int,
  35. void *, int, int, GDALDataType,
  36. int, int);
  37. #endif
  38. struct fileinfo /* Information for opened cell files */
  39. {
  40. int open_mode; /* see defines below */
  41. struct Cell_head cellhd; /* Cell header */
  42. struct Reclass reclass; /* Table reclass */
  43. struct Cell_stats statf; /* Cell stats */
  44. struct Range range; /* Range structure */
  45. struct FPRange fp_range; /* float Range structure */
  46. int want_histogram;
  47. int reclass_flag; /* Automatic reclass flag */
  48. off_t *row_ptr; /* File row addresses */
  49. COLUMN_MAPPING *col_map; /* Data to window col mapping */
  50. double C1, C2; /* Data to window row constants */
  51. int cur_row; /* Current data row in memory */
  52. int null_cur_row; /* Current null row in memory */
  53. int cur_nbytes; /* nbytes per cell for current row */
  54. unsigned char *data; /* Decompressed data 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. unsigned char *NULL_ROWS[NULL_ROWS_INMEM];
  65. int min_null_row; /* Minimum row null row number in memory */
  66. struct Quant quant;
  67. struct GDAL_link *gdal;
  68. };
  69. struct G__ /* Structure of library globals */
  70. {
  71. RASTER_MAP_TYPE fp_type; /* type for writing floating maps */
  72. struct Cell_head window; /* Contains the current window */
  73. int window_set; /* Flag: window set? */
  74. int mask_fd; /* File descriptor for automatic mask */
  75. int auto_mask; /* Flag denoting automatic masking */
  76. int want_histogram;
  77. int nbytes;
  78. int compression_type;
  79. int fileinfo_count;
  80. struct fileinfo *fileinfo;
  81. };
  82. extern struct G__ G__; /* allocated in gisinit */
  83. #define OPEN_OLD 1
  84. #define OPEN_NEW_COMPRESSED 2
  85. #define OPEN_NEW_UNCOMPRESSED 3