1
0
Fork 0

- Added support for generating green taxiway center lighting (when called for

in Robin's data.)
- Code adjusted to work with slightly modified input data format (part of
  our move away from metakit.)
- Eliminate some debugging output.
This commit is contained in:
curt 2003-08-29 20:34:46 +00:00
parent bd02f2548c
commit 473c4d9b94
5 changed files with 257 additions and 167 deletions

View file

@ -115,7 +115,7 @@ static void calc_elevations( const string &root, Matrix_Point3Df &Pts ) {
if ( elev > -9000 ) { if ( elev > -9000 ) {
p.z() = elev; p.z() = elev;
Pts(i,j) = p; Pts(i,j) = p;
cout << "interpolating for " << p << endl; // cout << "interpolating for " << p << endl;
} }
} }
} }

View file

@ -271,7 +271,7 @@ static void build_runway( const TGRunway& rwy_info,
SG_LOG(SG_GENERAL, SG_DEBUG, "type flag = " << type_flag); SG_LOG(SG_GENERAL, SG_DEBUG, "type flag = " << type_flag);
if ( rwy_info.really_taxiway ) { if ( rwy_info.really_taxiway ) {
gen_taxiway( rwy_info, alt_m,material, gen_taxiway( rwy_info, alt_m, material,
rwy_polys, texparams, accum ); rwy_polys, texparams, accum );
} else if ( surface_flag == "D" || surface_flag == "G" || } else if ( surface_flag == "D" || surface_flag == "G" ||
surface_flag == "T" ) surface_flag == "T" )
@ -293,6 +293,9 @@ static void build_runway( const TGRunway& rwy_info,
} else if ( type_flag == "B" ) { } else if ( type_flag == "B" ) {
// bouys (sea plane base) // bouys (sea plane base)
// do nothing for now. // do nothing for now.
} else if ( type_flag == "H" ) {
// helipad
// do nothing for now.
} else { } else {
// unknown runway code ... hehe, I know, let's just die // unknown runway code ... hehe, I know, let's just die
// right here so the programmer has to fix his code if a // right here so the programmer has to fix his code if a
@ -318,7 +321,7 @@ static void build_runway( const TGRunway& rwy_info,
// build 3d airport // build 3d airport
void build_airport( string airport_raw, float alt_m, void build_airport( string airport_id, float alt_m,
string_list& runways_raw, string_list& runways_raw,
string_list& taxiways_raw, const string& root ) string_list& taxiways_raw, const string& root )
{ {
@ -338,45 +341,10 @@ void build_airport( string airport_raw, float alt_m,
accum.erase(); accum.erase();
// parse main airport information // parse main airport information
double apt_lon, apt_lat; double apt_lon = 0.0, apt_lat = 0.0;
int elev; int rwy_count = 0;
SG_LOG(SG_GENERAL, SG_INFO, airport_raw); SG_LOG( SG_GENERAL, SG_INFO, "Building " << airport_id );
string apt_type = airport_raw.substr(0, 1);
string apt_code = airport_raw.substr(2, 4); my_chomp( apt_code );
string apt_lat_str = airport_raw.substr(7, 10);
apt_lat = atof( apt_lat_str.c_str() );
string apt_lon_str = airport_raw.substr(18, 11);
apt_lon = atof( apt_lon_str.c_str() );
string apt_elev = airport_raw.substr(30, 5);
elev = atoi( apt_elev.c_str() );
string apt_use = airport_raw.substr(36, 1);
string apt_twr = airport_raw.substr(37, 1);
string apt_bldg = airport_raw.substr(38, 1);
string apt_name = airport_raw.substr(40);
/*
SG_LOG(SG_GENERAL, SG_DEBUG, " type = " << apt_type);
SG_LOG(SG_GENERAL, SG_DEBUG, " code = " << apt_code);
SG_LOG(SG_GENERAL, SG_DEBUG, " lat = " << apt_lat);
SG_LOG(SG_GENERAL, SG_DEBUG, " lon = " << apt_lon);
SG_LOG(SG_GENERAL, SG_DEBUG, " elev = " << apt_elev << " " << elev);
SG_LOG(SG_GENERAL, SG_DEBUG, " use = " << apt_use);
SG_LOG(SG_GENERAL, SG_DEBUG, " twr = " << apt_twr);
SG_LOG(SG_GENERAL, SG_DEBUG, " bldg = " << apt_bldg);
SG_LOG(SG_GENERAL, SG_DEBUG, " name = " << apt_name);
*/
SGBucket b( apt_lon, apt_lat );
Point3D center_geod( b.get_center_lon() * SGD_DEGREES_TO_RADIANS,
b.get_center_lat() * SGD_DEGREES_TO_RADIANS, 0 );
Point3D gbs_center = sgGeodToCart( center_geod );
SG_LOG(SG_GENERAL, SG_DEBUG, b.gen_base_path() << "/" << b.gen_index_str());
// Ignore any seaplane bases
if ( apt_type == "S" ) {
return;
}
// parse runways and generate the vertex list // parse runways and generate the vertex list
runway_list runways; runway_list runways;
@ -384,6 +352,8 @@ void build_airport( string airport_raw, float alt_m,
string rwy_str; string rwy_str;
for ( i = 0; i < (int)runways_raw.size(); ++i ) { for ( i = 0; i < (int)runways_raw.size(); ++i ) {
++rwy_count;
rwy_str = runways_raw[i]; rwy_str = runways_raw[i];
TGRunway rwy; TGRunway rwy;
@ -391,101 +361,115 @@ void build_airport( string airport_raw, float alt_m,
rwy.really_taxiway = false; rwy.really_taxiway = false;
SG_LOG(SG_GENERAL, SG_DEBUG, rwy_str); SG_LOG(SG_GENERAL, SG_DEBUG, rwy_str);
rwy.rwy_no = rwy_str.substr(2, 4); rwy.rwy_no = rwy_str.substr(7, 4);
string rwy_lat = rwy_str.substr(6, 10); string rwy_lat = rwy_str.substr(11, 10);
rwy.lat = atof( rwy_lat.c_str() ); rwy.lat = atof( rwy_lat.c_str() );
apt_lat += rwy.lat;
string rwy_lon = rwy_str.substr(17, 11); string rwy_lon = rwy_str.substr(22, 11);
rwy.lon = atof( rwy_lon.c_str() ); rwy.lon = atof( rwy_lon.c_str() );
apt_lon += rwy.lon;
string rwy_hdg = rwy_str.substr(29, 7); string rwy_hdg = rwy_str.substr(34, 6);
rwy.heading = atof( rwy_hdg.c_str() ); rwy.heading = atof( rwy_hdg.c_str() );
string rwy_len = rwy_str.substr(36, 7); string rwy_len = rwy_str.substr(41, 5);
rwy.length = atoi( rwy_len.c_str() ); rwy.length = atoi( rwy_len.c_str() );
string rwy_width = rwy_str.substr(43, 4); string rwy_width = rwy_str.substr(47, 5);
rwy.width = atoi( rwy_width.c_str() ); rwy.width = atoi( rwy_width.c_str() );
rwy.surface_flags = rwy_str.substr(47, 5); rwy.surface_flags = rwy_str.substr(53, 5);
rwy.end1_flags = rwy_str.substr(53, 4); rwy.end1_flags = rwy_str.substr(59, 4);
string rwy_disp_threshold1 = rwy_str.substr(58, 6); string rwy_disp_threshold1 = rwy_str.substr(64, 4);
rwy.disp_thresh1 = atoi( rwy_disp_threshold1.c_str() ); rwy.disp_thresh1 = atoi( rwy_disp_threshold1.c_str() );
string rwy_stopway1 = rwy_str.substr(65, 6); string rwy_stopway1 = rwy_str.substr(69, 4);
rwy.stopway1 = atoi( rwy_stopway1.c_str() ); rwy.stopway1 = atoi( rwy_stopway1.c_str() );
rwy.end2_flags = rwy_str.substr(72, 4); rwy.end2_flags = rwy_str.substr(74, 4);
string rwy_disp_threshold2 = rwy_str.substr(77, 6); string rwy_disp_threshold2 = rwy_str.substr(79, 4);
rwy.disp_thresh2 = atoi( rwy_disp_threshold2.c_str() ); rwy.disp_thresh2 = atoi( rwy_disp_threshold2.c_str() );
string rwy_stopway2 = rwy_str.substr(84, 6); string rwy_stopway2 = rwy_str.substr(83, 4);
rwy.stopway2 = atoi( rwy_stopway2.c_str() ); rwy.stopway2 = atoi( rwy_stopway2.c_str() );
SG_LOG(SG_GENERAL, SG_DEBUG, " no = " << rwy.rwy_no); SG_LOG( SG_GENERAL, SG_INFO, " no = " << rwy.rwy_no);
SG_LOG(SG_GENERAL, SG_DEBUG, " lat = " << rwy_lat << " " << rwy.lat); SG_LOG( SG_GENERAL, SG_INFO, " lat = " << rwy_lat << " " << rwy.lat);
SG_LOG(SG_GENERAL, SG_DEBUG, " lon = " << rwy_lon << " " << rwy.lon); SG_LOG( SG_GENERAL, SG_INFO, " lon = " << rwy_lon << " " << rwy.lon);
SG_LOG(SG_GENERAL, SG_DEBUG, " hdg = " << rwy_hdg << " " << rwy.heading); SG_LOG( SG_GENERAL, SG_INFO, " hdg = " << rwy_hdg << " "
SG_LOG(SG_GENERAL, SG_DEBUG, " len = " << rwy_len << " " << rwy.length); << rwy.heading);
SG_LOG(SG_GENERAL, SG_DEBUG, " width = " << rwy_width << " " << rwy.width); SG_LOG( SG_GENERAL, SG_INFO, " len = " << rwy_len << " "
SG_LOG(SG_GENERAL, SG_DEBUG, " sfc = " << rwy.surface_flags); << rwy.length);
SG_LOG(SG_GENERAL, SG_DEBUG, " end1 = " << rwy.end1_flags); SG_LOG( SG_GENERAL, SG_INFO, " width = " << rwy_width << " "
SG_LOG(SG_GENERAL, SG_DEBUG, " dspth1= " << rwy_disp_threshold1 << " " << rwy.disp_thresh1); << rwy.width);
SG_LOG(SG_GENERAL, SG_DEBUG, " stop1 = " << rwy_stopway1 << " " << rwy.stopway1); SG_LOG( SG_GENERAL, SG_INFO, " sfc = " << rwy.surface_flags);
SG_LOG(SG_GENERAL, SG_DEBUG, " end2 = " << rwy.end2_flags); SG_LOG( SG_GENERAL, SG_INFO, " end1 = " << rwy.end1_flags);
SG_LOG(SG_GENERAL, SG_DEBUG, " dspth2= " << rwy_disp_threshold2 << " " << rwy.disp_thresh2); SG_LOG( SG_GENERAL, SG_INFO, " dspth1= " << rwy_disp_threshold1
SG_LOG(SG_GENERAL, SG_DEBUG, " stop2 = " << rwy_stopway2 << " " << rwy.stopway2); << " " << rwy.disp_thresh1);
SG_LOG( SG_GENERAL, SG_INFO, " stop1 = " << rwy_stopway1 << " "
<< rwy.stopway1);
SG_LOG( SG_GENERAL, SG_INFO, " end2 = " << rwy.end2_flags);
SG_LOG( SG_GENERAL, SG_INFO, " dspth2= " << rwy_disp_threshold2
<< " " << rwy.disp_thresh2);
SG_LOG( SG_GENERAL, SG_INFO, " stop2 = " << rwy_stopway2 << " "
<< rwy.stopway2);
runways.push_back( rwy ); runways.push_back( rwy );
} }
SGBucket b( apt_lon / (double)rwy_count, apt_lat / (double)rwy_count );
Point3D center_geod( b.get_center_lon() * SGD_DEGREES_TO_RADIANS,
b.get_center_lat() * SGD_DEGREES_TO_RADIANS, 0 );
Point3D gbs_center = sgGeodToCart( center_geod );
SG_LOG(SG_GENERAL, SG_INFO, b.gen_base_path() << "/" << b.gen_index_str());
// parse taxiways and generate the vertex list // parse taxiways and generate the vertex list
runway_list taxiways; runway_list taxiways;
taxiways.clear(); taxiways.clear();
for ( i = 0; i < (int)taxiways_raw.size(); ++i ) { for ( i = 0; i < (int)taxiways_raw.size(); ++i ) {
rwy_str = taxiways_raw[i]; string taxi_str = taxiways_raw[i];
TGRunway taxi; TGRunway taxi;
taxi.really_taxiway = true; taxi.really_taxiway = true;
taxi.generated = false; taxi.generated = false;
SG_LOG(SG_GENERAL, SG_DEBUG, rwy_str); SG_LOG(SG_GENERAL, SG_INFO, taxi_str);
taxi.rwy_no = rwy_str.substr(2, 4);
string rwy_lat = rwy_str.substr(6, 10); string taxi_lat = taxi_str.substr(11, 10);
taxi.lat = atof( rwy_lat.c_str() ); taxi.lat = atof( taxi_lat.c_str() );
string rwy_lon = rwy_str.substr(17, 11); string taxi_lon = taxi_str.substr(22, 11);
taxi.lon = atof( rwy_lon.c_str() ); taxi.lon = atof( taxi_lon.c_str() );
string rwy_hdg = rwy_str.substr(29, 7); string taxi_hdg = taxi_str.substr(34, 6);
taxi.heading = atof( rwy_hdg.c_str() ); taxi.heading = atof( taxi_hdg.c_str() );
string rwy_len = rwy_str.substr(36, 7); string taxi_len = taxi_str.substr(41, 5);
taxi.length = atoi( rwy_len.c_str() ); taxi.length = atoi( taxi_len.c_str() );
string rwy_width = rwy_str.substr(43, 5); string taxi_width = taxi_str.substr(47, 5);
taxi.width = atoi( rwy_width.c_str() ); taxi.width = atoi( taxi_width.c_str() );
taxi.surface_flags = rwy_str.substr(48, 3); taxi.surface_flags = taxi_str.substr(53, 5);
/* SG_LOG( SG_GENERAL, SG_INFO, " lat = " << taxi_lat << " "
SG_LOG(SG_GENERAL, SG_DEBUG, " no = " << rwy_no); << taxi.lat);
SG_LOG(SG_GENERAL, SG_DEBUG, " lat = " << rwy_lat << " " << lat); SG_LOG( SG_GENERAL, SG_INFO, " lon = " << taxi_lon << " "
SG_LOG(SG_GENERAL, SG_DEBUG, " lon = " << rwy_lon << " " << lon); << taxi.lon);
SG_LOG(SG_GENERAL, SG_DEBUG, " hdg = " << rwy_hdg << " " << hdg); SG_LOG( SG_GENERAL, SG_INFO, " hdg = " << taxi_hdg << " "
SG_LOG(SG_GENERAL, SG_DEBUG, " len = " << rwy_len << " " << len); << taxi.heading);
SG_LOG(SG_GENERAL, SG_DEBUG, " width = " << rwy_width << " " << width); SG_LOG( SG_GENERAL, SG_INFO, " len = " << taxi_len << " "
SG_LOG(SG_GENERAL, SG_DEBUG, " sfc = " << rwy_sfc); << taxi.length);
SG_LOG(SG_GENERAL, SG_DEBUG, " end1 = " << rwy_end1); SG_LOG( SG_GENERAL, SG_INFO, " width = " << taxi_width << " "
SG_LOG(SG_GENERAL, SG_DEBUG, " end2 = " << rwy_end2); << taxi.width);
*/ SG_LOG( SG_GENERAL, SG_INFO, " sfc = " << taxi.surface_flags);
taxiways.push_back( taxi ); taxiways.push_back( taxi );
} }
@ -498,7 +482,7 @@ void build_airport( string airport_raw, float alt_m,
for ( i = 0; i < (int)runways.size(); ++i ) { for ( i = 0; i < (int)runways.size(); ++i ) {
string type_flag = runways[i].surface_flags.substr(2, 1); string type_flag = runways[i].surface_flags.substr(2, 1);
if ( type_flag == "P" ) { if ( type_flag == "P" ) {
build_runway( runways[i], elev * SG_FEET_TO_METER, build_runway( runways[i], alt_m,
&rwy_polys, &texparams, &accum, &rwy_polys, &texparams, &accum,
&apt_base, &apt_clearing ); &apt_base, &apt_clearing );
} }
@ -508,7 +492,7 @@ void build_airport( string airport_raw, float alt_m,
for ( i = 0; i < (int)runways.size(); ++i ) { for ( i = 0; i < (int)runways.size(); ++i ) {
string type_flag = runways[i].surface_flags.substr(2, 1); string type_flag = runways[i].surface_flags.substr(2, 1);
if ( type_flag == "R" || type_flag == "V" ) { if ( type_flag == "R" || type_flag == "V" ) {
build_runway( runways[i], elev * SG_FEET_TO_METER, build_runway( runways[i], alt_m,
&rwy_polys, &texparams, &accum, &rwy_polys, &texparams, &accum,
&apt_base, &apt_clearing ); &apt_base, &apt_clearing );
} }
@ -519,7 +503,7 @@ void build_airport( string airport_raw, float alt_m,
string type_flag = runways[i].surface_flags.substr(2, 1); string type_flag = runways[i].surface_flags.substr(2, 1);
if ( type_flag != string("P") && type_flag != string("R") if ( type_flag != string("P") && type_flag != string("R")
&& type_flag != string("V") ) { && type_flag != string("V") ) {
build_runway( runways[i], elev * SG_FEET_TO_METER, build_runway( runways[i], alt_m,
&rwy_polys, &texparams, &accum, &rwy_polys, &texparams, &accum,
&apt_base, &apt_clearing ); &apt_base, &apt_clearing );
} }
@ -545,7 +529,7 @@ void build_airport( string airport_raw, float alt_m,
if ( largest_idx >= 0 ) { if ( largest_idx >= 0 ) {
SG_LOG( SG_GENERAL, SG_INFO, "generating " << largest_idx ); SG_LOG( SG_GENERAL, SG_INFO, "generating " << largest_idx );
build_runway( taxiways[largest_idx], elev * SG_FEET_TO_METER, build_runway( taxiways[largest_idx], alt_m,
&rwy_polys, &texparams, &accum, &rwy_polys, &texparams, &accum,
&apt_base, &apt_clearing ); &apt_base, &apt_clearing );
taxiways[largest_idx].generated = true; taxiways[largest_idx].generated = true;
@ -1143,7 +1127,7 @@ void build_airport( string airport_raw, float alt_m,
string_list fan_materials; fan_materials.clear(); string_list fan_materials; fan_materials.clear();
string objpath = root + "/AirportObj"; string objpath = root + "/AirportObj";
string name = apt_code + ".btg"; string name = airport_id + ".btg";
SGBinObject obj; SGBinObject obj;

View file

@ -34,7 +34,7 @@
// build 3d airport // build 3d airport
void build_airport( string airport, float alt_m, string_list& runways_raw, void build_airport( string airport_id, float alt_m, string_list& runways_raw,
string_list& taxiways_raw, const string& root ); string_list& taxiways_raw, const string& root );

View file

@ -496,6 +496,76 @@ static superpoly_list gen_runway_center_line_lights( const TGRunway& rwy_info,
} }
// generate runway center line lighting, 50' spacing.
static superpoly_list gen_taxiway_center_line_lights( const TGRunway& rwy_info,
bool recip )
{
point_list g_lights; g_lights.clear();
point_list g_normals; g_normals.clear();
int i;
double len = rwy_info.length;
// this should be ??' technically but I'm trying 50' to space things out
int divs = (int)(len / 70) + 1;
Point3D normal = gen_runway_light_vector( rwy_info, 3.0, recip );
// using TGPolygon is a bit innefficient, but that's what the
// routine returns.
TGPolygon poly_corners = gen_runway_area_w_extend( rwy_info, 0.0, 2.0, 2.0 );
point_list corner;
for ( i = 0; i < poly_corners.contour_size( 0 ); ++i ) {
corner.push_back( poly_corners.get_pt( 0, i ) );
}
Point3D inc;
Point3D pt1, pt2;
if ( recip ) {
pt1 = (corner[0] + corner[1] ) / 2.0;
pt2 = (corner[2] + corner[3] ) / 2.0;
} else {
pt1 = (corner[2] + corner[3] ) / 2.0;
pt2 = (corner[0] + corner[1] ) / 2.0;
}
inc = (pt2 - pt1) / divs;
double dist = len;
double step = len / divs;
pt1 += inc; // move 25' in
dist -= step;
while ( dist > 0.0 ) {
g_lights.push_back( pt1 );
g_normals.push_back( normal );
pt1 += inc;
pt1 += inc;
dist -= step;
dist -= step;
}
superpoly_list result; result.clear();
if ( g_lights.size() > 0 ) {
TGPolygon lights_poly; lights_poly.erase();
TGPolygon normals_poly; normals_poly.erase();
lights_poly.add_contour( g_lights, false );
normals_poly.add_contour( g_normals, false );
TGSuperPoly green;
green.set_poly( lights_poly );
green.set_normals( normals_poly );
green.set_material( "RWY_GREEN_LOW_LIGHTS" );
result.push_back( green );
}
return result;
}
// generate touch down zone lights // generate touch down zone lights
static TGSuperPoly gen_touchdown_zone_lights( const TGRunway& rwy_info, static TGSuperPoly gen_touchdown_zone_lights( const TGRunway& rwy_info,
float alt_m, bool recip ) float alt_m, bool recip )
@ -2391,13 +2461,13 @@ void gen_taxiway_lights( const TGRunway& taxiway_info, float alt_m,
if ( taxiway_info.surface_flags.substr(0,1) == "Y" ) { if ( taxiway_info.surface_flags.substr(0,1) == "Y" ) {
// forward direction // forward direction
superpoly_list s; superpoly_list s;
s = gen_runway_center_line_lights( taxiway_info, false ); s = gen_taxiway_center_line_lights( taxiway_info, false );
for ( i = 0; i < s.size(); ++i ) { for ( i = 0; i < s.size(); ++i ) {
lights.push_back( s[i] ); lights.push_back( s[i] );
} }
// reverse direction // reverse direction
s = gen_runway_center_line_lights( taxiway_info, true ); s = gen_taxiway_center_line_lights( taxiway_info, true );
for ( i = 0; i < s.size(); ++i ) { for ( i = 0; i < s.size(); ++i ) {
lights.push_back( s[i] ); lights.push_back( s[i] );
} }

View file

@ -74,10 +74,6 @@ int main( int argc, char **argv ) {
float max_lon = 180; float max_lon = 180;
float min_lat = -90; float min_lat = -90;
float max_lat = 90; float max_lat = 90;
string_list runways_list, taxiways_list;
string airport, last_airport;
string line;
char tmp[2048];
bool ready_to_go = true; bool ready_to_go = true;
sglog().setLogLevels( SG_GENERAL, SG_INFO ); sglog().setLogLevels( SG_GENERAL, SG_INFO );
@ -163,58 +159,69 @@ int main( int argc, char **argv ) {
} }
// throw away the first line // throw away the first line
in.getline(tmp, 2048); in >> skipeol;
last_airport = ""; string_list runways_list, taxiways_list;
string last_apt_id = "";
string last_apt_info = "";
string line;
char tmp[2048];
while ( ! in.eof() ) { while ( ! in.eof() ) {
in.getline(tmp, 2048); in.getline(tmp, 2048);
line = tmp; line = tmp;
SG_LOG(SG_GENERAL, SG_DEBUG, line); SG_LOG( SG_GENERAL, SG_INFO, "-> " << line );
if ( line.length() == 0 ) { if ( line.length() == 0 ) {
// empty, skip // empty, skip
} else if ( line[0] == '#' ) { } else if ( line[0] == '#' ) {
// comment, skip // comment, skip
} else if ( (line[0] == 'A') || (line[0] == 'H') || (line[0] == 'S') ) { } else if ( line[0] == 'A' || line[0] == 'H' || line[0] == 'S' ) {
// start of airport record // extract some airport runway info
airport = line; char ctmp, tmpid[32], rwy[32];
string id;
if ( !last_airport.empty() ) {
char ctmp, id[32];
float lat, lon; float lat, lon;
int alt_ft; int elev = 0;
sscanf( last_airport.c_str(), "%c %s %f %f %d",
&ctmp, id, &lat, &lon, &alt_ft); sscanf( line.c_str(), "%c %s %d",
SG_LOG(SG_GENERAL, SG_DEBUG, "Airport lat/lon/alt = " &ctmp, tmpid, &elev );
<< lat << ',' << lon << "," << alt_ft); id = tmpid;
SG_LOG(SG_GENERAL, SG_DEBUG, "Id portion = " << id); SG_LOG( SG_GENERAL, SG_INFO, "Airport = " << id << " "
<< elev );
if ( !last_apt_id.empty()) {
if ( runways_list.size() ) {
sscanf( runways_list[0].c_str(), "%c %s %s %f %f",
&ctmp, tmpid, rwy, &lat, &lon );
}
if ( lon >= min_lon && lon <= max_lon && if ( lon >= min_lon && lon <= max_lon &&
lat >= min_lat && lat <= max_lat ) { lat >= min_lat && lat <= max_lat )
{
if ( start_id.length() && start_id == (string)id ) { if ( start_id.length() && start_id == last_apt_id ) {
ready_to_go = true; ready_to_go = true;
} }
if ( ready_to_go ) { if ( ready_to_go ) {
// check point our location // check point our location
char command[256]; char command[256];
sprintf( command, "echo %s > last_apt", id ); sprintf( command,
"echo before building %s >> last_apt",
last_apt_id.c_str() );
system( command ); system( command );
// process previous record // process previous record
// process_airport(last_airport, runways_list, argv[2]); // process_airport(last_apt_id, runways_list, argv[2]);
try { try {
build_airport( last_airport, build_airport( last_apt_id, elev * SG_FEET_TO_METER,
alt_ft * SG_FEET_TO_METER,
runways_list, taxiways_list, runways_list, taxiways_list,
work_dir ); work_dir );
} catch (sg_exception &e) { } catch (sg_exception &e) {
SG_LOG(SG_GENERAL, SG_ALERT, SG_LOG( SG_GENERAL, SG_ALERT,
"Failed to build airport " << id); "Failed to build airport = "
SG_LOG(SG_GENERAL, SG_ALERT, "Exception: " << last_apt_id );
<< e.getMessage()); SG_LOG( SG_GENERAL, SG_ALERT, "Exception: "
<< e.getMessage() );
exit(-1); exit(-1);
} }
} }
@ -222,21 +229,17 @@ int main( int argc, char **argv ) {
SG_LOG(SG_GENERAL, SG_INFO, "Skipping airport " << id); SG_LOG(SG_GENERAL, SG_INFO, "Skipping airport " << id);
} }
} }
last_apt_id = id;
last_apt_info = line;
// clear runway list for start of next airport // clear runway list for start of next airport
runways_list.clear(); runways_list.clear();
taxiways_list.clear(); taxiways_list.clear();
last_airport = airport;
} else if ( line[0] == 'R' ) { } else if ( line[0] == 'R' ) {
// runway entry // runway entry
runways_list.push_back(line); runways_list.push_back(line);
} else if ( line[0] == 'T' ) { } else if ( line[0] == 'T' ) {
// runway entry // runway entry
taxiways_list.push_back(line); taxiways_list.push_back(line);
} else if ( line == "[End]" ) {
// end of file
break;
} else { } else {
SG_LOG( SG_GENERAL, SG_ALERT, SG_LOG( SG_GENERAL, SG_ALERT,
"Unknown line in file: " << line ); "Unknown line in file: " << line );
@ -244,25 +247,58 @@ int main( int argc, char **argv ) {
} }
} }
if ( last_airport.length() ) { if ( last_apt_id.length() ) {
char ctmp, id[32]; // extract some airport runway info
char ctmp, tmpid[32], rwy[32];
string id;
float lat, lon; float lat, lon;
int alt_ft; int elev = 0;
sscanf( last_airport.c_str(), "%c %s %f %f %d",
&ctmp, id, &lat, &lon, &alt_ft);
SG_LOG(SG_GENERAL, SG_DEBUG, "Airport lat/lon/alt = "
<< lat << ',' << lon << "," << alt_ft);
SG_LOG(SG_GENERAL, SG_DEBUG, "Id portion = " << id);
if ( start_id.length() && start_id == id ) { sscanf( line.c_str(), "%c %s %d",
&ctmp, tmpid, &elev );
id = tmpid;
SG_LOG( SG_GENERAL, SG_INFO, "Airport = " << id << " "
<< elev );
if ( !last_apt_id.empty()) {
if ( runways_list.size() ) {
sscanf( runways_list[0].c_str(), "%c %s %s %s %f %f",
&ctmp, tmpid, rwy, &lat, &lon );
}
if ( lon >= min_lon && lon <= max_lon &&
lat >= min_lat && lat <= max_lat )
{
if ( start_id.length() && start_id == last_apt_id ) {
ready_to_go = true; ready_to_go = true;
} }
if ( ready_to_go ) { if ( ready_to_go ) {
// check point our location
char command[256];
sprintf( command,
"echo before building %s >> last_apt",
last_apt_id.c_str() );
system( command );
// process previous record // process previous record
// process_airport(last_airport, runways_list, argv[2]); // process_airport(last_apt_id, runways_list, argv[2]);
build_airport(last_airport, alt_ft * SG_FEET_TO_METER, try {
runways_list, taxiways_list, work_dir); build_airport( last_apt_id, elev * SG_FEET_TO_METER,
runways_list, taxiways_list,
work_dir );
} catch (sg_exception &e) {
SG_LOG( SG_GENERAL, SG_ALERT,
"Failed to build airport = "
<< last_apt_id );
SG_LOG( SG_GENERAL, SG_ALERT, "Exception: "
<< e.getMessage() );
exit(-1);
}
}
} else {
SG_LOG(SG_GENERAL, SG_INFO, "Skipping airport " << id);
}
} }
} }