Add a routine to dump out the .hgt data in a simplistic ascii format.
This commit is contained in:
parent
bf96033516
commit
266772ee39
3 changed files with 33 additions and 6 deletions
|
@ -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() {
|
TGHgt::~TGHgt() {
|
||||||
// printf("class TGHgt DEstructor called.\n");
|
// printf("class TGHgt DEstructor called.\n");
|
||||||
delete [] data;
|
delete [] data;
|
||||||
|
|
|
@ -83,6 +83,9 @@ public:
|
||||||
// hand corner.
|
// hand corner.
|
||||||
bool write_area( const string& root, SGBucket& b );
|
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
|
// Informational methods
|
||||||
inline double get_originx() const { return originx; }
|
inline double get_originx() const { return originx; }
|
||||||
inline double get_originy() const { return originy; }
|
inline double get_originy() const { return originy; }
|
||||||
|
|
|
@ -3,15 +3,16 @@
|
||||||
#include "hgt.hxx"
|
#include "hgt.hxx"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
SGPath path1( "/stage/fgfs03/SRTM/United_States/N33W080/1arcsec/N33W080.hgt.gz" );
|
// 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 path3( "N37W123/3arcsec/N37W123.hgt.gz" );
|
||||||
|
|
||||||
TGHgt hgt1( 1, path1 );
|
// TGHgt hgt1( 1, path1 );
|
||||||
TGHgt hgt3( 3, path3 );
|
TGHgt hgt3( 3, path3 );
|
||||||
|
|
||||||
hgt1.load();
|
// hgt1.load();
|
||||||
hgt3.load();
|
hgt3.load();
|
||||||
|
|
||||||
SGBucket b(-79.5, 33.5);
|
// SGBucket b(-79.5, 33.5);
|
||||||
hgt1.write_area( ".", b );
|
// hgt1.write_area( ".", b );
|
||||||
|
hgt3.write_whole_ascii( "test.ahgt" );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue