#include <dem.h>
Collaboration diagram for DEMFile:

Definition at line 82 of file dem.h.
Public Member Functions | |
| DEMFile (char *s) | |
| void | dump_ARecord (void) |
| void | dump_BRecord (void) |
| void | dump_grid (void) |
| int * | process (void) |
| void | range (double &x, double &y) |
| void | resolution (double &r) |
| ~DEMFile () | |
Private Member Functions | |
| int | open (void) |
| void | read_field (void) |
| float | read_float (void) |
| int | read_int (void) |
Private Attributes | |
| ARecord | a |
| BRecord | b |
| FILE * | demfile |
| char * | fname |
| int * | grid |
| char | tempbuf [1024] |
|
|
Definition at line 84 of file dem.h.
|
|
|
Definition at line 85 of file dem.h. References demfile.
|
|
|
Definition at line 225 of file dem.cc. References a, ARecord::a_code, ARecord::angle, ARecord::cols, ARecord::corners, ARecord::dl_code, ARecord::e_units, ARecord::g_units, ARecord::max_elevation, ARecord::min_elevation, ARecord::p_code, ARecord::p_parm, ARecord::pr_code, ARecord::q_name, ARecord::rows, ARecord::sides, ARecord::x_res, ARecord::y_res, ARecord::z_code, and ARecord::z_res. Referenced by Topography::load_demfile(). 00226 { 00227 int i; 00228 00229 fprintf(stdout, "*** A RECORD ***\n"); 00230 fprintf(stdout, "Quadrangle name: %s\n", a.q_name); 00231 fprintf(stdout, "DEM Level code: %d\n", a.dl_code); 00232 fprintf(stdout, "Pattern code: %d\n", a.p_code); 00233 fprintf(stdout, "Planimetric reference system code: %d\n", a.pr_code); 00234 fprintf(stdout, "Zone code: %d\n", a.z_code); 00235 00236 fprintf(stdout, "Map Projection Parameters:\n"); 00237 for(i = 0; i < 15; i++) 00238 fprintf(stdout, " %f\n", 00239 a.p_parm[i]); 00240 00241 fprintf(stdout, "Ground planimetric coordinates: %d\n", a.g_units); 00242 fprintf(stdout, "Elevation coordinates: %d\n", a.e_units); 00243 fprintf(stdout, "Sides: %d\n", a.sides); 00244 00245 fprintf(stdout, "Corners:\n"); 00246 for(i = 0; i < 4; i++) 00247 fprintf(stdout, " %f, %f\n", 00248 a.corners[i][0], a.corners[i][1]); 00249 00250 fprintf(stdout, "Min Elevation: %f\n", a.min_elevation); 00251 fprintf(stdout, "Max Elevation: %f\n", a.max_elevation); 00252 fprintf(stdout, "Clockwise angle: %f\n", a.angle); 00253 fprintf(stdout, "Accuracy code: %d\n", a.a_code); 00254 00255 fprintf(stdout, "Spatial Resolution:\n"); 00256 fprintf(stdout, " %f (x)\n", a.x_res); 00257 fprintf(stdout, " %f (y)\n", a.y_res); 00258 fprintf(stdout, " %f (z)\n", a.z_res); 00259 00260 fprintf(stdout, "Rows: %d\n", a.rows); 00261 fprintf(stdout, "Columns: %d\n", a.cols); 00262 }
|
|
|
Definition at line 266 of file dem.cc. References b, BRecord::col_id, BRecord::cols, BRecord::elevation, BRecord::max_elevation, BRecord::min_elevation, BRecord::row_id, BRecord::rows, BRecord::x_gpc, and BRecord::y_gpc. 00267 { 00268 fprintf(stdout, "*** B RECORD ***\n"); 00269 fprintf(stdout, "Row ID: %d\n", b.row_id); 00270 fprintf(stdout, "Column ID: %d\n", b.col_id); 00271 fprintf(stdout, "Rows: %d\n", b.rows); 00272 fprintf(stdout, "Columns: %d\n", b.cols); 00273 fprintf(stdout, "Ground planimetric coordinates: %f, %f\n", 00274 b.x_gpc, b.y_gpc); 00275 fprintf(stdout, "Elevation: %f\n", b.elevation); 00276 fprintf(stdout, "Min Elevation: %f\n", b.min_elevation); 00277 fprintf(stdout, "Max Elevation: %f\n", b.max_elevation); 00278 }
|
|
|
Definition at line 282 of file dem.cc. References a, ARecord::cols, and grid. 00283 { 00284 int i, j; 00285 fprintf(stdout, "*** X,Y GRID ***\n"); 00286 for(i = 0; i < a.cols; i++) { 00287 fprintf(stdout, "ROW %5d --- ", i); 00288 for(j = 0; j < a.cols; j++) { 00289 fprintf(stdout, "%5d ", grid[i*a.cols + j]); 00290 } 00291 fprintf(stdout, "\n"); 00292 } 00293 }
|
|
|
Definition at line 45 of file dem.cc. References demfile, and fname. Referenced by process(). 00046 { 00047 if((demfile = fopen(fname, "r")) == 0) 00048 return EINVAL; 00049 else 00050 return 0; 00051 }
|
|
|
Definition at line 138 of file dem.cc. References a, demfile, fname, open(), and ARecord::q_name. Referenced by Topography::load_demfile(). 00139 { 00140 int i, j, offset = 0; 00141 char ch; 00142 00143 if(fname == 0) 00144 return 0; 00145 00146 if(open()) 00147 return 0; 00148 00149 /* ============================================================ 00150 A Record 00151 ============================================================ */ 00152 bzero(a.q_name, sizeof(a.q_name)); 00153 for(i = 0; ! feof(demfile) && i < (int) sizeof(a.q_name) - 1; i++) { 00154 ch = fgetc(demfile); 00155 if(! isspace(ch)) { 00156 a.q_name[offset] = ch; 00157 offset++; 00158 } 00159 else { 00160 if(offset && ! isspace(a.q_name[offset-1])) { 00161 a.q_name[offset] = ch; 00162 offset++; 00163 } 00164 } 00165 } 00166 00167 a.dl_code = read_int(); 00168 a.p_code = read_int(); 00169 a.pr_code = read_int(); 00170 a.z_code = read_int(); 00171 00172 /* Map Projection Parameters */ 00173 for(i = 0; i < 15; i++) 00174 a.p_parm[i] = read_float(); 00175 00176 a.g_units = read_int(); 00177 a.e_units = read_int(); 00178 a.sides = read_int(); 00179 00180 for(i = 0; i < 4; i++) { 00181 a.corners[i][0] = read_float(); 00182 a.corners[i][1] = read_float(); 00183 } 00184 00185 a.min_elevation = read_float(); 00186 a.max_elevation = read_float(); 00187 a.angle = read_float(); 00188 #if 0 00189 a.a_code = read_int(); 00190 a.x_res = read_float(); 00191 a.y_res = read_float(); 00192 a.z_res = read_float(); 00193 #else 00194 read_field(); 00195 #endif 00196 a.rows = read_int(); 00197 a.cols = read_int(); 00198 00199 grid = (int*) malloc(sizeof(int) * a.cols * a.cols); 00200 00201 /* ============================================================ 00202 B Records 00203 ============================================================ */ 00204 for(int rows = 0; rows < a.cols; rows++) { 00205 b.row_id = read_int(); 00206 b.col_id = read_int(); 00207 b.rows = read_int(); 00208 b.cols = read_int(); 00209 b.x_gpc = read_float(); 00210 b.y_gpc = read_float(); 00211 b.elevation = read_float(); 00212 b.min_elevation = read_float(); 00213 b.max_elevation = read_float(); 00214 00215 i = rows * a.cols; 00216 for(j = 0; j < b.rows; j++) 00217 grid[i+j] = read_int(); 00218 } 00219 00220 return grid; 00221 }
Here is the call graph for this function: ![]() |
|
||||||||||||
|
Definition at line 103 of file dem.cc. References a, and ARecord::corners. Referenced by Topography::load_demfile(). 00104 { 00105 #if 0 00106 int i; 00107 double minx = 0.0, miny = 0.0, maxx = 0.0, maxy = 0.0; 00108 00109 for(i = 0; i < 4; i++) { 00110 if(minx == 0.0 || minx > a.corners[i][0]) { 00111 minx = a.corners[i][0]; 00112 miny = a.corners[i][1]; 00113 } 00114 else if(minx == a.corners[i][0] && miny > a.corners[i][1]) { 00115 miny = a.corners[i][1]; 00116 } 00117 00118 if(maxx == 0.0 || maxx < a.corners[i][0]) { 00119 maxx = a.corners[i][0]; 00120 maxy = a.corners[i][1]; 00121 } 00122 else if(maxx == a.corners[i][0] && maxy < a.corners[i][1]) { 00123 maxy = a.corners[i][1]; 00124 } 00125 } 00126 x = maxx - minx; 00127 y = maxy - miny; 00128 #else 00129 x = y = (double) a.cols - 1; 00130 #endif 00131 }
|
|
|
Definition at line 69 of file dem.cc. References __PRETTY_FUNCTION__, demfile, and tempbuf. Referenced by read_float(), and read_int(). 00070 { 00071 int i; 00072 char ch; 00073 00074 bzero(tempbuf, sizeof(tempbuf)); 00075 00076 do { 00077 ch = fgetc(demfile); 00078 } while (ch != EOF && isspace (ch)); 00079 tempbuf[0] = ch; 00080 00081 for(i = 1; ; i++) { 00082 if(feof(demfile)) { 00083 fprintf(stderr, "%s: EOF\n", __PRETTY_FUNCTION__); 00084 exit(1); 00085 } 00086 tempbuf[i] = fgetc(demfile); 00087 if(tempbuf[i] == 'D') 00088 tempbuf[i] = 'E'; 00089 if(isspace(tempbuf[i])) 00090 break; 00091 } 00092 }
|
|
|
Definition at line 62 of file dem.cc. References read_field(), and tempbuf. 00063 { 00064 read_field(); 00065 return (atof(tempbuf)); 00066 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 55 of file dem.cc. References read_field(), and tempbuf. 00056 { 00057 read_field(); 00058 return (atoi(tempbuf)); 00059 }
Here is the call graph for this function: ![]() |
|
|
Definition at line 96 of file dem.cc. Referenced by Topography::load_demfile().
|
|
|
Definition at line 101 of file dem.h. Referenced by dump_ARecord(), dump_grid(), process(), and range(). |
|
|
Definition at line 102 of file dem.h. Referenced by dump_BRecord(). |
|
|
Definition at line 100 of file dem.h. Referenced by open(), process(), read_field(), and ~DEMFile(). |
|
|
|
|
|
Definition at line 103 of file dem.h. Referenced by dump_grid(). |
|
|
Definition at line 104 of file dem.h. Referenced by read_field(), read_float(), and read_int(). |
1.4.6