1
0
Fork 0

Don't generate a DEM tile when all elevations are zero. This should

save about 70% worldwide with the GTOPO30 (less with the USGS DEM-3).
This commit is contained in:
david 2002-10-26 16:50:50 +00:00
parent cb30b2d474
commit 2b660877a3
2 changed files with 25 additions and 0 deletions

View file

@ -432,6 +432,12 @@ FGDem::write_area( const string& root, SGBucket& b, bool compress ) {
return 0;
}
// If the area is all ocean, skip it.
if (!has_non_zero_elev(start_x, span_x, start_y, span_y)) {
cout << "Tile is all zero elevation: skipping" << endl;
return 0;
}
// generate output file name
string base = b.gen_base_path();
string path = root + "/" + base;
@ -878,3 +884,16 @@ FGDem::~FGDem( void ) {
}
bool
FGDem::has_non_zero_elev (int start_x, int span_x,
int start_y, int span_y) const
{
for (int i = start_x; i < start_x + span_x; i++) {
for (int j = start_y; j < start_y + span_y; j++) {
if (dem_data[i][j] != 0)
return true;
}
}
return false;
}

View file

@ -151,6 +151,12 @@ public:
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; }
/**
* Test whether an area contains any non-zero elevations.
*/
bool has_non_zero_elev (int start_x, int span_x,
int start_y, int span_y) const;
};