From ef22db9c3a8c231c2654568a6cc398a4d9fd3b31 Mon Sep 17 00:00:00 2001 From: curt Date: Sun, 27 Aug 2000 16:22:26 +0000 Subject: [PATCH] More tweaks as I work through the airport database. --- src/Airports/GenAirports/build.cxx | 9 +++--- src/Airports/GenAirports/build.hxx | 3 ++ src/Airports/GenAirports/main.cxx | 46 +++++++++++++++++++++++++----- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/src/Airports/GenAirports/build.cxx b/src/Airports/GenAirports/build.cxx index 10c2f079..9ae3f783 100644 --- a/src/Airports/GenAirports/build.cxx +++ b/src/Airports/GenAirports/build.cxx @@ -52,6 +52,7 @@ #include #include +#include "build.hxx" #include "convex_hull.hxx" #include "output.hxx" #include "point2d.hxx" @@ -691,13 +692,13 @@ static void gen_runway_section( const FGRunway& rwy_info, // that by nudging the areas a bit bigger so we don't end up with // polygon slivers. if ( startw_pct > 0.0 || endw_pct < 1.0 ) { - startl_pct -= 80 * FG_EPSILON; - endl_pct += 80 * FG_EPSILON; + startl_pct -= nudge * FG_EPSILON; + endl_pct += nudge * FG_EPSILON; if ( startw_pct > 0.0 ) { - startw_pct -= 80 * FG_EPSILON; + startw_pct -= nudge * FG_EPSILON; } if ( endw_pct < 1.0 ) { - endw_pct += 80 * FG_EPSILON; + endw_pct += nudge * FG_EPSILON; } } diff --git a/src/Airports/GenAirports/build.hxx b/src/Airports/GenAirports/build.hxx index 0568f429..10ecbd13 100644 --- a/src/Airports/GenAirports/build.hxx +++ b/src/Airports/GenAirports/build.hxx @@ -32,6 +32,9 @@ #include "point2d.hxx" +extern int nudge; + + // build 3d airport void build_airport( string airport, string_list& runways_raw, const string& root ); diff --git a/src/Airports/GenAirports/main.cxx b/src/Airports/GenAirports/main.cxx index c02460ac..95960a1b 100644 --- a/src/Airports/GenAirports/main.cxx +++ b/src/Airports/GenAirports/main.cxx @@ -48,6 +48,9 @@ #include "convex_hull.hxx" +int nudge = 10; + + // reads the apt_full file and extracts and processes the individual // airport records int main( int argc, char **argv ) { @@ -58,14 +61,43 @@ int main( int argc, char **argv ) { fglog().setLogLevels( FG_ALL, FG_DEBUG ); - if ( argc != 3 ) { + // parse arguments + string work_dir = ""; + string input_file; + int arg_pos; + for (arg_pos = 1; arg_pos < argc; arg_pos++) { + string arg = argv[arg_pos]; + if ( arg.find("--work=") == 0 ) { + work_dir = arg.substr(7); + } else if ( arg.find("--input=") == 0 ) { + input_file = arg.substr(8); + } 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 ]" ); + exit(-1); + } + } + + cout << "Input file = " << input_file << endl; + cout << "Work directory = " << work_dir << endl; + cout << "Nudge = " << nudge << endl; + + if ( work_dir == "" ) { FG_LOG( FG_GENERAL, FG_ALERT, - "Usage " << argv[0] << " " ); + "Error: no work directory specified." ); + exit(-1); + } + + if ( input_file == "" ) { + FG_LOG( FG_GENERAL, FG_ALERT, + "Error: no input file." ); exit(-1); } // make work directory - string work_dir = argv[2]; string command = "mkdir -p " + work_dir; system( command.c_str() ); @@ -73,9 +105,9 @@ int main( int argc, char **argv ) { string counter_file = work_dir + "/poly_counter"; poly_index_init( counter_file ); - fg_gzifstream in( argv[1] ); + fg_gzifstream in( input_file ); if ( !in ) { - FG_LOG( FG_GENERAL, FG_ALERT, "Cannot open file: " << argv[1] ); + FG_LOG( FG_GENERAL, FG_ALERT, "Cannot open file: " << input_file ); exit(-1); } @@ -100,7 +132,7 @@ 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, argv[2]); + build_airport(last_airport, runways_list, work_dir); } // clear runway list for start of next airport @@ -123,7 +155,7 @@ 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, argv[2]); + build_airport(last_airport, runways_list, work_dir); } return 0;