From 3802a0385ff9acd17c35877b536a463ba2523bd3 Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 29 Aug 2000 21:16:54 +0000 Subject: [PATCH] Updates ... --- src/Airports/GenAirports/main.cxx | 48 +++++++++++++++---- src/Airports/GenAirports/process.pl | 74 +++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 8 deletions(-) create mode 100755 src/Airports/GenAirports/process.pl diff --git a/src/Airports/GenAirports/main.cxx b/src/Airports/GenAirports/main.cxx index 95960a1b..891ae6e3 100644 --- a/src/Airports/GenAirports/main.cxx +++ b/src/Airports/GenAirports/main.cxx @@ -58,12 +58,14 @@ int main( int argc, char **argv ) { string airport, last_airport; string line; char tmp[256]; + bool ready_to_go = true; fglog().setLogLevels( FG_ALL, FG_DEBUG ); // parse arguments string work_dir = ""; - string input_file; + string input_file = ""; + string start_id = ""; int arg_pos; for (arg_pos = 1; arg_pos < argc; arg_pos++) { string arg = argv[arg_pos]; @@ -71,12 +73,15 @@ int main( int argc, char **argv ) { work_dir = arg.substr(7); } else if ( arg.find("--input=") == 0 ) { input_file = arg.substr(8); + } else if ( arg.find("--start-id=") == 0 ) { + start_id = arg.substr(11); + ready_to_go = false; } else if ( arg.find("--nudge=") == 0 ) { nudge = atoi( arg.substr(8).c_str() ); } else { FG_LOG( FG_GENERAL, FG_ALERT, "Usage " << argv[0] << " --input= " - << "--work= [ --nudge=n ]" ); + << "--work= [ --start-id=abcd ] [ --nudge=n ]" ); exit(-1); } } @@ -130,9 +135,24 @@ int main( int argc, char **argv ) { airport = line; if ( last_airport.length() ) { - // process previous record - // process_airport(last_airport, runways_list, argv[2]); - build_airport(last_airport, runways_list, work_dir); + char ctmp, id[32]; + sscanf( last_airport.c_str(), "%c %s", &ctmp, id ); + cout << "Id portion = " << id << endl; + + if ( start_id.length() && start_id == (string)id ) { + ready_to_go = true; + } + + if ( ready_to_go ) { + // check point our location + char command[256]; + sprintf( command, "echo %s > last_apt", id ); + system( command ); + + // process previous record + // process_airport(last_airport, runways_list, argv[2]); + build_airport(last_airport, runways_list, work_dir); + } } // clear runway list for start of next airport @@ -153,11 +173,23 @@ int main( int argc, char **argv ) { } if ( last_airport.length() ) { - // process previous record - // process_airport(last_airport, runways_list, argv[2]); - build_airport(last_airport, runways_list, work_dir); + char ctmp, id[32]; + sscanf( last_airport.c_str(), "%c %s", &ctmp, id ); + cout << "Id portion = " << id << endl; + + if ( start_id.length() && start_id == id ) { + ready_to_go = true; + } + + if ( ready_to_go ) { + // process previous record + // process_airport(last_airport, runways_list, argv[2]); + build_airport(last_airport, runways_list, work_dir); + } } + cout << "[FINISHED CORRECTLY]" << endl; + return 0; } diff --git a/src/Airports/GenAirports/process.pl b/src/Airports/GenAirports/process.pl new file mode 100755 index 00000000..ead98493 --- /dev/null +++ b/src/Airports/GenAirports/process.pl @@ -0,0 +1,74 @@ +#!/usr/bin/perl + +# this is a sad testament to building your software off of other +# libraries that have bugs (or perhaps less than disired features.) +# Unfortunatley I don't know enough about the functionality they +# provide to go fix them. Maybe someday. + +# At any rate. This script is a wrapper around the main airport +# generation utility. It run it until it finishes or crashes. If it +# finishes without saying, yup I'm all done, a crash is assumed. We +# re-run the airport generate from the crash point with a different +# nudge factor in a sorry attempt to work around the bug. + +# yes, I know this is a really ugly hack, I apologize in advance to +# those who might have trouble running these tools on non-unix +# platforms, but I'm not sure what else to do at this point. If +# someone can fix the polygon clipping library so it doesn't leave +# tiny shards of polygons or cracks, I'd be very grateful. + +# So here we go, children under 13 years of age should probably have +# parental supervision if playing with something this ugly. + + +# Edit the following values to set up your preferences: + +$workdir = "./work"; +# $inputfile = "./default.apt"; +$inputfile = "default.apt"; +$binary = "./genapts"; +$startid = ""; + +# end of user configurable section + + +$done = 0; +$nudge = 0; + +while ( ! $done ) { + + # update the nudge value + $nudge += 5; + if ( $nudge > 20 ) { + $nudge = 5; + } + + # launch the airport generator + + $command = "$binary --input=$inputfile --work=$workdir --nudge=$nudge"; + + if ( $startid ne "" ) { + $command .= " --start-id=$startid"; + } + + print "Executing $command\n"; + open( PIPE, "$command |" ) || die "Cannot run $command\n"; + + while ( ) { + if ( m/Id portion/ ) { + print $_; + } + + if ( m/\[FINISHED CORRECTLY\]/ ) { + $done = 1; + print "FINISHED!\n"; + } + } + + close ( PIPE ); + + if ( ! $done ) { + $startid = `cat last_apt`; chop( $startid ); + print "Restarting at $startid.\n"; + } +}