diff --git a/src/Lib/HGT/hgt.cxx b/src/Lib/HGT/hgt.cxx index 39a31fec..028261e7 100644 --- a/src/Lib/HGT/hgt.cxx +++ b/src/Lib/HGT/hgt.cxx @@ -229,6 +229,29 @@ TGHgt::write_area( const string& root, SGBucket& b ) { } +// write the entire area out in a simple ascii format +bool TGHgt::write_whole_ascii( const string& file ) { + cout << "writing to " << file << endl; + // write the file + gzFile fp; + if ( (fp = gzopen( file.c_str(), "wb9" )) == NULL ) { + cout << "ERROR: cannot open " << file << " for writing!" << endl; + exit(-1); + } + + gzprintf( fp, "%d\n%d\n", rows, cols ); + for ( int i = 0; i < rows; i++ ) { + for ( int j = 0; j < cols; j++ ) { + gzprintf( fp, "%d\n", (int)data[i][j] ); + } + } + gzclose(fp); + + return true; +} + + + TGHgt::~TGHgt() { // printf("class TGHgt DEstructor called.\n"); delete [] data; diff --git a/src/Lib/HGT/hgt.hxx b/src/Lib/HGT/hgt.hxx index 6e316dbe..395a0afe 100644 --- a/src/Lib/HGT/hgt.hxx +++ b/src/Lib/HGT/hgt.hxx @@ -83,6 +83,9 @@ public: // hand corner. bool write_area( const string& root, SGBucket& b ); + // write the entire area out in a simple ascii format + bool write_whole_ascii( const string& file ); + // Informational methods inline double get_originx() const { return originx; } inline double get_originy() const { return originy; } diff --git a/src/Lib/HGT/testhgt.cxx b/src/Lib/HGT/testhgt.cxx index 4d81ba04..47dde591 100644 --- a/src/Lib/HGT/testhgt.cxx +++ b/src/Lib/HGT/testhgt.cxx @@ -3,15 +3,16 @@ #include "hgt.hxx" int main() { - SGPath path1( "/stage/fgfs03/SRTM/United_States/N33W080/1arcsec/N33W080.hgt.gz" ); - SGPath path3( "/stage/fgfs03/SRTM/United_States/N33W080/3arcsec/N33W080.hgt.gz" ); + // SGPath path1( "/stage/fgfs03/SRTM/United_States/N33W080/1arcsec/N33W080.hgt.gz" ); + SGPath path3( "N37W123/3arcsec/N37W123.hgt.gz" ); - TGHgt hgt1( 1, path1 ); + // TGHgt hgt1( 1, path1 ); TGHgt hgt3( 3, path3 ); - hgt1.load(); + // hgt1.load(); hgt3.load(); - SGBucket b(-79.5, 33.5); - hgt1.write_area( ".", b ); + // SGBucket b(-79.5, 33.5); + // hgt1.write_area( ".", b ); + hgt3.write_whole_ascii( "test.ahgt" ); }