-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathdGrid.h
More file actions
177 lines (153 loc) · 5.95 KB
/
dGrid.h
File metadata and controls
177 lines (153 loc) · 5.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# ifndef DGRID_H
# define DGRID_H
#include "grdTypes.h"
#include "dHeader.h"
using namespace std;
#pragma warning(disable:4251)
class __declspec( dllexport ) dGrid
{
public:
//CONSTRUCTORS
dGrid();
~dGrid();
//OPERATORS
double operator()( int Column, int Row );
//FUNCTIONS
bool open( const char * Filename, bool InRam = true, GRID_TYPE GridType = USE_EXTENSION, void (*callback)( int number, const char * message ) = NULL );
bool initialize( const char * Filename, dHeader Header, double initialValue, bool InRam = true, GRID_TYPE GridType = USE_EXTENSION );
bool save( const char * Filename = "", GRID_TYPE GridType = USE_EXTENSION, void (*callback)(int number, const char * message ) = NULL );
bool close();
void clear(double clearValue);
//MAPPING FUNCTIONS
void ProjToCell( double x, double y, long & column, long & row );
void CellToProj( long column, long row, double & x, double & y );
//DATA MEMBER ACCESS
inline dHeader getHeader();
void setHeader( dHeader h );
inline double getValue( int Column, int Row );
inline void setValue( int Column, int Row, double Value );
bool inRam();
double maximum();
double minimum();
long LastErrorCode();
double ** getArrayPtr();
void asciiReadHeader( istream & in );
private:
inline int round( double d );
GRID_TYPE getGridType( const char * filename );
void dealloc();
void alloc();
inline bool inGrid( long column, long row );
inline double getValueDisk( int column, int row );
inline void setValueDisk( int column, int row, double value );
void clearDisk(double clearValue);
bool readDiskToMemory( void (*callback)(int number, const char * message ) = NULL );
bool readDiskToDisk( void (*callback)(int number, const char * message ) = NULL );
bool writeMemoryToDisk( void(*callback)(int number, const char * message ) = NULL );
bool writeDiskToDisk();
//ASCII GRID FUNCTIONS
bool asciiReadDiskToMemory( void (*callback)(int number, const char * message ) = NULL );
bool asciiReadDiskToDisk( void (*callback)(int number, const char * message ) = NULL );
bool asciiWriteMemoryToDisk( void(*callback)(int number, const char * message ) = NULL );
bool asciiWriteDiskToDisk();
void asciiReadFooter( istream & in );
void asciiWriteHeader( ostream & out );
void asciiWriteFooter( ostream & out );
bool asciiIsHeaderValue( CString headerValue, istream & in );
bool asciiSaveAs( CString filename, void(*callback)(int number, const char * message) = NULL );
//BINARY GRID FUNCTIONS
bool binaryReadDiskToMemory( void (*callback)(int number, const char * message ) = NULL );
bool binaryReadDiskToDisk();
bool binaryWriteMemoryToDisk( void(*callback)(int number, const char * message ) = NULL );
bool binaryWriteDiskToDisk();
bool binaryInitializeDisk( double InitialValue );
void binaryReadHeader( FILE * in );
void binaryWriteHeader( FILE * out );
double binaryGetValueDisk( int Column, int Row );
void binarySetValueDisk( int Column, int Row, double Value );
void binaryClearDisk(double clearValue);
void binaryBufferRows( int CenterRow );
bool binarySaveAs( CString filename, void(*callback)(int number, const char * message) = NULL );
//ESRI GRID FUNCTIONS
bool esriReadDiskToMemory( void (*callback)(int number, const char * message ) = NULL );
bool esriReadDiskToDisk();
bool esriWriteMemoryToDisk( void(*callback)(int number, const char * message ) = NULL );
bool esriWriteDiskToDisk();
bool esriInitializeDisk( double InitialValue );
double esriGetValueDisk( int Column, int Row );
void esriSetValueDisk( int Column, int Row, double Value );
void esriClearDisk(double clearValue);
void esriBufferRows( int CenterRow );
bool esriSaveAs( CString filename, void(*callback)(int number, const char * message) = NULL );
//SDTS GRID FUNCTIONS
bool sdtsReadDiskToMemory( void(*callback)(int number, const char * message ) = NULL );
void get_iref(double & xhrs, double & yhrs);
void get_xref(void);
void dem_rc(int status, int & ncol, int & nrow);
void dem_head(int);
void dem_mbr(int status, double & SWX, double & SWY, double & NWX, double & NWY, double & NEX, double & NEY, double & SEX, double & SEY);
void cell_range(int status, long & voidvalue, long & fillvalue);
void cells_out(const char * filename, int status, long fillvalue, void (*callback)(int number, const char * message ) = NULL );
void get_nw_corner(double & upperlx, double & upperly);
int s123tol2(char *,long *,int);
bool read_sdts_header(char * filename, dHeader & h, long & fillvalue);
void baseAndId();
char FeetOrMeters();
private:
dHeader gridHeader;
bool isInRam;
double ** data;
double max;
double min;
GRID_TYPE gridType;
CString gridFilename;
//ASCII Specific Variables
//Flags used to adjust reference to cell center
bool xllcorner;
bool yllcorner;
//BINARY Specific Variables
double * row_one;
double * row_two; //Current row
double * row_three;
long current_row;
FILE * file_in_out;
long file_position_beg_of_data;
DATA_TYPE data_type;
//ESRI Specific Variables
int grid_layer;
void * row_buf1;
void * row_buf2;
void * row_buf3;
float float_null;
//SDTS Specific Variables
FILE *fpin;
long int_level;
double sfax, sfay, xorg, yorg;
double x[5];
double y[5];
long nxy;
long str_len;
long li;
int stat2;
int status;
char temp[100];
char ice;
char leadid;
char ccs[4];
char tag[10];
char fdlen[10];
char *fdname;
char mod_name[10];
char base_name[MAX_STRING_LENGTH];
char file_name[MAX_STRING_LENGTH];
char string[5000];
char descr[5000];
char frmts[500];
int order;
char rsnm[5];
//Flags used to indicate if the max or min value has been overwritten
bool findNewMax;
bool findNewMin;
long lastErrorCode;
};
# endif