1
0
Fork 0

hgt: Remove dependency on Boost

hgtchop: General code maintenance
This commit is contained in:
xDraconian 2018-06-16 18:38:02 -05:00 committed by James Turner
parent acfecfbc4d
commit 51f9c54076
2 changed files with 17 additions and 20 deletions

View file

@ -40,8 +40,6 @@
# include <direct.h> # include <direct.h>
#endif #endif
#include <boost/foreach.hpp>
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/io/lowlevel.hxx> #include <simgear/io/lowlevel.hxx>
#include <simgear/misc/sg_dir.hxx> #include <simgear/misc/sg_dir.hxx>
@ -97,7 +95,7 @@ TGHgt::open ( const SGPath &f ) {
if ( system( command.c_str() ) != -1 ) if ( system( command.c_str() ) != -1 )
{ {
simgear::PathList files = tmp_dir.children(simgear::Dir::TYPE_FILE | simgear::Dir::NO_DOT_OR_DOTDOT); simgear::PathList files = tmp_dir.children(simgear::Dir::TYPE_FILE | simgear::Dir::NO_DOT_OR_DOTDOT);
BOOST_FOREACH(const SGPath& file, files) { for (const SGPath& file : files) {
string ext = file.lower_extension(); string ext = file.lower_extension();
if ( ext == "hgt" ) { if ( ext == "hgt" ) {
file_name = file; file_name = file;

View file

@ -26,6 +26,7 @@
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <cstdlib>
#include <string> #include <string>
#include <iostream> #include <iostream>
@ -37,8 +38,6 @@
#include <Include/version.h> #include <Include/version.h>
#include <HGT/hgt.hxx> #include <HGT/hgt.hxx>
#include <stdlib.h>
using std::cout; using std::cout;
using std::endl; using std::endl;
using std::string; using std::string;
@ -49,22 +48,21 @@ int main(int argc, char **argv) {
SG_LOG( SG_GENERAL, SG_ALERT, "hgtchop version " << getTGVersion() << "\n" ); SG_LOG( SG_GENERAL, SG_ALERT, "hgtchop version " << getTGVersion() << "\n" );
if ( argc != 4 ) { if ( argc != 4 ) {
cout << "Usage " << argv[0] << " <resolution> <hgt_file> <work_dir>" cout << "Usage " << argv[0] << " <resolution> <hgt_file> <work_dir>" << endl;
<< endl;
cout << endl; cout << endl;
cout << "\tresolution must be either 1 or 3 for 1arcsec or 3arcsec" cout << "\tresolution must be either 1 or 3 (1-arc-sec or 3-arc-sec)" << endl;
<< endl;
exit(-1); return EXIT_FAILURE;
} }
int resolution = atoi( argv[1] ); int resolution = std::stoi(string(argv[1]));
string hgt_name = argv[2]; string hgt_name = string(argv[2]);
string work_dir = argv[3]; string work_dir = string(argv[3]);
// determine if file is 1arcsec or 3arcsec variety // determine if file is 1arc-sec or 3arc-sec variety
if ( resolution != 1 && resolution != 3 ) { if ( resolution != 1 && resolution != 3 ) {
cout << "ERROR: resolution must be 1 or 3." << endl; cout << "ERROR: resolution must be 1 or 3." << endl;
exit( -1 ); return EXIT_FAILURE;
} }
SGPath sgp( work_dir ); SGPath sgp( work_dir );
@ -86,24 +84,25 @@ int main(int argc, char **argv) {
hgt.write_area( work_dir, b_min ); hgt.write_area( work_dir, b_min );
} else { } else {
SGBucket b_cur; SGBucket b_cur;
int dx, dy, i, j;
int dx, dy;
sgBucketDiff(b_min, b_max, &dx, &dy); sgBucketDiff(b_min, b_max, &dx, &dy);
cout << "HGT file spans tile boundaries (ok)" << endl; cout << "HGT file spans tile boundaries (ok)" << endl;
cout << " dx = " << dx << " dy = " << dy << endl; cout << " dx = " << dx << " dy = " << dy << endl;
if ( (dx > 20) || (dy > 20) ) { if ( (dx > 20) || (dy > 20) ) {
cout << "somethings really wrong!!!!" << endl; cout << "somethings really wrong!!!!" << endl;
exit(-1); return EXIT_FAILURE;
} }
for ( j = 0; j <= dy; j++ ) { for ( int j = 0; j <= dy; ++j ) {
for ( i = 0; i <= dx; i++ ) { for ( int i = 0; i <= dx; ++i ) {
b_cur = b_min.sibling(i, j); b_cur = b_min.sibling(i, j);
hgt.write_area( work_dir, b_cur ); hgt.write_area( work_dir, b_cur );
} }
} }
} }
return 0; return EXIT_SUCCESS;
} }