From: curt Date: Thu, 6 May 1999 11:45:55 +0000 (+0000) Subject: master.cxx (outer shell for doing mass scenery generation) now working. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9488efde97ffd9f2e32d65b9ff44c272a1bf2d7c;p=flightgear.git master.cxx (outer shell for doing mass scenery generation) now working. --- diff --git a/Tools/Construct/Main/Makefile.am b/Tools/Construct/Main/Makefile.am index fd54cdf68..cf570b43c 100644 --- a/Tools/Construct/Main/Makefile.am +++ b/Tools/Construct/Main/Makefile.am @@ -20,6 +20,10 @@ construct_LDADD = \ master_SOURCES = master.cxx +master_LDADD = \ + $(top_builddir)/Lib/Bucket/libBucket.a \ + $(top_builddir)/Lib/Misc/libMisc.a + INCLUDES += \ -I$(top_builddir) \ -I$(top_builddir)/Lib \ diff --git a/Tools/Construct/Main/main.cxx b/Tools/Construct/Main/main.cxx index f60d867ba..c59080f2b 100644 --- a/Tools/Construct/Main/main.cxx +++ b/Tools/Construct/Main/main.cxx @@ -475,7 +475,7 @@ main(int argc, char **argv) { // lon = -90.757128; lat = 46.790212; // WI32 // lon = -122.220717; lat = 37.721291; // KOAK // lon = -111.721477; lat = 40.215641; // KPVU - // lon = -122.309313; lat = 47.448982; // KSEA + lon = -122.309313; lat = 47.448982; // KSEA // lon = -148.798131; lat = 63.645099; // AK06 (Danali, AK) // lon = -92.5; lat = 47.5; // Marsh test (northern MN) // lon = -111.977773; lat = 40.788388; // KSLC diff --git a/Tools/Construct/Main/master.cxx b/Tools/Construct/Main/master.cxx index 192c18ea1..04d2f9cae 100644 --- a/Tools/Construct/Main/master.cxx +++ b/Tools/Construct/Main/master.cxx @@ -21,8 +21,9 @@ // $Id$ -#include // for directory reading -#include // for directory reading +#include // for system() +#include // for stat() +#include // for stat() #include @@ -39,9 +40,31 @@ // #include +// return true if file exists +static bool file_exists( const string& file ) { + struct stat buf; + + if ( stat( file.c_str(), &buf ) == 0 ) { + return true; + } else { + return false; + } +} + + // check if the specified tile has data defined for it static bool has_data( const string& path, const FGBucket& b ) { - + string dem_file = path + ".dem" + "/Scenery/" + b.gen_base_path() + + "/" + b.gen_index_str() + ".dem"; + if ( file_exists( dem_file ) ) { + return true; + } + + dem_file += ".gz"; + if ( file_exists( dem_file ) ) { + return true; + } + return false; } @@ -49,7 +72,28 @@ static bool has_data( const string& path, const FGBucket& b ) { // build the tile and check for success bool build_tile( const string& work_base, const string& output_base, const FGBucket& b ) { - return true; + string result_file = "result"; + + string command = "./construct " + work_base + " " + output_base + " " + + b.gen_index_str() + " > " + result_file + " 2>&1"; + cout << command << endl; + + system( command.c_str() ); + + FILE *fp = fopen( result_file.c_str(), "r" ); + char line[256]; + while ( fgets( line, 256, fp ) != NULL ) { + string line_str = line; + line_str = line_str.substr(0, line_str.length() - 1); + cout << line_str << endl; + if ( line_str == "[Finished successfully]" ) { + fclose(fp); + return true; + } + } + + fclose(fp); + return false; } @@ -85,7 +129,10 @@ main(int argc, char **argv) { cout << "Bucket = " << b << endl; if ( has_data( work_base, b ) ) { - build_tile( work_base, output_base, b ); + if ( ! build_tile( work_base, output_base, b ) ) { + cout << "error building last tile" << endl; + exit(-1); + } } lon += dx;