Remove a duplicate function and fix a segfault when using the
--airport option.
This commit is contained in:
parent
595a190dd3
commit
fcdeaae2fd
3 changed files with 4 additions and 37 deletions
|
@ -336,7 +336,7 @@ int main(int argc, char **argv)
|
||||||
else if ( start_id != "" )
|
else if ( start_id != "" )
|
||||||
{
|
{
|
||||||
// scroll forward in datafile
|
// scroll forward in datafile
|
||||||
parser->FindAirport( start_id );
|
parser->AddAirport( start_id );
|
||||||
|
|
||||||
// add remaining airports within boundary
|
// add remaining airports within boundary
|
||||||
parser->AddAirports( min_lat, min_lon, max_lat, max_lon );
|
parser->AddAirports( min_lat, min_lon, max_lat, max_lon );
|
||||||
|
|
|
@ -93,38 +93,7 @@ void Parser::AddAirport( string icao )
|
||||||
{
|
{
|
||||||
SG_LOG( SG_GENERAL, SG_DEBUG, "Found airport " << line << " at " << cur_pos );
|
SG_LOG( SG_GENERAL, SG_DEBUG, "Found airport " << line << " at " << cur_pos );
|
||||||
parse_positions.push_back( cur_pos );
|
parse_positions.push_back( cur_pos );
|
||||||
found = true;
|
airport_icaos.push_back( icao );
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parser::FindAirport( string icao )
|
|
||||||
{
|
|
||||||
char line[2048];
|
|
||||||
long cur_pos;
|
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
ifstream in( filename.c_str() );
|
|
||||||
if ( !in.is_open() )
|
|
||||||
{
|
|
||||||
SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << filename );
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SG_LOG( SG_GENERAL, SG_DEBUG, "Finding airport " << icao );
|
|
||||||
while ( !in.eof() && !found )
|
|
||||||
{
|
|
||||||
// remember the position of this line
|
|
||||||
cur_pos = in.tellg();
|
|
||||||
|
|
||||||
// get a line
|
|
||||||
in.getline(line, 2048);
|
|
||||||
|
|
||||||
// this is and airport definition - remember it
|
|
||||||
if ( IsAirportDefinition( line, icao ) )
|
|
||||||
{
|
|
||||||
SG_LOG( SG_GENERAL, SG_DEBUG, "Found airport " << line << " at " << cur_pos );
|
|
||||||
parse_positions.push_back( cur_pos );
|
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -320,7 +289,7 @@ void Parser::Parse()
|
||||||
in.clear();
|
in.clear();
|
||||||
|
|
||||||
SG_LOG( SG_GENERAL, SG_ALERT, "\n*******************************************************************" );
|
SG_LOG( SG_GENERAL, SG_ALERT, "\n*******************************************************************" );
|
||||||
SG_LOG( SG_GENERAL, SG_ALERT, "Parsing airport " << airport_icaos[i] << " at " << parse_positions[i] );
|
SG_LOG( SG_GENERAL, SG_ALERT, "Parsing airport " << airport_icaos[i] << " at position " << parse_positions[i] );
|
||||||
in.seekg(parse_positions[i], ios::beg);
|
in.seekg(parse_positions[i], ios::beg);
|
||||||
|
|
||||||
gettimeofday(&parse_start, NULL);
|
gettimeofday(&parse_start, NULL);
|
||||||
|
|
|
@ -85,8 +85,6 @@ public:
|
||||||
cur_state = STATE_NONE;
|
cur_state = STATE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// int Parse( char* icao );
|
|
||||||
void FindAirport( string icao );
|
|
||||||
void AddAirport( string icao );
|
void AddAirport( string icao );
|
||||||
void AddAirports( float min_lat, float min_lon, float max_lat, float max_lon );
|
void AddAirports( float min_lat, float min_lon, float max_lat, float max_lon );
|
||||||
void Parse( void );
|
void Parse( void );
|
||||||
|
|
Loading…
Reference in a new issue