From 007bac3720e694fddde672b5ecbe2645ab2d1f2b Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 5 Apr 1999 02:15:23 +0000 Subject: [PATCH] Make dem fitting more robust in cases when no dem file available. --- Array/array.cxx | 81 ++++++++++++++++++++++++++++++++++----------- Array/array.hxx | 10 ++++-- Array/testarray.cxx | 2 +- 3 files changed, 69 insertions(+), 24 deletions(-) diff --git a/Array/array.cxx b/Array/array.cxx index af1e32f7d..2b7d2a625 100644 --- a/Array/array.cxx +++ b/Array/array.cxx @@ -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 -FGArray::parse() { - *in >> originx >> originy; - *in >> cols >> col_step; - *in >> rows >> row_step; - - cout << " origin = " << originx << " " << originy << endl; - cout << " cols = " << cols << " rows = " << rows << endl; - cout << " col_step = " << col_step << " row_step = " << row_step <> in_data[i][j]; +FGArray::parse( FGBucket& b ) { + if ( in->is_open() ) { + // file open, parse + *in >> originx >> originy; + *in >> cols >> col_step; + *in >> rows >> row_step; + + cout << " origin = " << originx << " " << originy << endl; + cout << " cols = " << cols << " rows = " << rows << endl; + cout << " col_step = " << col_step + << " row_step = " << row_step <> 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 <