1
0
Fork 0

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
This commit is contained in:
curt 2000-11-28 20:45:10 +00:00
parent c8cc7e2a61
commit ebd254dae0
5 changed files with 35 additions and 11 deletions

View file

@ -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; }

View file

@ -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 );

View file

@ -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 {

View file

@ -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 ""

View file

@ -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 ) {