1
0
Fork 0

Updates ...

This commit is contained in:
curt 2000-08-29 21:16:54 +00:00
parent ef22db9c3a
commit 3802a0385f
2 changed files with 114 additions and 8 deletions

View file

@ -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=<apt_file> "
<< "--work=<work_dir> [ --nudge=n ]" );
<< "--work=<work_dir> [ --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;
}

View file

@ -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 ( <PIPE> ) {
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";
}
}