remove using std::
clean up
This commit is contained in:
parent
ae6006f350
commit
bbb9d746a0
1 changed files with 162 additions and 218 deletions
|
@ -14,30 +14,29 @@
|
|||
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/io/iostreams/sgstream.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/misc/strutils.hxx>
|
||||
|
||||
#include <Include/version.h>
|
||||
|
||||
#include "scheduler.hxx"
|
||||
#include "beznode.hxx"
|
||||
#include "closedpoly.hxx"
|
||||
#include "linearfeature.hxx"
|
||||
#include "parser.hxx"
|
||||
#include "scheduler.hxx"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// Display usage
|
||||
static void usage( int argc, char **argv ) {
|
||||
static void usage(int argc, char** argv)
|
||||
{
|
||||
TG_LOG(SG_GENERAL, SG_ALERT, "Usage: " << argv[0] << "\n--input=<apt_file>"
|
||||
<< "\n--work=<work_dir>\n[ --start-id=abcd ] [ --nudge=n ] "
|
||||
<< "[--min-lon=<deg>] [--max-lon=<deg>] [--min-lat=<deg>] [--max-lat=<deg>] "
|
||||
|
@ -46,7 +45,8 @@ static void usage( int argc, char **argv ) {
|
|||
}
|
||||
|
||||
|
||||
void setup_default_elevation_sources(string_list& elev_src) {
|
||||
void setup_default_elevation_sources(string_list& elev_src)
|
||||
{
|
||||
elev_src.push_back("SRTM2-Africa-3");
|
||||
elev_src.push_back("SRTM2-Australia-3");
|
||||
elev_src.push_back("SRTM2-Eurasia-3");
|
||||
|
@ -62,43 +62,43 @@ void setup_default_elevation_sources(string_list& elev_src) {
|
|||
}
|
||||
|
||||
// Display help and usage
|
||||
static void help( int argc, char **argv, const string_list& elev_src ) {
|
||||
cout << "genapts generates airports for use in generating scenery for the FlightGear flight simulator. \n";
|
||||
cout << "Airport, runway, and taxiway vector data and attributes are input, and generated 3D airports \n";
|
||||
cout << "are output for further processing by the TerraGear scenery creation tools. \n";
|
||||
cout << "\n\n";
|
||||
cout << "The standard input file is apt.dat.gz which is found in $FG_ROOT/Airports. \n";
|
||||
cout << "This file is periodically generated by Robin Peel, who maintains \n";
|
||||
cout << "the airport database for both the X-Plane and FlightGear simulators. \n";
|
||||
cout << "The format of this file is documented at \n";
|
||||
cout << "http://data.x-plane.com/designers.html#Formats \n";
|
||||
cout << "Any other input file corresponding to this format may be used as input to genapts. \n";
|
||||
cout << "Input files may be gzipped or left as plain text as required. \n";
|
||||
cout << "\n\n";
|
||||
cout << "Processing all the world's airports takes a *long* time. To cut down processing time \n";
|
||||
cout << "when only some airports are required, you may refine the input selection either by airport \n";
|
||||
cout << "or by area. By airport, either one airport can be specified using --airport=abcd, where abcd is \n";
|
||||
cout << "a valid airport code eg. --airport-id=KORD, or a starting airport can be specified using --start-id=abcd \n";
|
||||
cout << "where once again abcd is a valid airport code. In this case, all airports in the file subsequent to the \n";
|
||||
cout << "start-id are done. This is convenient when re-starting after a previous error. \n";
|
||||
cout << "\nAn input area may be specified by lat and lon extent using min and max lat and lon. \n";
|
||||
cout << "\nAn input file containing only a subset of the world's \n";
|
||||
cout << "airports may of course be used.\n";
|
||||
cout << "\n\n";
|
||||
cout << "It is necessary to generate the elevation data for the area of interest PRIOR TO GENERATING THE AIRPORTS. \n";
|
||||
cout << "Failure to do this will result in airports being generated with an elevation of zero. \n";
|
||||
cout << "The following subdirectories of the work-dir will be searched for elevation files:\n\n";
|
||||
static void help(int argc, char** argv, const string_list& elev_src)
|
||||
{
|
||||
std::cout << "genapts generates airports for use in generating scenery for the FlightGear flight simulator. \n";
|
||||
std::cout << "Airport, runway, and taxiway vector data and attributes are input, and generated 3D airports \n";
|
||||
std::cout << "are output for further processing by the TerraGear scenery creation tools. \n";
|
||||
std::cout << "\n\n";
|
||||
std::cout << "The standard input file is apt.dat.gz which is found in $FG_ROOT/Airports. \n";
|
||||
std::cout << "This file is periodically generated by Robin Peel, who maintains \n";
|
||||
std::cout << "the airport database for both the X-Plane and FlightGear simulators. \n";
|
||||
std::cout << "The format of this file is documented at \n";
|
||||
std::cout << "http://data.x-plane.com/designers.html#Formats \n";
|
||||
std::cout << "Any other input file corresponding to this format may be used as input to genapts. \n";
|
||||
std::cout << "Input files may be gzipped or left as plain text as required. \n";
|
||||
std::cout << "\n\n";
|
||||
std::cout << "Processing all the world's airports takes a *long* time. To cut down processing time \n";
|
||||
std::cout << "when only some airports are required, you may refine the input selection either by airport \n";
|
||||
std::cout << "or by area. By airport, either one airport can be specified using --airport=abcd, where abcd is \n";
|
||||
std::cout << "a valid airport code eg. --airport-id=KORD, or a starting airport can be specified using --start-id=abcd \n";
|
||||
std::cout << "where once again abcd is a valid airport code. In this case, all airports in the file subsequent to the \n";
|
||||
std::cout << "start-id are done. This is convenient when re-starting after a previous error. \n";
|
||||
std::cout << "\nAn input area may be specified by lat and lon extent using min and max lat and lon. \n";
|
||||
std::cout << "\nAn input file containing only a subset of the world's \n";
|
||||
std::cout << "airports may of course be used.\n";
|
||||
std::cout << "\n\n";
|
||||
std::cout << "It is necessary to generate the elevation data for the area of interest PRIOR TO GENERATING THE AIRPORTS. \n";
|
||||
std::cout << "Failure to do this will result in airports being generated with an elevation of zero. \n";
|
||||
std::cout << "The following subdirectories of the work-dir will be searched for elevation files:\n\n";
|
||||
|
||||
string_list::const_iterator elev_src_it;
|
||||
for (elev_src_it = elev_src.begin(); elev_src_it != elev_src.end(); ++elev_src_it) {
|
||||
cout << *elev_src_it << "\n";
|
||||
std::cout << *elev_src_it << "\n";
|
||||
}
|
||||
cout << "\n";
|
||||
std::cout << "\n";
|
||||
usage(argc, argv);
|
||||
}
|
||||
|
||||
void
|
||||
setLoggingPriority (const string & priority )
|
||||
void setLoggingPriority(const std::string& priority)
|
||||
{
|
||||
SG_LOG(SG_ALL, SG_ALERT, "setting log level to " << priority);
|
||||
if (priority == "bulk") {
|
||||
|
@ -136,10 +136,10 @@ int main(int argc, char **argv)
|
|||
setup_default_elevation_sources(elev_src);
|
||||
|
||||
std::string debug_dir = ".";
|
||||
vector<std::string> debug_runway_defs;
|
||||
vector<std::string> debug_pavement_defs;
|
||||
vector<std::string> debug_taxiway_defs;
|
||||
vector<std::string> debug_feature_defs;
|
||||
std::vector<std::string> debug_runway_defs;
|
||||
std::vector<std::string> debug_pavement_defs;
|
||||
std::vector<std::string> debug_taxiway_defs;
|
||||
std::vector<std::string> debug_feature_defs;
|
||||
|
||||
// Set Normal logging
|
||||
sglog().setLogLevels(SG_GENERAL, SG_INFO);
|
||||
|
@ -153,105 +153,57 @@ int main(int argc, char **argv)
|
|||
int num_threads = 1;
|
||||
|
||||
int arg_pos;
|
||||
for (arg_pos = 1; arg_pos < argc; arg_pos++)
|
||||
{
|
||||
string arg = argv[arg_pos];
|
||||
if (arg.compare(0, 12, "--log-level=") == 0)
|
||||
{
|
||||
for (arg_pos = 1; arg_pos < argc; arg_pos++) {
|
||||
std::string arg = argv[arg_pos];
|
||||
if (arg.compare(0, 12, "--log-level=") == 0) {
|
||||
setLoggingPriority(arg.substr(12));
|
||||
}
|
||||
else if (arg.compare(0, 7, "--work=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 7, "--work=") == 0) {
|
||||
work_dir = arg.substr(7);
|
||||
}
|
||||
else if (arg.compare(0, 8, "--input=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 8, "--input=") == 0) {
|
||||
input_file = arg.substr(8);
|
||||
}
|
||||
else if (arg.compare(0, 11, "--start-id=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 11, "--start-id=") == 0) {
|
||||
start_id = arg.substr(11);
|
||||
}
|
||||
else if (arg.compare(0, 8, "--nudge=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 8, "--nudge=") == 0) {
|
||||
nudge = atoi(arg.substr(8).c_str());
|
||||
}
|
||||
else if (arg.compare(0, 7, "--snap=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 7, "--snap=") == 0) {
|
||||
gSnap = atof(arg.substr(7).c_str());
|
||||
}
|
||||
else if (arg.compare(0, 10, "--min-lon=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 10, "--min-lon=") == 0) {
|
||||
min.setLongitudeDeg(atof(arg.substr(10).c_str()));
|
||||
}
|
||||
else if (arg.compare(0, 10, "--max-lon=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 10, "--max-lon=") == 0) {
|
||||
max.setLongitudeDeg(atof(arg.substr(10).c_str()));
|
||||
}
|
||||
else if (arg.compare(0, 10, "--min-lat=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 10, "--min-lat=") == 0) {
|
||||
min.setLatitudeDeg(atof(arg.substr(10).c_str()));
|
||||
}
|
||||
else if (arg.compare(0, 10, "--max-lat=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 10, "--max-lat=") == 0) {
|
||||
max.setLatitudeDeg(atof(arg.substr(10).c_str()));
|
||||
}
|
||||
else if (arg.compare(0, 10, "--airport=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 10, "--airport=") == 0) {
|
||||
airport_id = simgear::strutils::uppercase(arg.substr(10).c_str());
|
||||
}
|
||||
else if (arg.compare(0, 16, "--clear-dem-path") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 16, "--clear-dem-path") == 0) {
|
||||
elev_src.clear();
|
||||
}
|
||||
else if (arg.compare(0, 11, "--dem-path=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 11, "--dem-path=") == 0) {
|
||||
elev_src.push_back(arg.substr(11));
|
||||
}
|
||||
else if (arg.compare(0, 9, "--verbose") == 0 || arg.compare(0, 2, "-v") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 9, "--verbose") == 0 || arg.compare(0, 2, "-v") == 0) {
|
||||
sglog().setLogLevels(SG_GENERAL, SG_BULK);
|
||||
}
|
||||
else if (arg.compare(0, 12, "--max-slope=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 12, "--max-slope=") == 0) {
|
||||
slope_max = atof(arg.substr(12).c_str());
|
||||
}
|
||||
else if (arg.compare(0, 10, "--threads=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 10, "--threads=") == 0) {
|
||||
num_threads = atoi(arg.substr(10).c_str());
|
||||
}
|
||||
else if (arg.compare(0, 9, "--threads") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 9, "--threads") == 0) {
|
||||
num_threads = boost::thread::hardware_concurrency();
|
||||
}
|
||||
else if (arg.compare(0, 12, "--debug-dir=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 12, "--debug-dir=") == 0) {
|
||||
debug_dir = arg.substr(12);
|
||||
}
|
||||
else if (arg.compare(0, 16, "--debug-runways=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 16, "--debug-runways=") == 0) {
|
||||
debug_runway_defs.push_back(arg.substr(16));
|
||||
}
|
||||
else if (arg.compare(0, 18, "--debug-pavements=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 18, "--debug-pavements=") == 0) {
|
||||
debug_pavement_defs.push_back(arg.substr(18));
|
||||
}
|
||||
else if (arg.compare(0, 17, "--debug-taxiways=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 17, "--debug-taxiways=") == 0) {
|
||||
TG_LOG(SG_GENERAL, SG_INFO, "add debug taxiway " << arg.substr(17));
|
||||
debug_taxiway_defs.push_back(arg.substr(17));
|
||||
}
|
||||
else if (arg.compare(0, 17, "--debug-features=") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 17, "--debug-features=") == 0) {
|
||||
debug_feature_defs.push_back(arg.substr(17));
|
||||
}
|
||||
else if (arg.compare(0, 6, "--help") == 0 || arg.compare(0, 2, "-h") == 0)
|
||||
{
|
||||
} else if (arg.compare(0, 6, "--help") == 0 || arg.compare(0, 2, "-h") == 0) {
|
||||
help(argc, argv, elev_src);
|
||||
exit(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
usage(argc, argv);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@ -272,8 +224,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
TG_LOG(SG_GENERAL, SG_INFO, "Nudge = " << nudge);
|
||||
|
||||
if (!max.isValid() || !min.isValid())
|
||||
{
|
||||
if (!max.isValid() || !min.isValid()) {
|
||||
TG_LOG(SG_GENERAL, SG_ALERT, "Bad longitude or latitude");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -288,22 +239,19 @@ int main(int argc, char **argv)
|
|||
tgRectangle boundingBox(min, max);
|
||||
boundingBox.sanify();
|
||||
|
||||
if ( work_dir == "" )
|
||||
{
|
||||
if (work_dir == "") {
|
||||
TG_LOG(SG_GENERAL, SG_ALERT, "Error: no work directory specified.");
|
||||
usage(argc, argv);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if ( input_file == "" )
|
||||
{
|
||||
if (input_file == "") {
|
||||
TG_LOG(SG_GENERAL, SG_ALERT, "Error: no input file.");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
sg_gzifstream in(input_file);
|
||||
if ( !in.is_open() )
|
||||
{
|
||||
if (!in.is_open()) {
|
||||
TG_LOG(SG_GENERAL, SG_ALERT, "Cannot open file: " << input_file);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@ -326,8 +274,7 @@ int main(int argc, char **argv)
|
|||
scheduler->set_debug(debug_dir, debug_runway_defs, debug_pavement_defs, debug_taxiway_defs, debug_feature_defs);
|
||||
|
||||
// just one airport
|
||||
if ( airport_id != "" )
|
||||
{
|
||||
if (airport_id != "") {
|
||||
// just find and add the one airport
|
||||
scheduler->AddAirport(airport_id);
|
||||
|
||||
|
@ -337,25 +284,20 @@ int main(int argc, char **argv)
|
|||
scheduler->Schedule(num_threads, summary_file);
|
||||
}
|
||||
|
||||
else if ( start_id != "" )
|
||||
{
|
||||
else if (start_id != "") {
|
||||
TG_LOG(SG_GENERAL, SG_INFO, "move forward to " << start_id);
|
||||
|
||||
// scroll forward in datafile
|
||||
long position = scheduler->FindAirport(start_id);
|
||||
|
||||
// add remaining airports within boundary
|
||||
if ( scheduler->AddAirports( position, &boundingBox ) )
|
||||
{
|
||||
if (scheduler->AddAirports(position, &boundingBox)) {
|
||||
// parse all the airports that were found
|
||||
scheduler->Schedule(num_threads, summary_file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// find all airports within given boundary
|
||||
if ( scheduler->AddAirports( 0, &boundingBox ) )
|
||||
{
|
||||
if (scheduler->AddAirports(0, &boundingBox)) {
|
||||
// and parse them
|
||||
scheduler->Schedule(num_threads, summary_file);
|
||||
}
|
||||
|
@ -365,7 +307,9 @@ int main(int argc, char **argv)
|
|||
|
||||
auto finish_time = std::chrono::high_resolution_clock::now();
|
||||
std::chrono::duration<double> elapsed = finish_time - start_time;
|
||||
std::cout << std::endl << "Elapsed time: " << elapsed.count() << " seconds" << std::endl << std::endl;
|
||||
std::cout << std::endl
|
||||
<< "Elapsed time: " << elapsed.count() << " seconds" << std::endl
|
||||
<< std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue