1 // array.hxx -- Array management class
3 // Written by Curtis Olson, started March 1998.
5 // Copyright (C) 1998 - 1999 Curtis L. Olson - curt@flightgear.org
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.
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.
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.
22 // (Log is kept at end of this file)
30 # error This library requires C++
34 #include <Include/compiler.h>
38 #include <Bucket/newbucket.hxx>
39 #include <Math/point3d.hxx>
40 #include <Misc/fgstream.hxx>
45 #define ARRAY_SIZE 1200
46 #define ARRAY_SIZE_1 1201
49 typedef vector < Point3D > fitnode_list;
50 typedef fitnode_list::iterator fitnode_list_iterator;
51 typedef fitnode_list::const_iterator const_fitnode_list_iterator;
58 // file pointer for input
62 // coordinates (in arc seconds) of south west corner
63 double originx, originy;
65 // number of columns and rows
68 // Distance between column and row data points (in arc seconds)
69 double col_step, row_step;
71 // pointers to the actual grid data allocated here
72 float (*in_data)[ARRAY_SIZE_1];
73 // float (*out_data)[ARRAY_SIZE_1];
76 fitnode_list node_list;
78 // Initialize output mesh structure
79 // void outputmesh_init( void );
81 // Get the value of a mesh node
82 // double outputmesh_get_pt( int i, int j );
84 // Set the value of a mesh node
85 // void outputmesh_set_pt( int i, int j, double value );
88 // Write out a node file that can be used by the "triangle" program
89 // void outputmesh_output_nodes( const string& fg_root, FGBucket& p );
96 FGArray( const string& file );
101 // open an Array file (use "-" if input is coming from stdin)
102 int open ( const string& file );
104 // close a Array file
107 // parse a Array file
110 // Use least squares to fit a simpler data set to dem data
111 void fit( double error );
113 // add a node to the output (fitted) node list
114 void add_fit_node( int i, int j, double val );
116 // return the current altitude based on grid data. We should
117 // rewrite this to interpolate exact values, but for now this is
119 double interpolate_altitude( double lon, double lat );
121 // Informational methods
122 inline double get_originx() const { return originx; }
123 inline double get_originy() const { return originy; }
124 inline int get_cols() const { return cols; }
125 inline int get_rows() const { return rows; }
126 inline double get_col_step() const { return col_step; }
127 inline double get_row_step() const { return row_step; }
129 inline fitnode_list get_fit_node_list() const { return node_list; }
137 // Revision 1.3 1999/03/20 20:32:52 curt
138 // First mostly successful tile triangulation works. There's plenty of tweaking
139 // to do, but we are marching in the right direction.
141 // Revision 1.2 1999/03/13 23:50:27 curt
142 // Tweaked output formatting a bit.
144 // Revision 1.1 1999/03/13 18:45:02 curt
145 // Initial revision. (derived from libDEM.a code.)