Make dem fitting more robust in cases when no dem file available.
This commit is contained in:
parent
bcb6638535
commit
007bac3720
3 changed files with 67 additions and 22 deletions
|
@ -107,24 +107,55 @@ FGArray::close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// parse Array file
|
// parse Array file, pass in the bucket so we can make up values when
|
||||||
|
// the file wasn't found.
|
||||||
int
|
int
|
||||||
FGArray::parse() {
|
FGArray::parse( FGBucket& b ) {
|
||||||
*in >> originx >> originy;
|
if ( in->is_open() ) {
|
||||||
*in >> cols >> col_step;
|
// file open, parse
|
||||||
*in >> rows >> row_step;
|
*in >> originx >> originy;
|
||||||
|
*in >> cols >> col_step;
|
||||||
|
*in >> rows >> row_step;
|
||||||
|
|
||||||
cout << " origin = " << originx << " " << originy << endl;
|
cout << " origin = " << originx << " " << originy << endl;
|
||||||
cout << " cols = " << cols << " rows = " << rows << endl;
|
cout << " cols = " << cols << " rows = " << rows << endl;
|
||||||
cout << " col_step = " << col_step << " row_step = " << row_step <<endl;
|
cout << " col_step = " << col_step
|
||||||
|
<< " row_step = " << row_step <<endl;
|
||||||
|
|
||||||
for ( int i = 0; i < cols; i++ ) {
|
for ( int i = 0; i < cols; i++ ) {
|
||||||
for ( int j = 0; j < rows; j++ ) {
|
for ( int j = 0; j < rows; j++ ) {
|
||||||
*in >> in_data[i][j];
|
*in >> in_data[i][j];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
cout << " Done parsing\n";
|
cout << " Done parsing\n";
|
||||||
|
} else {
|
||||||
|
// file not open (not found?), fill with zero'd data
|
||||||
|
|
||||||
|
originx = ( b.get_center_lon() - 0.5 * b.get_width() ) * 3600.0;
|
||||||
|
originy = ( b.get_center_lat() - 0.5 * b.get_height() ) * 3600.0;
|
||||||
|
|
||||||
|
double max_x = ( b.get_center_lon() + 0.5 * b.get_width() ) * 3600.0;
|
||||||
|
double max_y = ( b.get_center_lat() + 0.5 * b.get_height() ) * 3600.0;
|
||||||
|
|
||||||
|
cols = 3;
|
||||||
|
col_step = (max_x - originx) / (cols - 1);
|
||||||
|
rows = 3;
|
||||||
|
row_step = (max_y - originy) / (rows - 1);
|
||||||
|
|
||||||
|
cout << " origin = " << originx << " " << originy << endl;
|
||||||
|
cout << " cols = " << cols << " rows = " << rows << endl;
|
||||||
|
cout << " col_step = " << col_step
|
||||||
|
<< " row_step = " << row_step <<endl;
|
||||||
|
|
||||||
|
for ( int i = 0; i < cols; i++ ) {
|
||||||
|
for ( int j = 0; j < rows; j++ ) {
|
||||||
|
in_data[i][j] = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << " File not open, so using zero'd data" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -132,9 +163,11 @@ FGArray::parse() {
|
||||||
|
|
||||||
// add a node to the output corner node list
|
// add a node to the output corner node list
|
||||||
void FGArray::add_corner_node( int i, int j, double val ) {
|
void FGArray::add_corner_node( int i, int j, double val ) {
|
||||||
|
|
||||||
double x = (originx + i * col_step) / 3600.0;
|
double x = (originx + i * col_step) / 3600.0;
|
||||||
double y = (originy + j * row_step) / 3600.0;
|
double y = (originy + j * row_step) / 3600.0;
|
||||||
// cout << Point3D(x, y, val) << endl;
|
// cout << "originx = " << originx << " originy = " << originy << endl;
|
||||||
|
// cout << "corner = " << Point3D(x, y, val) << endl;
|
||||||
corner_list.push_back( Point3D(x, y, val) );
|
corner_list.push_back( Point3D(x, y, val) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,8 +181,9 @@ void FGArray::add_fit_node( int i, int j, double val ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Use least squares to fit a simpler data set to dem data
|
// Use least squares to fit a simpler data set to dem data. Return
|
||||||
void FGArray::fit( double error ) {
|
// the number of fitted nodes
|
||||||
|
int FGArray::fit( double error ) {
|
||||||
double x[ARRAY_SIZE_1], y[ARRAY_SIZE_1];
|
double x[ARRAY_SIZE_1], y[ARRAY_SIZE_1];
|
||||||
double m, b, max_error, error_sq;
|
double m, b, max_error, error_sq;
|
||||||
double x1, y1;
|
double x1, y1;
|
||||||
|
@ -162,8 +196,9 @@ void FGArray::fit( double error ) {
|
||||||
|
|
||||||
error_sq = error * error;
|
error_sq = error * error;
|
||||||
|
|
||||||
cout << " Initializing output mesh structure" << endl;
|
cout << " Initializing fitted node list" << endl;
|
||||||
// outputmesh_init();
|
corner_list.clear();
|
||||||
|
node_list.clear();
|
||||||
|
|
||||||
// determine dimensions
|
// determine dimensions
|
||||||
colmin = 0;
|
colmin = 0;
|
||||||
|
@ -297,6 +332,9 @@ void FGArray::fit( double error ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// outputmesh_output_nodes(fg_root, p);
|
// outputmesh_output_nodes(fg_root, p);
|
||||||
|
|
||||||
|
// return fit nodes + 4 corners
|
||||||
|
return node_list.size() + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -539,6 +577,9 @@ FGArray::~FGArray( void ) {
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.8 1999/04/05 02:15:23 curt
|
||||||
|
// Make dem fitting more robust in cases when no dem file available.
|
||||||
|
//
|
||||||
// Revision 1.7 1999/03/27 14:05:10 curt
|
// Revision 1.7 1999/03/27 14:05:10 curt
|
||||||
// More sensible handling of the case where no dem file for this tile exists
|
// More sensible handling of the case where no dem file for this tile exists
|
||||||
// (or has been generated).
|
// (or has been generated).
|
||||||
|
|
|
@ -89,10 +89,11 @@ public:
|
||||||
int close();
|
int close();
|
||||||
|
|
||||||
// parse a Array file
|
// parse a Array file
|
||||||
int parse();
|
int parse( FGBucket& b );
|
||||||
|
|
||||||
// Use least squares to fit a simpler data set to dem data
|
// Use least squares to fit a simpler data set to dem data.
|
||||||
void fit( double error );
|
// Return the number of fitted nodes
|
||||||
|
int fit( double error );
|
||||||
|
|
||||||
// add a node to the output corner node list
|
// add a node to the output corner node list
|
||||||
void add_corner_node( int i, int j, double val );
|
void add_corner_node( int i, int j, double val );
|
||||||
|
@ -122,6 +123,9 @@ public:
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.6 1999/04/05 02:15:24 curt
|
||||||
|
// Make dem fitting more robust in cases when no dem file available.
|
||||||
|
//
|
||||||
// Revision 1.5 1999/03/29 13:11:02 curt
|
// Revision 1.5 1999/03/29 13:11:02 curt
|
||||||
// Shuffled stl type names a bit.
|
// Shuffled stl type names a bit.
|
||||||
// Began adding support for tri-fanning (or maybe other arrangments too.)
|
// Began adding support for tri-fanning (or maybe other arrangments too.)
|
||||||
|
|
|
@ -23,7 +23,7 @@ main(int argc, char **argv) {
|
||||||
cout << "arrayfile = " << arrayfile << endl;
|
cout << "arrayfile = " << arrayfile << endl;
|
||||||
|
|
||||||
FGArray a(arrayfile);
|
FGArray a(arrayfile);
|
||||||
a.parse();
|
a.parse( b );
|
||||||
|
|
||||||
lon *= 3600;
|
lon *= 3600;
|
||||||
lat *= 3600;
|
lat *= 3600;
|
||||||
|
|
Loading…
Add table
Reference in a new issue