added support for --start-idx so I can restart after a failed airport.
This commit is contained in:
parent
a377f11dad
commit
06d0d8bdd9
6 changed files with 75 additions and 16 deletions
|
@ -1021,9 +1021,6 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
||||||
0.0 );
|
0.0 );
|
||||||
divided_base = calc_elevations( apt_surf, divided_base, 0.0 );
|
divided_base = calc_elevations( apt_surf, divided_base, 0.0 );
|
||||||
|
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "DIVIDED");
|
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, divided_base);
|
|
||||||
|
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Done with base calc_elevations()");
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Done with base calc_elevations()");
|
||||||
|
|
||||||
#if 0 // TODO : along with taxiway sign elevations
|
#if 0 // TODO : along with taxiway sign elevations
|
||||||
|
@ -1041,7 +1038,7 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
||||||
ws_nodes.push_back( p );
|
ws_nodes.push_back( p );
|
||||||
}
|
}
|
||||||
point_list windsock_nodes = calc_elevations( apt_surf, ws_nodes, 0.0 );
|
point_list windsock_nodes = calc_elevations( apt_surf, ws_nodes, 0.0 );
|
||||||
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Done");
|
||||||
|
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Computing beacon node elevations");
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Computing beacon node elevations");
|
||||||
point_list b_nodes;
|
point_list b_nodes;
|
||||||
|
@ -1052,6 +1049,7 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
||||||
b_nodes.push_back( p );
|
b_nodes.push_back( p );
|
||||||
}
|
}
|
||||||
point_list beacon_nodes = calc_elevations( apt_surf, b_nodes, 0.0 );
|
point_list beacon_nodes = calc_elevations( apt_surf, b_nodes, 0.0 );
|
||||||
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Done");
|
||||||
|
|
||||||
// calc taxiway sign elevations:
|
// calc taxiway sign elevations:
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Computing taxiway sign node elevations");
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Computing taxiway sign node elevations");
|
||||||
|
@ -1063,7 +1061,9 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
||||||
ts_nodes.push_back( p );
|
ts_nodes.push_back( p );
|
||||||
}
|
}
|
||||||
point_list taxisigns_nodes = calc_elevations( apt_surf, ts_nodes, 0.0 );
|
point_list taxisigns_nodes = calc_elevations( apt_surf, ts_nodes, 0.0 );
|
||||||
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Done");
|
||||||
|
|
||||||
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Computing water buoy elevations");
|
||||||
// calc water runway buoys elevations:
|
// calc water runway buoys elevations:
|
||||||
point_list water_buoys_nodes;
|
point_list water_buoys_nodes;
|
||||||
if ( waterrunways.size() > 0){
|
if ( waterrunways.size() > 0){
|
||||||
|
@ -1085,7 +1085,6 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// add base skirt (to hide potential cracks)
|
// add base skirt (to hide potential cracks)
|
||||||
//
|
//
|
||||||
// this has to happen after we've calculated the node elevations
|
// this has to happen after we've calculated the node elevations
|
||||||
|
|
|
@ -20,6 +20,10 @@ class ClosedPoly
|
||||||
public:
|
public:
|
||||||
ClosedPoly( char* desc );
|
ClosedPoly( char* desc );
|
||||||
ClosedPoly( int st, float s, float th, char* desc );
|
ClosedPoly( int st, float s, float th, char* desc );
|
||||||
|
~ClosedPoly()
|
||||||
|
{
|
||||||
|
SG_LOG( SG_GENERAL, SG_DEBUG, "Deleting ClosedPoly " << description );
|
||||||
|
}
|
||||||
|
|
||||||
inline string GetDescription() { return description; }
|
inline string GetDescription() { return description; }
|
||||||
void AddNode( BezNode* node );
|
void AddNode( BezNode* node );
|
||||||
|
|
|
@ -156,6 +156,7 @@ int main(int argc, char **argv)
|
||||||
float min_lat = -90;
|
float min_lat = -90;
|
||||||
float max_lat = 90;
|
float max_lat = 90;
|
||||||
bool view_osg = false;
|
bool view_osg = false;
|
||||||
|
long position = 0;
|
||||||
|
|
||||||
string_list elev_src;
|
string_list elev_src;
|
||||||
elev_src.clear();
|
elev_src.clear();
|
||||||
|
@ -335,11 +336,13 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
else if ( start_id != "" )
|
else if ( start_id != "" )
|
||||||
{
|
{
|
||||||
|
SG_LOG(SG_GENERAL, SG_INFO, "move forward to " << start_id );
|
||||||
|
|
||||||
// scroll forward in datafile
|
// scroll forward in datafile
|
||||||
parser->AddAirport( start_id );
|
position = parser->FindAirport( start_id );
|
||||||
|
|
||||||
// add remaining airports within boundary
|
// add remaining airports within boundary
|
||||||
parser->AddAirports( min_lat, min_lon, max_lat, max_lon );
|
parser->AddAirports( position, min_lat, min_lon, max_lat, max_lon );
|
||||||
|
|
||||||
// parse all the airports that were found
|
// parse all the airports that were found
|
||||||
parser->Parse();
|
parser->Parse();
|
||||||
|
@ -347,7 +350,7 @@ int main(int argc, char **argv)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// find all airports within given boundary
|
// find all airports within given boundary
|
||||||
parser->AddAirports( min_lat, min_lon, max_lat, max_lon );
|
parser->AddAirports( 0, min_lat, min_lon, max_lat, max_lon );
|
||||||
|
|
||||||
// and parser them
|
// and parser them
|
||||||
parser->Parse();
|
parser->Parse();
|
||||||
|
|
|
@ -91,7 +91,7 @@ void Parser::AddAirport( string icao )
|
||||||
// this is and airport definition - remember it
|
// this is and airport definition - remember it
|
||||||
if ( IsAirportDefinition( line, icao ) )
|
if ( IsAirportDefinition( line, icao ) )
|
||||||
{
|
{
|
||||||
SG_LOG( SG_GENERAL, SG_DEBUG, "Found airport " << line << " at " << cur_pos );
|
SG_LOG( SG_GENERAL, SG_DEBUG, "Found airport " << icao << " at " << cur_pos );
|
||||||
parse_positions.push_back( cur_pos );
|
parse_positions.push_back( cur_pos );
|
||||||
airport_icaos.push_back( icao );
|
airport_icaos.push_back( icao );
|
||||||
found = true;
|
found = true;
|
||||||
|
@ -99,7 +99,47 @@ void Parser::AddAirport( string icao )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::AddAirports( float min_lat, float min_lon, float max_lat, float max_lon )
|
long 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 );
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found)
|
||||||
|
{
|
||||||
|
return cur_pos;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Parser::AddAirports( long start_pos, float min_lat, float min_lon, float max_lat, float max_lon )
|
||||||
{
|
{
|
||||||
Airport* airport = NULL;
|
Airport* airport = NULL;
|
||||||
char line[2048];
|
char line[2048];
|
||||||
|
@ -115,7 +155,6 @@ void Parser::AddAirports( float min_lat, float min_lon, float max_lat, float max
|
||||||
done = false;
|
done = false;
|
||||||
match = false;
|
match = false;
|
||||||
|
|
||||||
|
|
||||||
// start from current position, and push all airports where a runway start or end
|
// start from current position, and push all airports where a runway start or end
|
||||||
// lies within the given min/max coordinates
|
// lies within the given min/max coordinates
|
||||||
|
|
||||||
|
@ -126,6 +165,11 @@ void Parser::AddAirports( float min_lat, float min_lon, float max_lat, float max
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (start_pos)
|
||||||
|
{
|
||||||
|
in.seekg(start_pos, ios::beg);
|
||||||
|
}
|
||||||
|
|
||||||
while (!done)
|
while (!done)
|
||||||
{
|
{
|
||||||
// remember the position of this line
|
// remember the position of this line
|
||||||
|
@ -274,6 +318,7 @@ void Parser::Parse()
|
||||||
struct timeval build_time;
|
struct timeval build_time;
|
||||||
struct timeval clean_time;
|
struct timeval clean_time;
|
||||||
struct timeval triangulation_time;
|
struct timeval triangulation_time;
|
||||||
|
time_t curtime;
|
||||||
|
|
||||||
ifstream in( filename.c_str() );
|
ifstream in( filename.c_str() );
|
||||||
if ( !in.is_open() )
|
if ( !in.is_open() )
|
||||||
|
@ -288,11 +333,12 @@ void Parser::Parse()
|
||||||
SetState(STATE_NONE);
|
SetState(STATE_NONE);
|
||||||
in.clear();
|
in.clear();
|
||||||
|
|
||||||
|
gettimeofday(&parse_start, NULL);
|
||||||
|
|
||||||
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 position " << parse_positions[i] );
|
SG_LOG( SG_GENERAL, SG_ALERT, "Parsing airport " << airport_icaos[i] << " at " << parse_positions[i] << " start time " << ctime(&parse_start.tv_sec) );
|
||||||
in.seekg(parse_positions[i], ios::beg);
|
in.seekg(parse_positions[i], ios::beg);
|
||||||
|
|
||||||
gettimeofday(&parse_start, NULL);
|
|
||||||
while ( !in.eof() && (cur_state != STATE_DONE ) )
|
while ( !in.eof() && (cur_state != STATE_DONE ) )
|
||||||
{
|
{
|
||||||
in.getline(tmp, 2048);
|
in.getline(tmp, 2048);
|
||||||
|
|
|
@ -85,8 +85,10 @@ public:
|
||||||
cur_state = STATE_NONE;
|
cur_state = STATE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// int Parse( char* icao );
|
||||||
|
long 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( long start_pos, float min_lat, float min_lon, float max_lat, float max_lon );
|
||||||
void Parse( void );
|
void Parse( void );
|
||||||
|
|
||||||
// osg::Group* CreateOsgGroup( void );
|
// osg::Group* CreateOsgGroup( void );
|
||||||
|
|
|
@ -115,6 +115,10 @@ TGPolygon WaterRunway::GetNodes()
|
||||||
TGPolygon buoy_nodes;
|
TGPolygon buoy_nodes;
|
||||||
buoy_nodes.erase();
|
buoy_nodes.erase();
|
||||||
|
|
||||||
|
SG_LOG(SG_GENERAL, SG_DEBUG, "WaterRunway::GetNodes" );
|
||||||
|
|
||||||
|
if (buoys == 1){ /*no point to calculate stuff we don't need*/
|
||||||
|
|
||||||
double heading, az2, length;
|
double heading, az2, length;
|
||||||
// calculate runway heading and length
|
// calculate runway heading and length
|
||||||
geo_inverse_wgs_84( lat[0], lon[0], lat[1], lon[1], &heading, &az2, &length );
|
geo_inverse_wgs_84( lat[0], lon[0], lat[1], lon[1], &heading, &az2, &length );
|
||||||
|
@ -122,6 +126,7 @@ TGPolygon WaterRunway::GetNodes()
|
||||||
// create a polygon for the 4 buoy points
|
// create a polygon for the 4 buoy points
|
||||||
// TODO: The amount of points can be increased if needed (more buoys)
|
// TODO: The amount of points can be increased if needed (more buoys)
|
||||||
buoy_nodes = gen_wgs84_area(Point3D( (lon[0] + lon[1]) / 2 , (lat[0] + lat[1]) / 2, 0), length, 0, 0, width, heading, 0, false);
|
buoy_nodes = gen_wgs84_area(Point3D( (lon[0] + lon[1]) / 2 , (lat[0] + lat[1]) / 2, 0), length, 0, 0, width, heading, 0, false);
|
||||||
|
}
|
||||||
return buoy_nodes;
|
return buoy_nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue