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