]> git.mxchange.org Git - flightgear.git/blob - Array/array.hxx
c097dadfbb69370ab801d03d405e5e3ebc867cce
[flightgear.git] / Array / array.hxx
1 // array.hxx -- Array management class
2 //
3 // Written by Curtis Olson, started March 1998.
4 //
5 // Copyright (C) 1998 - 1999  Curtis L. Olson  - curt@flightgear.org
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22 // (Log is kept at end of this file)
23
24
25 #ifndef _ARRAY_HXX
26 #define _ARRAY_HXX
27
28
29 #ifndef __cplusplus                                                          
30 # error This library requires C++
31 #endif                                   
32
33
34 #include <Bucket/newbucket.hxx>
35 #include <Misc/fgstream.hxx>
36
37
38 #define ARRAY_SIZE 1200
39 #define ARRAY_SIZE_1 1201
40
41
42 class FGArray {
43
44 private:
45
46     // file pointer for input
47     // gzFile fd;
48     fg_gzifstream *in;
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 grid data allocated here
60     float (*in_data)[ARRAY_SIZE_1];
61     float (*out_data)[ARRAY_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     // Initialize output mesh structure
81     void outputmesh_init( void );
82
83     // Get the value of a mesh node
84     double outputmesh_get_pt( int i, int j );
85
86     // Set the value of a mesh node
87     void outputmesh_set_pt( int i, int j, double value );
88
89 #if 0
90     // Write out a node file that can be used by the "triangle" program
91     void outputmesh_output_nodes( const string& fg_root, FGBucket& p );
92 #endif
93
94 public:
95
96     // Constructor
97     FGArray( void );
98     FGArray( const string& file );
99
100     // Destructor
101     ~FGArray( void );
102
103     // open an Array file (use "-" if input is coming from stdin)
104     int open ( const string& file );
105
106     // close a Array file
107     int close();
108
109     // parse a Array file
110     int parse();
111
112     // Use least squares to fit a simpler data set to dem data
113     void fit( FGBucket& p, double error );
114
115     // return the current altitude based on grid data.  We should
116     // rewrite this to interpolate exact values, but for now this is
117     // good enough
118     double interpolate_altitude( double lon, double lat );
119
120     // Informational methods
121     inline double get_originx() const { return originx; }
122     inline double get_originy() const { return originy; }
123     inline int get_cols() const { return cols; }
124     inline int get_rows() const { return rows; }
125     inline double get_col_step() const { return col_step; }
126     inline double get_row_step() const { return row_step; }
127 };
128
129
130 #endif // _ARRAY_HXX
131
132
133 // $Log$
134 // Revision 1.1  1999/03/13 18:45:02  curt
135 // Initial revision. (derived from libDEM.a code.)
136 //