master.cxx (outer shell for doing mass scenery generation) now working.
This commit is contained in:
parent
e03dbcee10
commit
9488efde97
3 changed files with 57 additions and 6 deletions
|
@ -20,6 +20,10 @@ construct_LDADD = \
|
||||||
|
|
||||||
master_SOURCES = master.cxx
|
master_SOURCES = master.cxx
|
||||||
|
|
||||||
|
master_LDADD = \
|
||||||
|
$(top_builddir)/Lib/Bucket/libBucket.a \
|
||||||
|
$(top_builddir)/Lib/Misc/libMisc.a
|
||||||
|
|
||||||
INCLUDES += \
|
INCLUDES += \
|
||||||
-I$(top_builddir) \
|
-I$(top_builddir) \
|
||||||
-I$(top_builddir)/Lib \
|
-I$(top_builddir)/Lib \
|
||||||
|
|
|
@ -475,7 +475,7 @@ main(int argc, char **argv) {
|
||||||
// lon = -90.757128; lat = 46.790212; // WI32
|
// lon = -90.757128; lat = 46.790212; // WI32
|
||||||
// lon = -122.220717; lat = 37.721291; // KOAK
|
// lon = -122.220717; lat = 37.721291; // KOAK
|
||||||
// lon = -111.721477; lat = 40.215641; // KPVU
|
// 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 = -148.798131; lat = 63.645099; // AK06 (Danali, AK)
|
||||||
// lon = -92.5; lat = 47.5; // Marsh test (northern MN)
|
// lon = -92.5; lat = 47.5; // Marsh test (northern MN)
|
||||||
// lon = -111.977773; lat = 40.788388; // KSLC
|
// lon = -111.977773; lat = 40.788388; // KSLC
|
||||||
|
|
|
@ -21,8 +21,9 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
#include <sys/types.h> // for directory reading
|
#include <stdlib.h> // for system()
|
||||||
#include <dirent.h> // for directory reading
|
#include <sys/stat.h> // for stat()
|
||||||
|
#include <unistd.h> // for stat()
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -39,9 +40,31 @@
|
||||||
// #include <Triangulate/triangle.hxx>
|
// #include <Triangulate/triangle.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
// 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
|
// check if the specified tile has data defined for it
|
||||||
static bool has_data( const string& path, const FGBucket& b ) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +72,28 @@ static bool has_data( const string& path, const FGBucket& b ) {
|
||||||
// build the tile and check for success
|
// build the tile and check for success
|
||||||
bool build_tile( const string& work_base, const string& output_base,
|
bool build_tile( const string& work_base, const string& output_base,
|
||||||
const FGBucket& b ) {
|
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;
|
cout << "Bucket = " << b << endl;
|
||||||
|
|
||||||
if ( has_data( work_base, b ) ) {
|
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;
|
lon += dx;
|
||||||
|
|
Loading…
Add table
Reference in a new issue