1999-03-13 18:45:02 +00:00
|
|
|
// array.hxx -- Array management class
|
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started March 1998.
|
|
|
|
//
|
|
|
|
// Copyright (C) 1998 - 1999 Curtis L. Olson - curt@flightgear.org
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
// (Log is kept at end of this file)
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _ARRAY_HXX
|
|
|
|
#define _ARRAY_HXX
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __cplusplus
|
|
|
|
# error This library requires C++
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1999-03-20 20:32:51 +00:00
|
|
|
#include <Include/compiler.h>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
1999-03-13 18:45:02 +00:00
|
|
|
#include <Bucket/newbucket.hxx>
|
1999-03-20 20:32:51 +00:00
|
|
|
#include <Math/point3d.hxx>
|
1999-03-13 18:45:02 +00:00
|
|
|
#include <Misc/fgstream.hxx>
|
|
|
|
|
1999-03-29 13:11:00 +00:00
|
|
|
#include <Main/construct_types.hxx>
|
|
|
|
|
1999-03-20 20:32:51 +00:00
|
|
|
FG_USING_STD(vector);
|
|
|
|
|
1999-03-13 18:45:02 +00:00
|
|
|
|
|
|
|
#define ARRAY_SIZE 1200
|
|
|
|
#define ARRAY_SIZE_1 1201
|
|
|
|
|
|
|
|
|
|
|
|
class FGArray {
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
// file pointer for input
|
|
|
|
// gzFile fd;
|
|
|
|
fg_gzifstream *in;
|
|
|
|
|
|
|
|
// coordinates (in arc seconds) of south west corner
|
|
|
|
double originx, originy;
|
|
|
|
|
|
|
|
// number of columns and rows
|
|
|
|
int cols, rows;
|
|
|
|
|
|
|
|
// Distance between column and row data points (in arc seconds)
|
|
|
|
double col_step, row_step;
|
|
|
|
|
|
|
|
// pointers to the actual grid data allocated here
|
|
|
|
float (*in_data)[ARRAY_SIZE_1];
|
1999-03-20 20:32:51 +00:00
|
|
|
// float (*out_data)[ARRAY_SIZE_1];
|
|
|
|
|
|
|
|
// output nodes
|
1999-03-29 13:11:00 +00:00
|
|
|
point_list corner_list;
|
|
|
|
point_list node_list;
|
1999-03-13 18:45:02 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
FGArray( void );
|
|
|
|
FGArray( const string& file );
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
~FGArray( void );
|
|
|
|
|
|
|
|
// open an Array file (use "-" if input is coming from stdin)
|
|
|
|
int open ( const string& file );
|
|
|
|
|
|
|
|
// close a Array file
|
|
|
|
int close();
|
|
|
|
|
|
|
|
// parse a Array file
|
1999-04-05 02:15:23 +00:00
|
|
|
int parse( FGBucket& b );
|
1999-03-13 18:45:02 +00:00
|
|
|
|
1999-04-05 02:15:23 +00:00
|
|
|
// Use least squares to fit a simpler data set to dem data.
|
|
|
|
// Return the number of fitted nodes
|
|
|
|
int fit( double error );
|
1999-03-13 18:45:02 +00:00
|
|
|
|
1999-03-27 05:20:13 +00:00
|
|
|
// add a node to the output corner node list
|
|
|
|
void add_corner_node( int i, int j, double val );
|
|
|
|
|
|
|
|
// add a node to the output fitted node list
|
1999-03-20 20:32:51 +00:00
|
|
|
void add_fit_node( int i, int j, double val );
|
|
|
|
|
1999-03-13 18:45:02 +00:00
|
|
|
// return the current altitude based on grid data. We should
|
|
|
|
// rewrite this to interpolate exact values, but for now this is
|
|
|
|
// good enough
|
1999-03-27 05:20:13 +00:00
|
|
|
double interpolate_altitude( double lon, double lat ) const;
|
1999-03-13 18:45:02 +00:00
|
|
|
|
|
|
|
// Informational methods
|
|
|
|
inline double get_originx() const { return originx; }
|
|
|
|
inline double get_originy() const { return originy; }
|
|
|
|
inline int get_cols() const { return cols; }
|
|
|
|
inline int get_rows() const { return rows; }
|
|
|
|
inline double get_col_step() const { return col_step; }
|
|
|
|
inline double get_row_step() const { return row_step; }
|
1999-03-20 20:32:51 +00:00
|
|
|
|
1999-03-29 13:11:00 +00:00
|
|
|
inline point_list get_corner_node_list() const { return corner_list; }
|
|
|
|
inline point_list get_fit_node_list() const { return node_list; }
|
1999-03-13 18:45:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _ARRAY_HXX
|
|
|
|
|
|
|
|
|
|
|
|
// $Log$
|
1999-04-05 21:32:32 +00:00
|
|
|
// Revision 1.1 1999/04/05 21:32:43 curt
|
|
|
|
// Initial revision
|
|
|
|
//
|
1999-04-05 02:15:23 +00:00
|
|
|
// Revision 1.6 1999/04/05 02:15:24 curt
|
|
|
|
// Make dem fitting more robust in cases when no dem file available.
|
|
|
|
//
|
1999-03-29 13:11:00 +00:00
|
|
|
// Revision 1.5 1999/03/29 13:11:02 curt
|
|
|
|
// Shuffled stl type names a bit.
|
|
|
|
// Began adding support for tri-fanning (or maybe other arrangments too.)
|
|
|
|
//
|
1999-03-27 05:20:13 +00:00
|
|
|
// Revision 1.4 1999/03/27 05:20:14 curt
|
|
|
|
// Handle corner nodes separately from the rest of the fitted nodes.
|
|
|
|
// Fixed some "const" related warnings.
|
|
|
|
//
|
1999-03-20 20:32:51 +00:00
|
|
|
// Revision 1.3 1999/03/20 20:32:52 curt
|
|
|
|
// First mostly successful tile triangulation works. There's plenty of tweaking
|
|
|
|
// to do, but we are marching in the right direction.
|
|
|
|
//
|
1999-03-13 23:50:26 +00:00
|
|
|
// Revision 1.2 1999/03/13 23:50:27 curt
|
|
|
|
// Tweaked output formatting a bit.
|
|
|
|
//
|
1999-03-13 18:45:02 +00:00
|
|
|
// Revision 1.1 1999/03/13 18:45:02 curt
|
|
|
|
// Initial revision. (derived from libDEM.a code.)
|
|
|
|
//
|