diff --git a/src/BuildTiles/CMakeLists.txt b/src/BuildTiles/CMakeLists.txt index 002435fb..311e08ae 100644 --- a/src/BuildTiles/CMakeLists.txt +++ b/src/BuildTiles/CMakeLists.txt @@ -4,7 +4,7 @@ include_directories(${PROJECT_SOURCE_DIR}/src/Lib) include_directories(${PROJECT_SOURCE_DIR}/src/BuildTiles) add_subdirectory(Osgb36) -#add_subdirectory(Parallel) +add_subdirectory(Parallel) add_subdirectory(Triangulate) add_subdirectory(Clipper) add_subdirectory(GenOutput) diff --git a/src/BuildTiles/Parallel/client.cxx b/src/BuildTiles/Parallel/client.cxx index c1355e0c..7adc8211 100644 --- a/src/BuildTiles/Parallel/client.cxx +++ b/src/BuildTiles/Parallel/client.cxx @@ -41,15 +41,17 @@ #include #include -#include +#include -#include +#include +#include +#include +#include using std::cout; using std::cerr; using std::endl; - #define MAXBUF 1024 #define BUSY_WAIT_TIME 30 @@ -76,7 +78,7 @@ void check_master_switch() { // check if the host system is free of interactive users int system_free() { -#if !defined(BSD) && !defined(__CYGWIN__) && !defined(_MSC_VER) +#if !defined(BSD) && !defined(__CYGWIN__) && !defined(_MSC_VER) && !defined(__APPLE__) struct utmp *uptr; setutent(); @@ -189,88 +191,68 @@ long int get_next_task( const string& host, int port, long int last_tile ) { return -1; } -bool endswith(const char* s, const char* suffix) { - size_t slen=strlen(s); - size_t sufflen=strlen(suffix); - if (slend_name,prefix.c_str(),prefix_len)) - continue; - string file=path+"/"+de->d_name; - if ( stat(file.c_str(), &src_stat) != 0) { - /* huh!? */ - cerr << " Could not stat file " << file << ":" << strerror(errno) << "\n"; - continue; - } - if ( have_btg && src_stat.st_mtime>btg_stat.st_mtime ) { - cout << " File " << file << " is newer than btg-file => rebuild\n"; - ulCloseDir(loaddir); - return true; - } - if ( have_stg && src_stat.st_mtime>stg_stat.st_mtime ) { - cout << " File " << file << " is newer than stg-file => rebuild\n"; - ulCloseDir(loaddir); - return true; - } - /* Ignore elevation data, as it is not used if we have no - * landmass data. So in addition to elevation data we need at - * least one polygon file. - */ - if ( endswith( de->d_name, ".arr.gz" ) || endswith( de->d_name, ".fit.gz" ) ) - continue; - if ( !(have_stg && have_btg) ) { - cout << " There is source-data (" << file << ") for tile " << b.gen_index_str() << " but .btg or .stg is missing => build\n"; - ulCloseDir(loaddir); - return true; - } + if (btg_file.exists() && (btg_file.modTime() < c.modTime())) { + cout << " File " << c.str() << " is newer than btg-file => rebuild\n"; + return true; } - ulCloseDir(loaddir); - } + if (stg_file.exists() && (stg_file.modTime() < c.modTime())) { + cout << " File " << c.str() << " is newer than stg-file => rebuild\n"; + return true; + } + + /* Ignore elevation data, as it is not used if we have no + * landmass data. So in addition to elevation data we need at + * least one polygon file. + */ + string lext = c.complete_lower_extension(); + if ((lext == "arr.gz") || (lext == "fit.gz")) { + continue; + } + + if ( !(stg_file.exists() && btg_file.exists()) ) { + cout << " There is source-data (" << c.str() << ") for tile " << b.gen_index_str() << " but .btg or .stg is missing => build\n"; + return true; + } + } // of load-dir child iteration + + } // of load dirs iteration return false; } diff --git a/src/Utils/CMakeLists.txt b/src/Utils/CMakeLists.txt index fd2f3993..3ad5ec9a 100644 --- a/src/Utils/CMakeLists.txt +++ b/src/Utils/CMakeLists.txt @@ -5,4 +5,4 @@ include_directories(${PROJECT_SOURCE_DIR}/src/Lib) # seems unfortunate that lib depends on other dirs #include_directories(${PROJECT_SOURCE_DIR}/src/BuildTiles) -#add_subdirectory(poly2ogr) +add_subdirectory(poly2ogr) diff --git a/src/Utils/poly2ogr/poly2ogr.cxx b/src/Utils/poly2ogr/poly2ogr.cxx index 8fe3c6fa..813969cb 100644 --- a/src/Utils/poly2ogr/poly2ogr.cxx +++ b/src/Utils/poly2ogr/poly2ogr.cxx @@ -35,12 +35,14 @@ # include #endif +#include + #include #include #include #include - -#include +#include +#include #include #include @@ -411,49 +413,31 @@ void process_points_file(const std::string& path) { } } -void process_file(const std::string& path) { - struct stat sbuf; - - if ( stat(path.c_str(),&sbuf) != 0 ) { - SG_LOG(SG_GENERAL, SG_ALERT, "Unable to stat path '" << path << "'"); - return; - } - - if (S_ISDIR(sbuf.st_mode)) { - ulDir* dir; - - dir=ulOpenDir(path.c_str()); - if (!dir) { - SG_LOG(SG_GENERAL, SG_ALERT, "Unable to open directory '" << path << "'"); - return; - } - - struct ulDirEnt *de; - - while ((de=ulReadDir(dir))) { - if (!strcmp(de->d_name,".") || !strcmp(de->d_name,"..")) { - continue; - } - - std::string subpath=path+"/"+de->d_name; - process_file(subpath); - } - - ulCloseDir(dir); - } else if (endswith(path,".pts")) { - // This is a points file - process_points_file(path); - } else if (endswith(path,".btg.gz") || endswith(path,".btg")) { - // This is a scenery file - process_scenery_file(path); - } else if (!endswith(path,".gz") && - !endswith(path,".arr") && - !endswith(path,".fit") && - !endswith(path,".stg") && - !endswith(path,".ind")) { - // should be a polygon file - process_polygon_file(path); +void process_file(const SGPath& path) +{ + if (path.isDir()) { + // recurse downwards! + simgear::Dir d(path); + int flags = simgear::Dir::TYPE_FILE | simgear::Dir::TYPE_DIR | + simgear::Dir::NO_DOT_OR_DOTDOT; + BOOST_FOREACH(const SGPath& c, d.children(flags)) { + process_file(c); } + + return; + } + + string lext = path.complete_lower_extension(); + if (lext == "pts") { + process_points_file(path.str()); + } else if ((lext == "btg.gz") || (lext == "btg")) { + process_scenery_file(path.str()); + } else if ((lext != "gz") && (lext != "arr") && (lext != "fit") && + (lext != "stg") && (lext != "ind")) + { + // should be a polygon file + process_polygon_file(path.str()); + } } void usage(const char* progname, const std::string& msg) { @@ -553,7 +537,7 @@ int main(int argc, char** argv) { } for (int i=optind;i