From ebd254dae0e0eac508183908c42062f6591a2e68 Mon Sep 17 00:00:00 2001 From: curt <curt> Date: Tue, 28 Nov 2000 20:45:10 +0000 Subject: [PATCH] Contributions from David Megginson: Added a new option, --cover, to fgfs-construct and fgfs-tools-client. The option takes an argument giving the location of the land-cover raster file; if it is not specified, land-cover is not built. Curt tweaked the code that divides up the tile into land use squares but there are still a couple slightly fishy things going on there.Z --- src/BuildTiles/Main/construct.hxx | 9 ++++++++- src/BuildTiles/Main/main.cxx | 17 +++++++++++------ src/BuildTiles/Parallel/client.cxx | 15 ++++++++++++--- src/BuildTiles/Parallel/fgfs-launch-clients | 2 +- src/Lib/Geometry/poly_support.cxx | 3 +++ 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/BuildTiles/Main/construct.hxx b/src/BuildTiles/Main/construct.hxx index dba81b5f..33fb6bab 100644 --- a/src/BuildTiles/Main/construct.hxx +++ b/src/BuildTiles/Main/construct.hxx @@ -62,6 +62,9 @@ private: // minimum interior angle for triangulation string angle; + // path to land-cover file (if any) + string cover; + // paths string work_base; string output_base; @@ -111,7 +114,11 @@ public: // minimum interior angle for triangulation inline string get_angle() const { return angle; } - inline void set_angle( const string s ) { angle = s; } + inline void set_angle( const string &s ) { angle = s; } + + // land cover file + inline string get_cover () const { return cover; } + inline void set_cover (const string &s) { cover = s; } // paths inline string get_work_base() const { return work_base; } diff --git a/src/BuildTiles/Main/main.cxx b/src/BuildTiles/Main/main.cxx index bba8f7a9..3f769219 100644 --- a/src/BuildTiles/Main/main.cxx +++ b/src/BuildTiles/Main/main.cxx @@ -221,9 +221,10 @@ static void inline add_to_polys ( FGPolygon &accum, const FGPolygon &poly) { // Generate polygons from la and-cover raster. Horizontally- or // vertically-adjacent polygons will be merged automatically. -static int actual_load_landcover ( LandCover &cover, FGConstruct & c, +static int actual_load_landcover ( FGConstruct & c, FGClipper &clipper ) { + LandCover cover(c.get_cover()); int count = 0; FGPolygon polys[FG_MAX_AREA_TYPES]; FGPolygon poly; // working polygon @@ -317,11 +318,10 @@ static int load_polys( FGConstruct& c ) { cout << " loaded " << count << " total polys" << endl; } - // Load the land use polygons - string glc = c.get_work_base(); - glc += "/LC-Global/gusgs2_0ll.img"; - LandCover cover( glc ); - count += actual_load_landcover ( cover, c, clipper ); + // Load the land use polygons if the --cover option was specified + if ( c.get_cover().size() > 0 ) { + count += actual_load_landcover (c, clipper); + } point2d min, max; min.x = c.get_bucket().get_center_lon() - 0.5 * c.get_bucket().get_width(); @@ -944,6 +944,7 @@ static void usage( const string name ) { cout << "Usage: " << name << endl; cout << "[ --output-dir=<directory>" << endl; cout << " --work-dir=<directory>" << endl; + cout << " --cover=<path to land-cover raster>" << endl; cout << " --min-angle=<angle>" << endl; cout << " --tile-id=<id>" << endl; cout << " --lon=<degrees>" << endl; @@ -959,6 +960,7 @@ int main(int argc, char **argv) { string output_dir = "."; string work_dir = "."; string min_angle = "10"; + string cover = ""; double lon = -110.664244; // P13 double lat = 33.352890; double xdist = -1; // 1/2 degree in each direction @@ -990,6 +992,8 @@ int main(int argc, char **argv) { xdist = atof(arg.substr(8).c_str()); } else if (arg.find("--ydist=") == 0) { ydist = atof(arg.substr(8).c_str()); + } else if (arg.find("--cover=") == 0) { + cover = arg.substr(8); } else if (arg.find("--") == 0) { usage(argv[0]); } else { @@ -1043,6 +1047,7 @@ int main(int argc, char **argv) { FGConstruct c; c.set_angle( min_angle ); + c.set_cover( cover ); c.set_work_base( work_dir ); c.set_output_base( output_dir ); diff --git a/src/BuildTiles/Parallel/client.cxx b/src/BuildTiles/Parallel/client.cxx index 8e76ebd8..8c8650d9 100644 --- a/src/BuildTiles/Parallel/client.cxx +++ b/src/BuildTiles/Parallel/client.cxx @@ -173,7 +173,9 @@ long int get_next_task( const string& host, int port, long int last_tile ) { // build the specified tile, return true if contruction completed // successfully -bool construct_tile( const FGBucket& b, const string& result_file ) { +bool construct_tile( const FGBucket& b, + const string& result_file, + const string &cover ) { double angle = 10.0; bool still_trying = true; @@ -186,6 +188,9 @@ bool construct_tile( const FGBucket& b, const string& result_file ) { command = command + " --work-dir=" + work_base; command = command + " --output-dir=" + output_base; command = command + " --tile-id=" + b.gen_index_str(); + if ( cover.size() > 0 ) { + command = command + " --cover=" + cover; + } for (int i = 0; i < (int)load_dirs.size(); i++) { command = command + " " + load_dirs[i]; } @@ -238,7 +243,8 @@ usage (const string name) cout << " --work-dir=<directory>" << endl; cout << " --host=<address>" << endl; cout << " --port=<number>" << endl; - cout << " --rude ]" << endl; + cout << " --rude" << endl; + cout << " --cover=<landcover-raster> ]" << endl; cout << "<load directory...>" << endl; exit(-1); } @@ -248,6 +254,7 @@ int main(int argc, char *argv[]) { bool rude = false; bool result; + string cover; string host = "127.0.0.1"; int port=4001; @@ -268,6 +275,8 @@ int main(int argc, char *argv[]) { port = atoi(arg.substr(7).c_str()); } else if (arg == "--rude") { rude = true; + } else if (arg.find("--cover=") == 0) { + cover = arg.substr(8); } else if (arg.find("--") == 0) { usage(argv[0]); } else { @@ -306,7 +315,7 @@ int main(int argc, char *argv[]) { check_master_switch(); while ( (tile = get_next_task( host, port, last_tile )) >= 0 ) { - result = construct_tile( FGBucket(tile), result_file ); + result = construct_tile( FGBucket(tile), result_file, cover ); if ( result ) { last_tile = tile; } else { diff --git a/src/BuildTiles/Parallel/fgfs-launch-clients b/src/BuildTiles/Parallel/fgfs-launch-clients index 19c72c3d..0a39f720 100755 --- a/src/BuildTiles/Parallel/fgfs-launch-clients +++ b/src/BuildTiles/Parallel/fgfs-launch-clients @@ -100,7 +100,7 @@ for i in $CLIENTS_RUDE; do # KILL_COMMAND="killall $CLIENT" # ssh -n $i "$KILL_COMMAND" - RMT_COMMAND="source ~/.profile; nice $CLIENT --host=$SERVER_HOST --port=$SERVER_PORT --work-dir=$WORK_BASE --output-dir=$OUTPUT_DIR --rude AirportArea AirportObj GSHHS-Ponds GSHHS-Islands GSHHS-Lakes GSHHS-LandMass USA-Hydro USA-Urban DEM-3 DEM-30" + RMT_COMMAND="source ~/.profile; nice $CLIENT --host=$SERVER_HOST --port=$SERVER_PORT --work-dir=$WORK_BASE --output-dir=$OUTPUT_DIR --rude --cover=$WORK_BASE/LC-Global/gusgs2_0ll.img AirportArea AirportObj GSHHS-Ponds GSHHS-Islands GSHHS-Lakes GSHHS-LandMass USA-Hydro USA-Urban DEM-3 DEM-30" # RMT_COMMAND="source ~/.profile; nice $CLIENT --host=$SERVER_HOST --port=$SERVER_PORT --work-dir=$WORK_BASE --output-dir=$OUTPUT_DIR --rude AirportArea AirportObj GSHHS-Ponds GSHHS-Islands GSHHS-Lakes GSHHS-LandMass LC-USA USA-Hydro USA-Urban DEM-3 DEM-30" echo "client command:" echo "" diff --git a/src/Lib/Geometry/poly_support.cxx b/src/Lib/Geometry/poly_support.cxx index aaef3810..c4c340e7 100644 --- a/src/Lib/Geometry/poly_support.cxx +++ b/src/Lib/Geometry/poly_support.cxx @@ -708,6 +708,9 @@ static void contour_tesselate( FGContourNode *node, const FGPolygon &p, #if 0 +// depricated code, also note the method for finding the center point +// of a triangle is depricated and weights the 3 vertices unevenly. + // Find a point inside the polygon without regard for holes static Point3D point_inside_hole( point_list contour ) {