]> git.mxchange.org Git - flightgear.git/commitdiff
master.cxx (outer shell for doing mass scenery generation) now working.
authorcurt <curt>
Thu, 6 May 1999 11:45:55 +0000 (11:45 +0000)
committercurt <curt>
Thu, 6 May 1999 11:45:55 +0000 (11:45 +0000)
Tools/Construct/Main/Makefile.am
Tools/Construct/Main/main.cxx
Tools/Construct/Main/master.cxx

index fd54cdf6899883c3995b3b167f88e4642c32fcb3..cf570b43ca10efe09a6f65b1fdbcd86f3b3b501b 100644 (file)
@@ -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 \
index f60d867ba3750ef6b3a93d8bf147ee1a5aebf891..c59080f2bd0a7ccb14f47022770b16f6dc0e107a 100644 (file)
@@ -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
index 192c18ea197bda6ddbb2c1e2bb7161cf37b6770c..04d2f9cae22c78ec2d8cb2f1a7b3b817c70ab41e 100644 (file)
@@ -21,8 +21,9 @@
 // $Id$
 
 
-#include <sys/types.h>  // for directory reading
-#include <dirent.h>     // for directory reading
+#include <stdlib.h>    // for system()
+#include <sys/stat.h>  // for stat()
+#include <unistd.h>    // for stat()
 
 #include <string>
 
 // #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
 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;