1
0
Fork 0

[Genapts] Reduce technical debt.

This commit is contained in:
Scott Giese 2019-01-29 14:02:18 -06:00
parent 279868b782
commit 911f7f9d27
11 changed files with 352 additions and 394 deletions

View file

@ -56,18 +56,18 @@ public:
private:
struct TGRunway {
// data for helipad
char designator[16];
double lat;
double lon;
double heading;
double length;
double width;
int surface;
int marking;
int shoulder;
double smoothness;
int edge_lights;
// data for helipad
char designator[16];
double lat;
double lon;
double heading;
double length;
double width;
int surface;
int marking;
int shoulder;
double smoothness;
int edge_lights;
};
TGRunway heli;

View file

@ -370,10 +370,8 @@ int LinearFeature::Finish( bool closed, unsigned int idx )
double heading;
double dist;
double az2;
double last_end_v;
double width = 0;
std::string material;
double cur_light_dist = 0.0f;
double light_delta = 0;
bool markStarted;
@ -386,7 +384,7 @@ int LinearFeature::Finish( bool closed, unsigned int idx )
for (unsigned int i=0; i<marks.size(); i++)
{
markStarted = false;
last_end_v = 0.0f;
double last_end_v = 0.0;
// which material for this mark?
switch( marks[i]->type )
@ -568,7 +566,7 @@ int LinearFeature::Finish( bool closed, unsigned int idx )
for (unsigned int i=0; i<lights.size(); i++)
{
markStarted = false;
cur_light_dist = 0.0f;
double cur_light_dist = 0.0;
int light_direction = lights[i]->LightDirection();
bool alternate = false;
@ -637,7 +635,7 @@ int LinearFeature::Finish( bool closed, unsigned int idx )
while (cur_light_dist < dist)
{
if (cur_light_dist == 0.0f)
if (cur_light_dist == 0.0)
{
tmp = prev_outer;
}

View file

@ -41,8 +41,8 @@ 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>] "
<< "[ --airport=abcd ] [--max-slope=<decimal>] [--tile=<tile>] [--threads] [--threads=x]"
<< "[--chunk=<chunk>] [--clear-dem-path] [--dem-path=<path>] [--verbose] [--help] [--log-level=bulk|info|debug|warn|alert]");
<< "[ --airport=abcd ] [--max-slope=<decimal>] [--threads] [--threads=x]"
<< "[--clear-dem-path] [--dem-path=<path>] [--verbose] [--help] [--log-level=bulk|info|debug|warn|alert]");
}
@ -82,8 +82,6 @@ static void help( int argc, char **argv, const string_list& elev_src ) {
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 << "Alternatively, you may specify a chunk (10 x 10 degrees) or tile (1 x 1 degree) using a string \n";
//cout << "such as eg. w080n40, e000s27. \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";
@ -92,7 +90,7 @@ static void help( int argc, char **argv, const string_list& elev_src ) {
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++) {
for (elev_src_it = elev_src.begin(); elev_src_it != elev_src.end(); ++elev_src_it) {
cout << *elev_src_it << "\n";
}
cout << "\n";
@ -159,110 +157,96 @@ int main(int argc, char **argv)
for (arg_pos = 1; arg_pos < argc; arg_pos++)
{
string arg = argv[arg_pos];
if ( arg.find("--log-level=") == 0 )
if (arg.compare(0, 12, "--log-level=") == 0)
{
setLoggingPriority(arg.substr(12));
}
else if ( arg.find("--work=") == 0 )
else if (arg.compare(0, 7, "--work=") == 0)
{
work_dir = arg.substr(7);
}
else if ( arg.find("--input=") == 0 )
else if (arg.compare(0, 8, "--input=") == 0)
{
input_file = arg.substr(8);
}
else if ( arg.find("--start-id=") == 0 )
else if (arg.compare(0, 11, "--start-id=") == 0)
{
start_id = arg.substr(11);
}
else if ( arg.find("--nudge=") == 0 )
else if (arg.compare(0, 8, "--nudge=") == 0)
{
nudge = atoi( arg.substr(8).c_str() );
}
else if ( arg.find("--snap=") == 0 )
else if (arg.compare(0, 7, "--snap=") == 0)
{
gSnap = atof( arg.substr(7).c_str() );
}
else if ( arg.find("--min-lon=") == 0 )
else if (arg.compare(0, 10, "--min-lon=") == 0)
{
min.setLongitudeDeg(atof( arg.substr(10).c_str() ));
}
else if ( arg.find("--max-lon=") == 0 )
else if (arg.compare(0, 10, "--max-lon=") == 0)
{
max.setLongitudeDeg(atof( arg.substr(10).c_str() ));
}
else if ( arg.find("--min-lat=") == 0 )
else if (arg.compare(0, 10, "--min-lat=") == 0)
{
min.setLatitudeDeg(atof( arg.substr(10).c_str() ));
}
else if ( arg.find("--max-lat=") == 0 )
else if (arg.compare(0, 10, "--max-lat=") == 0)
{
max.setLatitudeDeg(atof( arg.substr(10).c_str() ));
}
#if 0 // relly? - do we need this?
else if ( arg.find("--chunk=") == 0 )
{
tg::Rectangle rectangle = tg::parseChunk(arg.substr(8).c_str(), 10.0);
min = rectangle.getMin();
max = rectangle.getMax();
}
else if ( arg.find("--tile=") == 0 )
{
tg::Rectangle rectangle = tg::parseTile(arg.substr(7).c_str());
min = rectangle.getMin();
max = rectangle.getMax();
}
#endif
else if ( arg.find("--airport=") == 0 )
else if (arg.compare(0, 10, "--airport=") == 0)
{
airport_id = simgear::strutils::uppercase( arg.substr(10).c_str() );
}
else if ( arg == "--clear-dem-path" )
else if (arg.compare(0, 16, "--clear-dem-path") == 0)
{
elev_src.clear();
}
else if ( arg.find("--dem-path=") == 0 )
else if (arg.compare(0, 11, "--dem-path=") == 0)
{
elev_src.push_back( arg.substr(11) );
}
else if ( (arg.find("--verbose") == 0) || (arg.find("-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.find("--max-slope=") == 0) )
else if (arg.compare(0, 12, "--max-slope=") == 0)
{
slope_max = atof( arg.substr(12).c_str() );
}
else if ( (arg.find("--threads=") == 0) )
else if (arg.compare(0, 10, "--threads=") == 0)
{
num_threads = atoi( arg.substr(10).c_str() );
}
else if ( (arg.find("--threads") == 0) )
else if (arg.compare(0, 9, "--threads") == 0)
{
num_threads = boost::thread::hardware_concurrency();
}
else if (arg.find("--debug-dir=") == 0)
else if (arg.compare(0, 12, "--debug-dir=") == 0)
{
debug_dir = arg.substr(12);
}
else if (arg.find("--debug-runways=") == 0)
else if (arg.compare(0, 16, "--debug-runways=") == 0)
{
debug_runway_defs.push_back( arg.substr(16) );
}
else if (arg.find("--debug-pavements=") == 0)
else if (arg.compare(0, 18, "--debug-pavements=") == 0)
{
debug_pavement_defs.push_back( arg.substr(18) );
}
else if (arg.find("--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.find("--debug-features=") == 0)
else if (arg.compare(0, 17, "--debug-features=") == 0)
{
debug_feature_defs.push_back( arg.substr(17) );
}
else if ( (arg.find("--help") == 0) || (arg.find("-h") == 0) )
else if (arg.compare(0, 6, "--help") == 0 || arg.compare(0, 2, "-h") == 0)
{
help( argc, argv, elev_src );
exit(-1);

View file

@ -101,7 +101,7 @@ void write_index_object_sign( const string &base, const SGBucket &b,
exit(-1);
}
fprintf( fp, "OBJECT_SIGN %s %.6f %.6f %.1f %.2f %u\n", sign.c_str(),
fprintf( fp, "OBJECT_SIGN %s %.6f %.6f %.1f %.2f %d\n", sign.c_str(),
p.getLongitudeDeg(), p.getLatitudeDeg(), p.getElevationM(), heading, size );
fclose( fp );
}

View file

@ -8,17 +8,15 @@
bool Parser::GetAirportDefinition( char* line, std::string& icao )
{
char* tok;
int code;
bool match = false;
bool match = false;
// Get the number code
tok = strtok(line, " \t\r\n");
char* tok = strtok(line, " \t\r\n");
if (tok)
{
line += strlen(tok)+1;
code = atoi(tok);
int code = atoi(tok);
switch(code)
{
@ -40,7 +38,7 @@ bool Parser::GetAirportDefinition( char* line, std::string& icao )
return match;
}
void Parser::set_debug( std::string path, std::vector<std::string> runway_defs,
void Parser::set_debug( const std::string& path, std::vector<std::string> runway_defs,
std::vector<std::string> pavement_defs,
std::vector<std::string> taxiway_defs,
std::vector<std::string> feature_defs )
@ -416,7 +414,7 @@ std::shared_ptr<ClosedPoly> Parser::ParsePavement( char* line )
char *d = nullptr;
int numParams;
numParams = sscanf(line, "%d %f %f %s", &st, &s, &th, desc);
numParams = sscanf(line, "%d %f %f %255s", &st, &s, &th, desc);
if (numParams == 4)
{
@ -440,7 +438,7 @@ std::shared_ptr<ClosedPoly> Parser::ParseBoundary( char* line )
char *d = nullptr;
int numParams;
numParams = sscanf(line, "%s", desc);
numParams = sscanf(line, "%255s", desc);
if (numParams == 1)
{
@ -485,164 +483,196 @@ int Parser::SetState( int state )
// TODO: This should be a loop here, and main should just pass the file name and airport code...
int Parser::ParseLine(char* line)
{
char* tok;
int code;
std::shared_ptr<BezNode> cur_node = nullptr;
if (*line != '#')
if (*line == '#')
return cur_state;
// Get the number code
char* tok = strtok(line, " \t\r\n");
if (tok)
{
// Get the number code
tok = strtok(line, " \t\r\n");
line += strlen(tok)+1;
int code = atoi(tok);
if (tok)
switch(code)
{
line += strlen(tok)+1;
code = atoi(tok);
case LAND_AIRPORT_CODE:
case SEA_AIRPORT_CODE:
if (cur_state == STATE_NONE)
{
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing land airport: " << line);
cur_airport = std::make_shared<Airport>( code, line );
}
else
{
SetState( STATE_DONE );
}
break;
case HELIPORT_CODE:
if (cur_state == STATE_NONE)
{
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing heliport: " << line);
cur_airport = std::make_shared<Airport>( code, line );
}
else
{
SetState( STATE_DONE );
}
break;
switch(code)
{
case LAND_AIRPORT_CODE:
case SEA_AIRPORT_CODE:
if (cur_state == STATE_NONE)
{
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing land airport: " << line);
cur_airport = std::make_shared<Airport>( code, line );
}
else
{
SetState( STATE_DONE );
}
break;
case HELIPORT_CODE:
if (cur_state == STATE_NONE)
{
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing heliport: " << line);
cur_airport = std::make_shared<Airport>( code, line );
}
else
{
SetState( STATE_DONE );
}
break;
case LAND_RUNWAY_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing runway: " << line);
cur_runway = std::make_shared<Runway>(line);
if (cur_airport)
{
cur_airport->AddRunway( cur_runway );
}
break;
case WATER_RUNWAY_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing water runway: " << line);
cur_waterrunway = std::make_shared<WaterRunway>(line);
if (cur_airport)
{
cur_airport->AddWaterRunway( cur_waterrunway );
}
break;
case HELIPAD_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing helipad: " << line);
cur_helipad = std::make_shared<Helipad>(line);
if (cur_airport)
{
cur_airport->AddHelipad( cur_helipad );
}
break;
case TAXIWAY_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing taxiway: " << line);
cur_taxiway = std::make_shared<Taxiway>(line);
if (cur_airport)
{
cur_airport->AddTaxiway( cur_taxiway );
}
break;
case PAVEMENT_CODE:
SetState( STATE_PARSE_PAVEMENT );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing pavement: " << line);
cur_pavement = ParsePavement( line );
break;
case LINEAR_FEATURE_CODE:
SetState( STATE_PARSE_FEATURE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Linear Feature: " << line);
cur_feat = ParseFeature( line );
break;
case BOUNDARY_CODE:
SetState( STATE_PARSE_BOUNDARY );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing Boundary: " << line);
cur_boundary = ParseBoundary( line );
break;
case NODE_CODE:
case BEZIER_NODE_CODE:
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing node: " << line);
cur_node = ParseNode( code, line, prev_node );
if ( prev_node && (cur_node != prev_node) )
{
// prev node is done - process it
if ( cur_state == STATE_PARSE_PAVEMENT )
{
cur_pavement->AddNode( prev_node );
}
else if ( cur_state == STATE_PARSE_FEATURE )
{
cur_feat->AddNode( prev_node );
}
else if ( cur_state == STATE_PARSE_BOUNDARY )
{
cur_boundary->AddNode( prev_node );
}
}
case LAND_RUNWAY_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing runway: " << line);
cur_runway = std::make_shared<Runway>(line);
if (cur_airport)
{
cur_airport->AddRunway( cur_runway );
}
break;
prev_node = cur_node;
break;
case CLOSE_NODE_CODE:
case CLOSE_BEZIER_NODE_CODE:
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing close loop node: " << line);
cur_node = ParseNode( code, line, prev_node );
case WATER_RUNWAY_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing water runway: " << line);
cur_waterrunway = std::make_shared<WaterRunway>(line);
if (cur_airport)
{
cur_airport->AddWaterRunway( cur_waterrunway );
}
break;
case HELIPAD_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing helipad: " << line);
cur_helipad = std::make_shared<Helipad>(line);
if (cur_airport)
{
cur_airport->AddHelipad( cur_helipad );
}
break;
if ( cur_state == STATE_PARSE_PAVEMENT && prev_node )
case TAXIWAY_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing taxiway: " << line);
cur_taxiway = std::make_shared<Taxiway>(line);
if (cur_airport)
{
cur_airport->AddTaxiway( cur_taxiway );
}
break;
case PAVEMENT_CODE:
SetState( STATE_PARSE_PAVEMENT );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing pavement: " << line);
cur_pavement = ParsePavement( line );
break;
case LINEAR_FEATURE_CODE:
SetState( STATE_PARSE_FEATURE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Linear Feature: " << line);
cur_feat = ParseFeature( line );
break;
case BOUNDARY_CODE:
SetState( STATE_PARSE_BOUNDARY );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing Boundary: " << line);
cur_boundary = ParseBoundary( line );
break;
case NODE_CODE:
case BEZIER_NODE_CODE:
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing node: " << line);
cur_node = ParseNode( code, line, prev_node );
if ( prev_node && (cur_node != prev_node) )
{
// prev node is done - process it
if ( cur_state == STATE_PARSE_PAVEMENT )
{
if (cur_node != prev_node)
{
cur_pavement->AddNode( prev_node );
cur_pavement->AddNode( cur_node );
}
else
{
cur_pavement->AddNode( cur_node );
}
cur_pavement->CloseCurContour();
}
else if ( cur_state == STATE_PARSE_BOUNDARY )
{
if (cur_node != prev_node)
{
cur_boundary->AddNode( prev_node );
cur_boundary->AddNode( cur_node );
}
else
{
cur_boundary->AddNode( cur_node );
}
cur_boundary->CloseCurContour();
cur_pavement->AddNode( prev_node );
}
else if ( cur_state == STATE_PARSE_FEATURE )
{
cur_feat->AddNode( prev_node );
}
else if ( cur_state == STATE_PARSE_BOUNDARY )
{
cur_boundary->AddNode( prev_node );
}
}
prev_node = cur_node;
break;
case CLOSE_NODE_CODE:
case CLOSE_BEZIER_NODE_CODE:
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing close loop node: " << line);
cur_node = ParseNode( code, line, prev_node );
if ( cur_state == STATE_PARSE_PAVEMENT && prev_node )
{
if (cur_node != prev_node)
{
cur_pavement->AddNode( prev_node );
cur_pavement->AddNode( cur_node );
}
else
{
cur_pavement->AddNode( cur_node );
}
cur_pavement->CloseCurContour();
}
else if ( cur_state == STATE_PARSE_BOUNDARY )
{
if (cur_node != prev_node)
{
cur_boundary->AddNode( prev_node );
cur_boundary->AddNode( cur_node );
}
else
{
cur_boundary->AddNode( cur_node );
}
cur_boundary->CloseCurContour();
}
else if ( cur_state == STATE_PARSE_FEATURE )
{
if (cur_node != prev_node)
{
cur_feat->AddNode( prev_node );
cur_feat->AddNode( cur_node );
}
else
{
cur_feat->AddNode( cur_node );
}
if (cur_airport)
{
cur_feat->Finish( true, cur_airport->NumFeatures() );
cur_airport->AddFeature( cur_feat );
}
cur_feat = nullptr;
SetState( STATE_PARSE_SIMPLE );
}
prev_node = nullptr;
cur_node = nullptr;
break;
case TERM_NODE_CODE:
case TERM_BEZIER_NODE_CODE:
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing termination node: " << line);
if ( cur_state == STATE_PARSE_FEATURE )
{
// we have some bad data - termination nodes right after the
// linear feature declaration - can't do anything with a
// single point - detect and delete.
if ( prev_node )
{
cur_node = ParseNode( code, line, prev_node );
if (cur_node != prev_node)
{
cur_feat->AddNode( prev_node );
@ -654,121 +684,86 @@ int Parser::ParseLine(char* line)
}
if (cur_airport)
{
cur_feat->Finish( true, cur_airport->NumFeatures() );
cur_feat->Finish( false, cur_airport->NumFeatures() );
cur_airport->AddFeature( cur_feat );
}
cur_feat = nullptr;
SetState( STATE_PARSE_SIMPLE );
}
prev_node = nullptr;
cur_node = nullptr;
break;
case TERM_NODE_CODE:
case TERM_BEZIER_NODE_CODE:
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing termination node: " << line);
if ( cur_state == STATE_PARSE_FEATURE )
else
{
// we have some bad data - termination nodes right after the
// linear feature declaration - can't do anything with a
// single point - detect and delete.
if ( prev_node )
{
cur_node = ParseNode( code, line, prev_node );
if (cur_node != prev_node)
{
cur_feat->AddNode( prev_node );
cur_feat->AddNode( cur_node );
}
else
{
cur_feat->AddNode( cur_node );
}
if (cur_airport)
{
cur_feat->Finish( false, cur_airport->NumFeatures() );
cur_airport->AddFeature( cur_feat );
}
}
else
{
TG_LOG(SG_GENERAL, SG_ALERT, "Parsing termination node with no previous nodes!!!" );
}
cur_feat = nullptr;
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_ALERT, "Parsing termination node with no previous nodes!!!" );
}
prev_node = nullptr;
cur_node = nullptr;
break;
case AIRPORT_VIEWPOINT_CODE:
cur_feat = nullptr;
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing viewpoint: " << line);
break;
case AIRPLANE_STARTUP_LOCATION_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing airplane startup location: " << line);
break;
case LIGHT_BEACON_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing light beacon: " << line);
cur_beacon = std::make_shared<Beacon>(line);
cur_airport->AddBeacon( cur_beacon );
break;
case WINDSOCK_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing windsock: " << line);
cur_windsock = std::make_shared<Windsock>(line);
cur_airport->AddWindsock( cur_windsock );
break;
case TAXIWAY_SIGN:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing taxiway sign: " << line);
cur_sign = std::make_shared<Sign>(line);
cur_airport->AddSign( cur_sign );
break;
case LIGHTING_OBJECT:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing lighting object: " << line);
cur_object = std::make_shared<LightingObj>(line);
cur_airport->AddObj( cur_object );
break;
case COMM_FREQ1_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing commfreq 1: " << line);
break;
case COMM_FREQ2_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing commfreq 2: " << line);
break;
case COMM_FREQ3_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing commfreq 3: " << line);
break;
case COMM_FREQ4_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing commfreq 4: " << line);
break;
case COMM_FREQ5_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing commfreq 5: " << line);
break;
case COMM_FREQ6_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing commfreq 6: " << line);
break;
case COMM_FREQ7_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing commfreq 7: " << line);
break;
case END_OF_FILE :
TG_LOG(SG_GENERAL, SG_DEBUG, "Reached end of file");
SetState( STATE_DONE );
break;
}
}
prev_node = nullptr;
cur_node = nullptr;
break;
case AIRPORT_VIEWPOINT_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing viewpoint: " << line);
break;
case AIRPLANE_STARTUP_LOCATION_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing airplane startup location: " << line);
break;
case LIGHT_BEACON_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing light beacon: " << line);
cur_beacon = std::make_shared<Beacon>(line);
cur_airport->AddBeacon( cur_beacon );
break;
case WINDSOCK_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing windsock: " << line);
cur_windsock = std::make_shared<Windsock>(line);
cur_airport->AddWindsock( cur_windsock );
break;
case TAXIWAY_SIGN:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing taxiway sign: " << line);
cur_sign = std::make_shared<Sign>(line);
cur_airport->AddSign( cur_sign );
break;
case LIGHTING_OBJECT:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing lighting object: " << line);
cur_object = std::make_shared<LightingObj>(line);
cur_airport->AddObj( cur_object );
break;
case COMM_FREQ1_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing commfreq 1: " << line);
break;
case COMM_FREQ2_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing commfreq 2: " << line);
break;
case COMM_FREQ3_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing commfreq 3: " << line);
break;
case COMM_FREQ4_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing commfreq 4: " << line);
break;
case COMM_FREQ5_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing commfreq 5: " << line);
break;
case COMM_FREQ6_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing commfreq 6: " << line);
break;
case COMM_FREQ7_CODE:
SetState( STATE_PARSE_SIMPLE );
TG_LOG(SG_GENERAL, SG_DEBUG, "Parsing commfreq 7: " << line);
break;
case END_OF_FILE :
TG_LOG(SG_GENERAL, SG_DEBUG, "Reached end of file");
SetState( STATE_DONE );
break;
}
}

View file

@ -89,30 +89,29 @@
class Parser : public SGThread
{
public:
Parser(const std::string& datafile, const std::string& root, const string_list& elev_src )
Parser(const std::string& datafile, const std::string& root, const string_list& elev_src ) :
prev_node(nullptr),
filename(datafile),
elevation(elev_src),
work_dir(root),
cur_airport(nullptr),
cur_taxiway(nullptr),
cur_runway(nullptr),
cur_waterrunway(nullptr),
cur_helipad(nullptr),
cur_pavement(nullptr),
cur_boundary(nullptr),
cur_feat(nullptr),
cur_object(nullptr),
cur_windsock(nullptr),
cur_beacon(nullptr),
cur_sign(nullptr)
{
filename = datafile;
work_dir = root;
elevation = elev_src;
cur_airport = nullptr;
cur_runway = nullptr;
cur_waterrunway = nullptr;
cur_helipad = nullptr;
cur_taxiway = nullptr;
cur_pavement = nullptr;
cur_boundary = nullptr;
cur_feat = nullptr;
cur_object = nullptr;
cur_windsock = nullptr;
cur_beacon = nullptr;
cur_sign = nullptr;
prev_node = nullptr;
cur_state = STATE_NONE;
cur_state = STATE_NONE;
}
// Debug
void set_debug( std::string path, std::vector<std::string> runway_defs,
void set_debug( const std::string& path, std::vector<std::string> runway_defs,
std::vector<std::string> pavement_defs,
std::vector<std::string> taxiway_defs,
std::vector<std::string> feature_defs );

View file

@ -55,7 +55,7 @@ public:
private:
struct TGRunway {
// data for whole runway
// data for whole runway
int surface;
int shoulder;
int centerline_lights;

View file

@ -832,19 +832,16 @@ void Runway::gen_rwy( tgpolygon_list& rwy_polys,
start1_pct = 0.0;
end1_pct = 0.0;
double part_len = 0.0;
int count=0;
if (rwy.overrun[rwhalf] > 0.0) {
/* Generate approach end overrun */
count = (int) (rwy.overrun[rwhalf] * 2.0/ rwy.width);
if(count < 1) {
int count = (int) (rwy.overrun[rwhalf] * 2.0/ rwy.width);
if (count < 1) {
count = 1;
}
part_len = rwy.overrun[rwhalf] / (double)count;
for(int i=0; i<count; i++) {
start1_pct=end1_pct;
double part_len = rwy.overrun[rwhalf] / (double)count;
for (int i = 0; i < count; ++i) {
start1_pct = end1_pct;
end1_pct = start1_pct + ( part_len / length );
if ( debug ) { section_name = shapefile_name + "stopway"; }
gen_runway_section( runway_half,

View file

@ -22,6 +22,7 @@
#include <simgear/compiler.h>
#include <simgear/debug/logstream.hxx>
#include "runway.hxx"
#include "debug.hxx"
@ -37,9 +38,7 @@ void Runway::gen_simple_rwy( tgpolygon_list& rwy_polys,
std::string empty = "";
for ( int rwhalf=0; rwhalf<2; ++rwhalf ) {
double length = rwy.length / 2.0;
double start_pct = 0.0;
double end_pct = 0.0;
double heading = 0.0;
@ -53,7 +52,6 @@ void Runway::gen_simple_rwy( tgpolygon_list& rwy_polys,
runway_half.AddNode( 0, runway.GetNode(5) );
runway_half.AddNode( 0, runway.GetNode(2) );
}
else {
heading = rwy.heading;
@ -71,7 +69,7 @@ void Runway::gen_simple_rwy( tgpolygon_list& rwy_polys,
if ( rwy.threshold[rwhalf] > 0.0 ) {
TG_LOG( SG_GENERAL, SG_DEBUG, "Displaced threshold for RW side " << rwhalf << " is " << rwy.threshold[rwhalf] );
start_pct = end_pct;
double start_pct = end_pct;
end_pct = start_pct + ( rwy.threshold[rwhalf] / length );
Runway::gen_runway_section( runway_half,
start_pct, end_pct,

View file

@ -49,7 +49,7 @@ std::ostream& operator<< (std::ostream &out, const AirportInfo &ai)
return out; // MSVC
}
void Scheduler::set_debug( std::string path, std::vector<std::string> runway_defs,
void Scheduler::set_debug( const std::string& path, std::vector<std::string> runway_defs,
std::vector<std::string> pavement_defs,
std::vector<std::string> taxiway_defs,
std::vector<std::string> feature_defs )
@ -176,32 +176,31 @@ void Scheduler::set_debug( std::string path, std::vector<std::string> runway_def
}
}
bool Scheduler::IsAirportDefinition( char* line, std::string icao )
bool Scheduler::IsAirportDefinition( char* line, const std::string& icao )
{
char* tok;
int code;
bool match = false;
bool match = false;
// Get the number code
tok = strtok(line, " \t\r\n");
char* tok = strtok(line, " \t\r\n");
if (tok)
{
line += strlen(tok)+1;
code = atoi(tok);
int code = atoi(tok);
switch(code)
{
case LAND_AIRPORT_CODE:
case SEA_AIRPORT_CODE:
case HELIPORT_CODE:
{
Airport ap( code, line );
if ( ap.GetIcao() == icao )
{
match = true;
Airport ap( code, line );
if ( ap.GetIcao() == icao )
{
match = true;
}
}
}
break;
case LAND_RUNWAY_CODE:
@ -240,7 +239,6 @@ bool Scheduler::IsAirportDefinition( char* line, std::string icao )
void Scheduler::AddAirport( std::string icao )
{
char line[2048];
long cur_pos;
bool found = false;
AirportInfo ai;
@ -255,7 +253,7 @@ void Scheduler::AddAirport( std::string icao )
while ( !in.eof() && !found )
{
// remember the position of this line
cur_pos = in.tellg();
long cur_pos = in.tellg();
// get a line
in.getline(line, 2048);
@ -273,7 +271,7 @@ void Scheduler::AddAirport( std::string icao )
}
}
long Scheduler::FindAirport( std::string icao )
long Scheduler::FindAirport( const std::string& icao )
{
char line[2048];
long cur_pos = 0;
@ -321,11 +319,8 @@ void Scheduler::RetryAirport( AirportInfo* pai )
bool Scheduler::AddAirports( long start_pos, tgRectangle* boundingBox )
{
char line[2048];
char* def;
long cur_pos;
long cur_apt_pos = 0;
std::string cur_apt_name;
char* tok;
int code;
bool match;
bool done;
@ -351,14 +346,14 @@ bool Scheduler::AddAirports( long start_pos, tgRectangle* boundingBox )
while (!done)
{
// remember the position of this line
cur_pos = in.tellg();
long cur_pos = in.tellg();
// get a line
in.getline(line, 2048);
def = &line[0];
char* def = &line[0];
// Get the number code
tok = strtok(def, " \t\r\n");
char* tok = strtok(def, " \t\r\n");
if (tok)
{
@ -471,12 +466,11 @@ bool Scheduler::AddAirports( long start_pos, tgRectangle* boundingBox )
}
}
Scheduler::Scheduler(std::string& datafile, const std::string& root, const string_list& elev_src)
Scheduler::Scheduler(std::string& datafile, const std::string& root, const string_list& elev_src) :
filename(datafile),
elevation(elev_src),
work_dir(root)
{
filename = datafile;
work_dir = root;
elevation = elev_src;
std::ifstream in( filename.c_str() );
if ( !in.is_open() )
{
@ -487,16 +481,9 @@ Scheduler::Scheduler(std::string& datafile, const std::string& root, const strin
void Scheduler::Schedule( int num_threads, std::string& summaryfile )
{
// std::ofstream csvfile;
// open and truncate the summary file : monitor only appends
// csvfile.open( summaryfile.c_str(), std::ios_base::out | std::ios_base::trunc );
// csvfile.close();
std::vector<std::shared_ptr<Parser>> parsers;
for (int i=0; i<num_threads; i++) {
auto parser = std::make_shared<Parser>( filename, work_dir, elevation );
// parser->set_debug();
parser->start();
parsers.push_back( parser );
}

View file

@ -44,9 +44,9 @@ public:
{
}
AirportInfo( std::string id, long p, double s )
AirportInfo( const std::string& id, long p, double s ) :
icao(id)
{
icao = id;
pos = p;
snap = s;
@ -99,7 +99,7 @@ class Scheduler
public:
Scheduler(std::string& datafile, const std::string& root, const string_list& elev_src);
long FindAirport( std::string icao );
long FindAirport( const std::string& icao );
void AddAirport( std::string icao );
bool AddAirports( long start_pos, tgRectangle* boundingBox );
void RetryAirport( AirportInfo* pInfo );
@ -107,13 +107,13 @@ public:
void Schedule( int num_threads, std::string& summaryfile );
// Debug
void set_debug( std::string path, std::vector<std::string> runway_defs,
void set_debug( const std::string& path, std::vector<std::string> runway_defs,
std::vector<std::string> pavement_defs,
std::vector<std::string> taxiway_defs,
std::vector<std::string> feature_defs );
private:
bool IsAirportDefinition( char* line, std::string icao );
bool IsAirportDefinition( char* line, const std::string& icao );
std::string filename;
string_list elevation;