]> git.mxchange.org Git - flightgear.git/blob - DEM/dem.hxx
Removed zlib support.
[flightgear.git] / DEM / dem.hxx
1 // -*- Mode: C++ -*-
2 //
3 // dem.h -- DEM management class
4 //
5 // Written by Curtis Olson, started March 1998.
6 //
7 // Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 // General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 //
23 // $Id$
24 // (Log is kept at end of this file)
25
26
27 #ifndef _DEM_H
28 #define _DEM_H
29
30
31 #ifndef __cplusplus                                                          
32 # error This library requires C++
33 #endif                                   
34
35
36 #include <stdio.h>
37
38 #include <Bucket/bucketutils.h>
39 #include <zlib/zlib.h>
40
41
42 #define DEM_SIZE 1200
43 #define DEM_SIZE_1 1201
44
45
46 class fgDEM {
47     // file pointer for input
48     gzFile fd;
49
50     // coordinates (in arc seconds) of south west corner
51     double originx, originy;
52     
53     // number of columns and rows
54     int cols, rows;
55     
56     // Distance between column and row data points (in arc seconds)
57     double col_step, row_step;
58     
59     // pointers to the actual mesh data allocated here
60     float (*dem_data)[DEM_SIZE_1];
61     float (*output_data)[DEM_SIZE_1];
62
63     // Current "A" Record Information
64     char dem_description[80], dem_quadrangle[80];
65     double dem_x1, dem_y1, dem_x2, dem_y2, dem_x3, dem_y3, dem_x4, dem_y4;
66     double dem_z1, dem_z2;
67     int dem_resolution, dem_num_profiles;
68   
69     // Current "B" Record Information
70     int prof_col, prof_row;
71     int prof_num_cols, prof_num_rows;
72     double prof_x1, prof_y1;
73     int prof_data;
74
75     // temporary values for the class to use
76     char option_name[32];
77     int do_data;
78     int cur_col, cur_row;
79
80 public:
81
82     // Constructor
83     fgDEM( void );
84
85     // open a DEM file (use "-" if input is coming from stdin)
86     int open ( char *file );
87
88     // close a DEM file
89     int close ( void );
90
91     // parse a DEM file
92     int parse( void );
93
94     // read and parse DEM "A" record
95     int read_a_record( void );
96
97     // read and parse DEM "B" record
98     void read_b_record( void );
99
100     // Informational methods
101     double info_originx( void ) { return(originx); }
102     double info_originy( void ) { return(originy); }
103
104     // return the current altitude based on mesh data.  We should
105     // rewrite this to interpolate exact values, but for now this is
106     // good enough
107     double interpolate_altitude( double lon, double lat );
108
109     // Use least squares to fit a simpler data set to dem data
110     void fit( double error, fgBUCKET *p );
111
112     // Initialize output mesh structure
113     void outputmesh_init( void );
114
115     // Get the value of a mesh node
116     double outputmesh_get_pt( int i, int j );
117
118     // Set the value of a mesh node
119     void outputmesh_set_pt( int i, int j, double value );
120
121     // Write out a node file that can be used by the "triangle" program
122     void outputmesh_output_nodes( char *fg_root, fgBUCKET *p );
123
124     // Destructor
125     ~fgDEM( void );
126 };
127
128
129 #endif // _DEM_H
130
131
132 // $Log$
133 // Revision 1.7  1998/07/04 00:47:19  curt
134 // typedef'd struct fgBUCKET.
135 //
136 // Revision 1.6  1998/06/05 18:14:40  curt
137 // Abort out early when reading the "A" record if it doesn't look like
138 // a proper DEM file.
139 //
140 // Revision 1.5  1998/04/22 13:14:46  curt
141 // Fixed a bug in zlib usage.
142 //
143 // Revision 1.4  1998/04/21 17:03:41  curt
144 // Prepairing for C++ integration.
145 //
146 // Revision 1.3  1998/04/18 03:53:06  curt
147 // Added zlib support.
148 //
149 // Revision 1.2  1998/04/14 02:43:28  curt
150 // Used "new" to auto-allocate large DEM parsing arrays in class constructor.
151 //
152 // Revision 1.1  1998/04/08 22:57:23  curt
153 // Adopted Gnu automake/autoconf system.
154 //
155 // Revision 1.2  1998/03/23 20:35:42  curt
156 // Updated to use FG_EPSILON
157 //
158 // Revision 1.1  1998/03/19 02:54:47  curt
159 // Reorganized into a class lib called fgDEM.
160 //
161 // Revision 1.1  1998/03/19 01:46:29  curt
162 // Initial revision.
163 //