00001 #include <grass/gis.h> 00002 #include <rpc/types.h> 00003 #include <rpc/xdr.h> 00004 00005 #define XDR_FLOAT_NBYTES 4 00006 #define XDR_DOUBLE_NBYTES 8 00007 #define NULL_ROWS_INMEM 8 00008 00009 /* if short is 16 bits, then 00010 * short will allow 32767 cols 00011 * unsigned short will allow 65536 cols 00012 * use int if you need more columns (but this will take more memory). 00013 * 00014 */ 00015 typedef int COLUMN_MAPPING ; 00016 00017 struct fileinfo /* Information for opened cell files */ 00018 { 00019 int open_mode; /* see defines below */ 00020 struct Cell_head cellhd; /* Cell header */ 00021 struct Reclass reclass; /* Table reclass */ 00022 struct Cell_stats statf; /* Cell stats */ 00023 struct Range range; /* Range structure */ 00024 struct FPRange fp_range; /* float Range structure */ 00025 int want_histogram; 00026 int reclass_flag; /* Automatic reclass flag */ 00027 off_t *row_ptr; /* File row addresses */ 00028 COLUMN_MAPPING *col_map; /* Data to window col mapping */ 00029 double C1,C2; /* Data to window row constants */ 00030 int cur_row; /* Current data row in memory */ 00031 int null_cur_row; /* Current null row in memory */ 00032 int cur_nbytes; /* nbytes per cell for current row */ 00033 unsigned char *data; /* Decompressed data buffer */ 00034 int nbytes; /* bytes per cell */ 00035 RASTER_MAP_TYPE map_type; /* type: int, float or double map */ 00036 char *temp_name; /* Temporary name for NEW files */ 00037 char *null_temp_name; /* Temporary name for NEW NULL files */ 00038 int null_file_exists; /* for existing raster maps */ 00039 char *name; /* Name of open file */ 00040 char *mapset; /* Mapset of open file */ 00041 int io_error; /* io error warning given */ 00042 XDR xdrstream; /* xdr stream for reading fp */ 00043 unsigned char *NULL_ROWS [NULL_ROWS_INMEM]; 00044 unsigned char *null_work_buf; /* data buffer for reading null rows */ 00045 int min_null_row; /* Minimum row null row number in memory */ 00046 struct Quant quant; 00047 }; 00048 00049 struct G__ /* Structure of library globals */ 00050 { 00051 int fp_nbytes; /* size of cell in floating maps */ 00052 RASTER_MAP_TYPE fp_type; /* type for writing floating maps */ 00053 struct Cell_head window; /* Contains the current window */ 00054 int window_set; /* Flag: window set? */ 00055 int mask_fd; /* File descriptor for automatic mask */ 00056 int auto_mask; /* Flag denoting automatic masking */ 00057 CELL *mask_buf; 00058 char *null_buf; /* buffer for reading null rows */ 00059 CELL *temp_buf; 00060 unsigned char *compressed_buf; /* Pre/post compressed data buffer */ 00061 int compressed_buf_size; /* sizeof compressed_buf */ 00062 unsigned char *work_buf; /* work data buffer */ 00063 int work_buf_size; /* sizeof work_buf */ 00064 int null_buf_size; /* sizeof null_buf */ 00065 int mask_buf_size; /* sizeof mask_buf */ 00066 int temp_buf_size; /* sizeof temp_buf */ 00067 int want_histogram; 00068 00069 int fileinfo_count; 00070 struct fileinfo *fileinfo; 00071 }; 00072 00073 extern struct G__ G__; /* allocated in gisinit */ 00074 00075 #define OPEN_OLD 1 00076 #define OPEN_NEW_COMPRESSED 2 00077 #define OPEN_NEW_UNCOMPRESSED 3 00078 #define OPEN_NEW_RANDOM 4