1
0
Fork 0

First stab at code changes to support the X-Plane data format directly.

This commit is contained in:
curt 2004-10-15 20:14:38 +00:00
parent 86d985a131
commit 27cfc32e4e
6 changed files with 310 additions and 341 deletions

View file

@ -29,6 +29,7 @@
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <simgear/misc/strutils.hxx>
#include <simgear/structure/exception.hxx> #include <simgear/structure/exception.hxx>
#include <stdio.h> #include <stdio.h>
@ -236,82 +237,89 @@ static void build_runway( const TGRunway& rwy_info,
TGPolygon *apt_base, TGPolygon *apt_base,
TGPolygon *apt_clearing ) TGPolygon *apt_clearing )
{ {
SG_LOG(SG_GENERAL, SG_DEBUG, "surface flags = " << rwy_info.surface_flags); SG_LOG(SG_GENERAL, SG_DEBUG, "surface code = " << rwy_info.surface_code);
string surface_flag = rwy_info.surface_flags.substr(1, 1); int surface_code = rwy_info.surface_code;
string light_flag = rwy_info.surface_flags.substr(2, 1); SG_LOG(SG_GENERAL, SG_DEBUG, "surface code = " << surface_code);
SG_LOG(SG_GENERAL, SG_DEBUG, "surface flag = " << surface_flag); string lighting_flags = rwy_info.lighting_flags;
SG_LOG(SG_GENERAL, SG_DEBUG, "lighting flags = " << lighting_flags);
string vasi1 = lighting_flags.substr(0,1);
string rwylt1 = lighting_flags.substr(1,1);
string apprch1 = lighting_flags.substr(2,1);
string vasi2 = lighting_flags.substr(3,1);
string rwylt2 = lighting_flags.substr(4,1);
string apprch2 = lighting_flags.substr(5,1);
string material; string material;
if ( surface_flag == "A" ) { if ( surface_code == 1 /* Asphalt */ ) {
if ( !rwy_info.really_taxiway ) { if ( !rwy_info.really_taxiway ) {
material = "pa_"; // asphalt material = "pa_";
} else { } else {
if ( rwy_info.width <= 150 && light_flag == "B" ) if ( rwy_info.width <= 150 && rwylt1 == "6" ) {
material = "pa_taxiway"; material = "pa_taxiway";
else } else {
material = "pa_tiedown"; material = "pa_tiedown";
} }
} else if ( surface_flag == "C" ) { }
} else if ( surface_code == 2 /* Concrete */ ) {
if ( !rwy_info.really_taxiway ) { if ( !rwy_info.really_taxiway ) {
material = "pc_"; // concrete material = "pc_";
} else { } else {
if ( rwy_info.width <= 150 && light_flag == "B" ) if ( rwy_info.width <= 150 && rwylt1 == "6" ) {
material = "pc_taxiway"; material = "pc_taxiway";
else } else {
material = "pc_tiedown"; material = "pc_tiedown";
} }
} else if ( surface_flag == "D" ) { }
material = "dirt_rwy"; } else if ( surface_code == 3 /* Turf/Grass */ ) {
} else if ( surface_flag == "G" ) {
material = "grass_rwy"; material = "grass_rwy";
} else if ( surface_flag == "L" ) { } else if ( surface_code == 4 /* Dirt */
|| surface_code == 5 /* Gravel */ ) {
material = "dirt_rwy";
} else if ( surface_code == 12 /* Dry Lakebed */ ) {
if ( rwy_info.really_taxiway ) { if ( rwy_info.really_taxiway ) {
material = "lakebed_taxiway"; material = "lakebed_taxiway";
} else { } else {
material = "dirt_rwy"; material = "dirt_rwy";
} }
} else if ( surface_flag == "T" ) { } else if ( surface_code == 13 /* Water runway (buoy's?) */ ) {
material = "grass_rwy"; // water
} else if ( surface_flag == "W" ) {
// water ???
} else { } else {
throw sg_exception("unknown runway type!"); throw sg_exception("unknown runway type!");
} }
string type_flag = rwy_info.surface_flags.substr(2, 1); SG_LOG(SG_GENERAL, SG_DEBUG, "marking code = " << rwy_info.marking_code);
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_code == 3 /* Turf/Grass */
surface_flag == "T" ) || surface_code == 4 /* Dirt */
|| surface_code == 5 /* Gravel */ )
{ {
gen_simple_rwy( rwy_info, alt_m, material, gen_simple_rwy( rwy_info, alt_m, material,
rwy_polys, texparams, accum ); rwy_polys, texparams, accum );
} else if ( type_flag == "P" ) { } else if ( rwy_info.marking_code == 3 /* Precision */ ) {
// precision runway markings // precision runway markings
gen_precision_rwy( rwy_info, alt_m, material, gen_precision_rwy( rwy_info, alt_m, material,
rwy_polys, texparams, accum ); rwy_polys, texparams, accum );
} else if ( type_flag == "R" ) { } else if ( rwy_info.marking_code == 2 /* Non-precision */ ) {
// non-precision runway markings // non-precision runway markings
gen_non_precision_rwy( rwy_info, alt_m, material, gen_non_precision_rwy( rwy_info, alt_m, material,
rwy_polys, texparams, accum ); rwy_polys, texparams, accum );
} else if ( type_flag == "V" ) { } else if ( rwy_info.marking_code == 1 /* Visual */ ) {
// visual runway markings // visual runway markings
gen_visual_rwy( rwy_info, alt_m, material, gen_visual_rwy( rwy_info, alt_m, material,
rwy_polys, texparams, accum ); rwy_polys, texparams, accum );
} else if ( type_flag == "B" ) { } else if ( surface_code == 13 /* Water buoys */ ) {
// bouys (sea plane base)
// do nothing for now.
} else if ( type_flag == "H" ) {
// helipad
// do nothing for now. // 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
// new code ever gets introduced. :-) // new code ever gets introduced. :-)
SG_LOG( SG_GENERAL, SG_ALERT, "Unknown runway code = " <<
rwy_info.marking_code );
throw sg_exception("Unknown runway code in build.cxx:build_airport()"); throw sg_exception("Unknown runway code in build.cxx:build_airport()");
} }
@ -337,7 +345,6 @@ static void build_runway( const TGRunway& rwy_info,
// build 3d airport // build 3d airport
void build_airport( string airport_id, float alt_m, void build_airport( string airport_id, float alt_m,
string_list& runways_raw, string_list& runways_raw,
string_list& taxiways_raw,
string_list& beacons_raw, string_list& beacons_raw,
string_list& towers_raw, string_list& towers_raw,
string_list& windsocks_raw, string_list& windsocks_raw,
@ -365,81 +372,74 @@ void build_airport( string airport_id, float alt_m,
SG_LOG( SG_GENERAL, SG_INFO, "Building " << airport_id ); SG_LOG( SG_GENERAL, SG_INFO, "Building " << airport_id );
// parse runways and generate the vertex list // parse runways/taxiways and generate the vertex list
runway_list runways; runway_list runways; runways.clear();
runways.clear(); runway_list taxiways; taxiways.clear();
string rwy_str;
for ( i = 0; i < (int)runways_raw.size(); ++i ) { for ( i = 0; i < (int)runways_raw.size(); ++i ) {
++rwy_count; ++rwy_count;
rwy_str = runways_raw[i]; string rwy_str = runways_raw[i];
vector<string> token = simgear::strutils::split( rwy_str );
TGRunway rwy; TGRunway rwy;
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(7, 4); rwy.rwy_no = token[3];
rwy.really_taxiway = (rwy.rwy_no == "xxx");
string rwy_lat = rwy_str.substr(11, 10); rwy.lat = atof( token[1].c_str() );
rwy.lat = atof( rwy_lat.c_str() );
apt_lat += rwy.lat; apt_lat += rwy.lat;
string rwy_lon = rwy_str.substr(22, 11); rwy.lon = atof( token[2].c_str() );
rwy.lon = atof( rwy_lon.c_str() );
apt_lon += rwy.lon; apt_lon += rwy.lon;
string rwy_hdg = rwy_str.substr(34, 6); rwy.heading = atof( token[4].c_str() );
rwy.heading = atof( rwy_hdg.c_str() );
string rwy_len = rwy_str.substr(41, 5); rwy.length = atoi( token[5].c_str() );
rwy.length = atoi( rwy_len.c_str() ); rwy.width = atoi( token[8].c_str() );
string rwy_width = rwy_str.substr(47, 5); string rwy_displ_threshold = token[6];
rwy.width = atoi( rwy_width.c_str() ); vector<string> displ
= simgear::strutils::split( rwy_displ_threshold, "." );
rwy.disp_thresh1 = atoi( displ[0].c_str() );
rwy.disp_thresh2 = atoi( displ[1].c_str() );
rwy.surface_flags = rwy_str.substr(53, 5); string rwy_stopway = token[7];
vector<string> stop
= simgear::strutils::split( rwy_stopway, "." );
rwy.stopway1 = atoi( stop[0].c_str() );
rwy.stopway2 = atoi( stop[1].c_str() );
rwy.end1_flags = rwy_str.substr(59, 4); rwy.lighting_flags = token[9];
rwy.surface_code = atoi( token[10].c_str() );
string rwy_disp_threshold1 = rwy_str.substr(64, 4); rwy.shoulder_code = token[11];
rwy.disp_thresh1 = atoi( rwy_disp_threshold1.c_str() ); rwy.marking_code = atoi( token[12].c_str() );
rwy.smoothness = atof( token[13].c_str() );
string rwy_stopway1 = rwy_str.substr(69, 4); rwy.dist_remaining = (atoi( token[14].c_str() ) == 1 );
rwy.stopway1 = atoi( rwy_stopway1.c_str() );
rwy.end2_flags = rwy_str.substr(74, 4);
string rwy_disp_threshold2 = rwy_str.substr(79, 4);
rwy.disp_thresh2 = atoi( rwy_disp_threshold2.c_str() );
string rwy_stopway2 = rwy_str.substr(83, 4);
rwy.stopway2 = atoi( rwy_stopway2.c_str() );
SG_LOG( SG_GENERAL, SG_DEBUG, " no = " << rwy.rwy_no); SG_LOG( SG_GENERAL, SG_DEBUG, " no = " << rwy.rwy_no);
SG_LOG( SG_GENERAL, SG_DEBUG, " lat = " << rwy_lat << " " << rwy.lat); SG_LOG( SG_GENERAL, SG_DEBUG, " lat = " << rwy.lat);
SG_LOG( SG_GENERAL, SG_DEBUG, " lon = " << rwy_lon << " " << rwy.lon); SG_LOG( SG_GENERAL, SG_DEBUG, " lon = " << rwy.lon);
SG_LOG( SG_GENERAL, SG_DEBUG, " hdg = " << rwy_hdg << " " SG_LOG( SG_GENERAL, SG_DEBUG, " hdg = " << rwy.heading);
<< rwy.heading); SG_LOG( SG_GENERAL, SG_DEBUG, " len = " << rwy.length);
SG_LOG( SG_GENERAL, SG_DEBUG, " len = " << rwy_len << " " SG_LOG( SG_GENERAL, SG_DEBUG, " width = " << rwy.width);
<< rwy.length); SG_LOG( SG_GENERAL, SG_DEBUG, " lighting = " << rwy.lighting_flags);
SG_LOG( SG_GENERAL, SG_DEBUG, " width = " << rwy_width << " " SG_LOG( SG_GENERAL, SG_DEBUG, " sfc = " << rwy.surface_code);
<< rwy.width); SG_LOG( SG_GENERAL, SG_DEBUG, " mrkgs = " << rwy.marking_code);
SG_LOG( SG_GENERAL, SG_DEBUG, " sfc = " << rwy.surface_flags); SG_LOG( SG_GENERAL, SG_DEBUG, " dspth1= " << rwy.disp_thresh1);
SG_LOG( SG_GENERAL, SG_DEBUG, " end1 = " << rwy.end1_flags); SG_LOG( SG_GENERAL, SG_DEBUG, " stop1 = " << rwy.stopway1);
SG_LOG( SG_GENERAL, SG_DEBUG, " dspth1= " << rwy_disp_threshold1 SG_LOG( SG_GENERAL, SG_DEBUG, " dspth2= " << rwy.disp_thresh2);
<< " " << rwy.disp_thresh1); SG_LOG( SG_GENERAL, SG_DEBUG, " stop2 = " << rwy.stopway2);
SG_LOG( SG_GENERAL, SG_DEBUG, " stop1 = " << rwy_stopway1 << " "
<< rwy.stopway1);
SG_LOG( SG_GENERAL, SG_DEBUG, " end2 = " << rwy.end2_flags);
SG_LOG( SG_GENERAL, SG_DEBUG, " dspth2= " << rwy_disp_threshold2
<< " " << rwy.disp_thresh2);
SG_LOG( SG_GENERAL, SG_DEBUG, " stop2 = " << rwy_stopway2 << " "
<< rwy.stopway2);
if ( rwy.really_taxiway ) {
taxiways.push_back( rwy );
} else {
runways.push_back( rwy ); runways.push_back( rwy );
} }
}
SG_LOG(SG_GENERAL, SG_INFO, "Runway count = " << runways.size() );
SG_LOG(SG_GENERAL, SG_INFO, "Taxiway count = " << taxiways.size() );
SGBucket b( apt_lon / (double)rwy_count, apt_lat / (double)rwy_count ); SGBucket b( apt_lon / (double)rwy_count, apt_lat / (double)rwy_count );
SG_LOG(SG_GENERAL, SG_INFO, b.gen_base_path() << "/" << b.gen_index_str()); SG_LOG(SG_GENERAL, SG_INFO, b.gen_base_path() << "/" << b.gen_index_str());
@ -447,52 +447,6 @@ void build_airport( string airport_id, float alt_m,
b.get_center_lat() * SGD_DEGREES_TO_RADIANS, 0 ); b.get_center_lat() * SGD_DEGREES_TO_RADIANS, 0 );
Point3D gbs_center = sgGeodToCart( center_geod ); Point3D gbs_center = sgGeodToCart( center_geod );
// parse taxiways and generate the vertex list
runway_list taxiways;
taxiways.clear();
for ( i = 0; i < (int)taxiways_raw.size(); ++i ) {
string taxi_str = taxiways_raw[i];
TGRunway taxi;
taxi.really_taxiway = true;
taxi.generated = false;
SG_LOG(SG_GENERAL, SG_INFO, taxi_str);
string taxi_lat = taxi_str.substr(11, 10);
taxi.lat = atof( taxi_lat.c_str() );
string taxi_lon = taxi_str.substr(22, 11);
taxi.lon = atof( taxi_lon.c_str() );
string taxi_hdg = taxi_str.substr(34, 6);
taxi.heading = atof( taxi_hdg.c_str() );
string taxi_len = taxi_str.substr(41, 5);
taxi.length = atoi( taxi_len.c_str() );
string taxi_width = taxi_str.substr(47, 5);
taxi.width = atoi( taxi_width.c_str() );
taxi.surface_flags = taxi_str.substr(53, 5);
SG_LOG( SG_GENERAL, SG_DEBUG, " lat = " << taxi_lat << " "
<< taxi.lat);
SG_LOG( SG_GENERAL, SG_DEBUG, " lon = " << taxi_lon << " "
<< taxi.lon);
SG_LOG( SG_GENERAL, SG_DEBUG, " hdg = " << taxi_hdg << " "
<< taxi.heading);
SG_LOG( SG_GENERAL, SG_DEBUG, " len = " << taxi_len << " "
<< taxi.length);
SG_LOG( SG_GENERAL, SG_DEBUG, " width = " << taxi_width << " "
<< taxi.width);
SG_LOG( SG_GENERAL, SG_DEBUG, " sfc = " << taxi.surface_flags);
taxiways.push_back( taxi );
}
point_list beacons; beacons.clear(); point_list beacons; beacons.clear();
for ( i = 0; i < (int)beacons_raw.size(); ++i ) { for ( i = 0; i < (int)beacons_raw.size(); ++i ) {
string beacon_str = beacons_raw[i]; string beacon_str = beacons_raw[i];
@ -568,8 +522,7 @@ void build_airport( string airport_id, float alt_m,
// First pass: generate the precision runways since these have // First pass: generate the precision runways since these have
// precidence // precidence
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); if ( runways[i].marking_code == 3 /* Precision */ ) {
if ( type_flag == "P" ) {
build_runway( runways[i], alt_m, build_runway( runways[i], alt_m,
&rwy_polys, &texparams, &accum, &rwy_polys, &texparams, &accum,
&apt_base, &apt_clearing ); &apt_base, &apt_clearing );
@ -578,10 +531,10 @@ void build_airport( string airport_id, float alt_m,
// 2nd pass: generate the non-precision and visual runways // 2nd pass: generate the non-precision and visual runways
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); if ( runways[i].marking_code == 2 /* Non-precision */
string surface_flag = runways[i].surface_flags.substr(1, 1); || runways[i].marking_code == 1 /* Visual */ )
if ( type_flag == "R" || type_flag == "V" ) { {
if ( surface_flag != "W" ) { if ( runways[i].surface_code != 13 /* Water */ ) {
// only build non-water runways // only build non-water runways
build_runway( runways[i], alt_m, build_runway( runways[i], alt_m,
&rwy_polys, &texparams, &accum, &rwy_polys, &texparams, &accum,
@ -592,11 +545,11 @@ void build_airport( string airport_id, float alt_m,
// 3rd pass: generate all remaining runways not covered in the first pass // 3rd pass: generate all remaining runways not covered in the first pass
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); if ( runways[i].marking_code != 3 /* Precision */
string surface_flag = runways[i].surface_flags.substr(1, 1); && runways[i].marking_code != 2 /* Non-precision */
if ( type_flag != string("P") && type_flag != string("R") && runways[i].marking_code != 1 /* Visual */ )
&& type_flag != string("V") ) { {
if ( surface_flag != "W" ) { if ( runways[i].surface_code != 13 ) {
// only build non-water runways // only build non-water runways
build_runway( runways[i], alt_m, build_runway( runways[i], alt_m,
&rwy_polys, &texparams, &accum, &rwy_polys, &texparams, &accum,

View file

@ -36,7 +36,6 @@
// build 3d airport // build 3d airport
void build_airport( string airport_id, float alt_m, void build_airport( string airport_id, float alt_m,
string_list& runways_raw, string_list& runways_raw,
string_list& taxiways_raw,
string_list& beacons_raw, string_list& beacons_raw,
string_list& towers_raw, string_list& towers_raw,
string_list& windsocks_raw, string_list& windsocks_raw,

View file

@ -85,7 +85,7 @@ static Point3D gen_runway_light_vector( const TGRunway& rwy_info,
// generate runway edge lighting // generate runway edge lighting
// 60 meters spacing or the next number down that divides evenly. // 60 meters spacing or the next number down that divides evenly.
static superpoly_list gen_runway_edge_lights( const TGRunway& rwy_info, static superpoly_list gen_runway_edge_lights( const TGRunway& rwy_info,
const string& kind, bool recip ) const int kind, bool recip )
{ {
point_list w_lights; w_lights.clear(); point_list w_lights; w_lights.clear();
point_list y_lights; y_lights.clear(); point_list y_lights; y_lights.clear();
@ -160,13 +160,12 @@ static superpoly_list gen_runway_edge_lights( const TGRunway& rwy_info,
TGSuperPoly white; TGSuperPoly white;
white.set_poly( lights_poly ); white.set_poly( lights_poly );
white.set_normals( normals_poly ); white.set_normals( normals_poly );
if ( kind == "H" ) {
white.set_material( "RWY_WHITE_LIGHTS" ); white.set_material( "RWY_WHITE_LIGHTS" );
} else if ( kind == "M" ) { /* other intensities for when the data file supports it
white.set_material( "RWY_WHITE_MEDIUM_LIGHTS" ); *
} else if ( kind == "L" ) { * white.set_material( "RWY_WHITE_MEDIUM_LIGHTS" );
white.set_material( "RWY_WHITE_LOW_LIGHTS" ); * white.set_material( "RWY_WHITE_LOW_LIGHTS" );
} */
lights_poly.erase(); lights_poly.erase();
normals_poly.erase(); normals_poly.erase();
@ -176,13 +175,12 @@ static superpoly_list gen_runway_edge_lights( const TGRunway& rwy_info,
TGSuperPoly yellow; TGSuperPoly yellow;
yellow.set_poly( lights_poly ); yellow.set_poly( lights_poly );
yellow.set_normals( normals_poly ); yellow.set_normals( normals_poly );
if ( kind == "H" ) {
yellow.set_material( "RWY_YELLOW_LIGHTS" ); yellow.set_material( "RWY_YELLOW_LIGHTS" );
} else if ( kind == "M" ) { /* other intensities for when the data file supports it
yellow.set_material( "RWY_YELLOW_MEDIUM_LIGHTS" ); *
} else if ( kind == "L" ) { * yellow.set_material( "RWY_YELLOW_MEDIUM_LIGHTS" );
yellow.set_material( "RWY_YELLOW_LOW_LIGHTS" ); * yellow.set_material( "RWY_YELLOW_LOW_LIGHTS" );
} */
superpoly_list result; result.clear(); superpoly_list result; result.clear();
@ -196,7 +194,7 @@ static superpoly_list gen_runway_edge_lights( const TGRunway& rwy_info,
// generate taxiway edge lighting // generate taxiway edge lighting
// 100 meters spacing or the next number down that divides evenly. // 100 meters spacing or the next number down that divides evenly.
static superpoly_list gen_taxiway_edge_lights( const TGRunway& rwy_info, static superpoly_list gen_taxiway_edge_lights( const TGRunway& rwy_info,
const string& kind, bool recip ) const int kind, bool recip )
{ {
point_list b_lights; b_lights.clear(); point_list b_lights; b_lights.clear();
point_list b_normals; b_normals.clear(); point_list b_normals; b_normals.clear();
@ -279,7 +277,7 @@ static superpoly_list gen_taxiway_edge_lights( const TGRunway& rwy_info,
// generate threshold lights for a 3 degree approach // generate threshold lights for a 3 degree approach
static superpoly_list gen_runway_threshold_lights( const TGRunway& rwy_info, static superpoly_list gen_runway_threshold_lights( const TGRunway& rwy_info,
const string& kind, const int kind,
float alt_m, bool recip ) float alt_m, bool recip )
{ {
point_list g_lights; g_lights.clear(); point_list g_lights; g_lights.clear();
@ -369,17 +367,11 @@ static superpoly_list gen_runway_threshold_lights( const TGRunway& rwy_info,
green.set_poly( lights_poly ); green.set_poly( lights_poly );
green.set_normals( normals_poly ); green.set_normals( normals_poly );
green.set_material( "RWY_GREEN_LIGHTS" ); green.set_material( "RWY_GREEN_LIGHTS" );
if ( kind == "H" ) { /* other intensities for when the data file supports it
green.set_material( "RWY_GREEN_LIGHTS" ); *
} else if ( kind == "M" ) { * green.set_material( "RWY_GREEN_MEDIUM_LIGHTS" );
green.set_material( "RWY_GREEN_MEDIUM_LIGHTS" ); * green.set_material( "RWY_GREEN_LOW_LIGHTS" );
} else if ( kind == "L" ) { */
green.set_material( "RWY_GREEN_LOW_LIGHTS" );
} else {
// this is a catch all in case there is an oddity in the input
// data
green.set_material( "RWY_GREEN_LIGHTS" );
}
lights_poly.erase(); lights_poly.erase();
normals_poly.erase(); normals_poly.erase();
@ -389,17 +381,12 @@ static superpoly_list gen_runway_threshold_lights( const TGRunway& rwy_info,
TGSuperPoly red; TGSuperPoly red;
red.set_poly( lights_poly ); red.set_poly( lights_poly );
red.set_normals( normals_poly ); red.set_normals( normals_poly );
if ( kind == "H" ) {
red.set_material( "RWY_RED_LIGHTS" ); red.set_material( "RWY_RED_LIGHTS" );
} else if ( kind == "M" ) { /* other intensities for when the data file supports it
red.set_material( "RWY_RED_MEDIUM_LIGHTS" ); *
} else if ( kind == "L" ) { * red.set_material( "RWY_RED_MEDIUM_LIGHTS" );
red.set_material( "RWY_RED_LOW_LIGHTS" ); * red.set_material( "RWY_RED_LOW_LIGHTS" );
} else { */
// this is a catch all in case there is an oddity in the input
// data
red.set_material( "RWY_RED_LIGHTS" );
}
superpoly_list result; result.clear(); superpoly_list result; result.clear();
@ -2578,82 +2565,85 @@ static superpoly_list gen_malsx( const TGRunway& rwy_info,
void gen_runway_lights( const TGRunway& rwy_info, float alt_m, void gen_runway_lights( const TGRunway& rwy_info, float alt_m,
superpoly_list &lights ) { superpoly_list &lights ) {
SG_LOG(SG_GENERAL, SG_DEBUG, "gen runway lights " << rwy_info.rwy_no << " " string lighting_flags = rwy_info.lighting_flags;
<< rwy_info.end1_flags << " " << rwy_info.end2_flags); SG_LOG( SG_GENERAL, SG_DEBUG, "gen runway lights " << rwy_info.rwy_no << " "
<< rwy_info.lighting_flags );
int vasi1 = atoi( lighting_flags.substr(0,1).c_str() );
int rwylt1 = atoi( lighting_flags.substr(1,1).c_str() );
int app1 = atoi( lighting_flags.substr(2,1).c_str() );
int vasi2 = atoi( lighting_flags.substr(3,1).c_str() );
int rwylt2 = atoi( lighting_flags.substr(4,1).c_str() );
int app2 = atoi( lighting_flags.substr(5,1).c_str() );
unsigned int i; unsigned int i;
// Make edge lighting // Make edge lighting
string edge_type = rwy_info.surface_flags.substr(3,1); if ( rwylt1 >= 2 /* Has edge lighting */ ) {
if ( edge_type != (string)"N" ) {
// forward direction // forward direction
superpoly_list s; superpoly_list s = gen_runway_edge_lights( rwy_info, rwylt1, false );
s = gen_runway_edge_lights( rwy_info, edge_type, 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] );
} }
}
if ( rwylt2 >= 2 /* Has edge lighting */ ) {
// reverse direction // reverse direction
s = gen_runway_edge_lights( rwy_info, edge_type, true ); superpoly_list s = gen_runway_edge_lights( rwy_info, rwylt2, 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] );
} }
} }
// Centerline lighting // Centerline lighting
if ( rwy_info.surface_flags.substr(0,1) == "Y" ) { if ( rwylt1 >= 4 /* Has centerline lighting */ ) {
// forward direction // forward direction
superpoly_list s; superpoly_list s = gen_runway_center_line_lights( rwy_info, false );
s = gen_runway_center_line_lights( rwy_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] );
} }
}
if ( rwylt2 >= 4 /* Has centerline lighting */ ) {
// reverse direction // reverse direction
s = gen_runway_center_line_lights( rwy_info, true ); superpoly_list s = gen_runway_center_line_lights( rwy_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] );
} }
} }
// Touchdown zone lighting // Touchdown zone lighting
if ( rwy_info.end1_flags.substr(0,1) == "Y" ) { if ( rwylt1 >= 5 /* Has touchdown zone lighting */ ) {
TGSuperPoly s = gen_touchdown_zone_lights( rwy_info, alt_m, false ); TGSuperPoly s = gen_touchdown_zone_lights( rwy_info, alt_m, false );
lights.push_back( s ); lights.push_back( s );
} }
if ( rwy_info.end2_flags.substr(0,1) == "Y" ) { if ( rwylt2 >= 5 /* Has touchdown zone lighting */ ) {
TGSuperPoly s = gen_touchdown_zone_lights( rwy_info, alt_m, true ); TGSuperPoly s = gen_touchdown_zone_lights( rwy_info, alt_m, true );
lights.push_back( s ); lights.push_back( s );
} }
// REIL lighting // REIL lighting
if ( rwy_info.end1_flags.substr(1,1) == "Y" ) { if ( rwylt1 >= 3 /* Has REIL lighting */ ) {
TGSuperPoly s = gen_reil( rwy_info, alt_m, false ); TGSuperPoly s = gen_reil( rwy_info, alt_m, false );
lights.push_back( s ); lights.push_back( s );
} }
if ( rwy_info.end2_flags.substr(1,1) == "Y" ) { if ( rwylt2 >= 3 /* Has REIL lighting */ ) {
TGSuperPoly s = gen_reil( rwy_info, alt_m, true ); TGSuperPoly s = gen_reil( rwy_info, alt_m, true );
lights.push_back( s ); lights.push_back( s );
} }
// PAPI lighting // VASI/PAPI lighting
if ( rwy_info.end1_flags.substr(2,1) == "P" ) { if ( vasi1 == 2 /* Has VASI */ ) {
TGSuperPoly s = gen_vasi( rwy_info, alt_m, false );
lights.push_back( s );
} else if ( vasi1 == 3 /* Has PAPI */ ) {
TGSuperPoly s = gen_papi( rwy_info, alt_m, false ); TGSuperPoly s = gen_papi( rwy_info, alt_m, false );
lights.push_back( s ); lights.push_back( s );
} }
if ( rwy_info.end2_flags.substr(2,1) == "P" ) { if ( vasi2 == 2 /* Has VASI */ ) {
TGSuperPoly s = gen_papi( rwy_info, alt_m, true );
lights.push_back( s );
}
// VASI lighting
if ( rwy_info.end1_flags.substr(2,1) == "V" ) {
TGSuperPoly s = gen_vasi( rwy_info, alt_m, false );
lights.push_back( s );
}
if ( rwy_info.end2_flags.substr(2,1) == "V" ) {
TGSuperPoly s = gen_vasi( rwy_info, alt_m, true ); TGSuperPoly s = gen_vasi( rwy_info, alt_m, true );
lights.push_back( s ); lights.push_back( s );
} else if ( vasi2 == 3 /* Has PAPI */ ) {
TGSuperPoly s = gen_papi( rwy_info, alt_m, true );
lights.push_back( s );
} }
// Approach lighting // Approach lighting
@ -2666,28 +2656,26 @@ void gen_runway_lights( const TGRunway& rwy_info, float alt_m,
// Please send me documentation for this configuration // Please send me documentation for this configuration
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// ALSF-I if ( app1 == 4 /* ALSF-I */ ) {
if ( rwy_info.end1_flags.substr(3,1) == "B" ) {
superpoly_list s = gen_alsf( rwy_info, alt_m, "1", false ); superpoly_list s = gen_alsf( rwy_info, alt_m, "1", 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] );
} }
} }
if ( rwy_info.end2_flags.substr(3,1) == "B" ) { if ( app2 == 4 /* ALSF-I */ ) {
superpoly_list s = gen_alsf( rwy_info, alt_m, "1", true ); superpoly_list s = gen_alsf( rwy_info, alt_m, "1", 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] );
} }
} }
// ALSF-II if ( app1 == 5 /* ALSF-II */ ) {
if ( rwy_info.end1_flags.substr(3,1) == "C" ) {
superpoly_list s = gen_alsf( rwy_info, alt_m, "2", false ); superpoly_list s = gen_alsf( rwy_info, alt_m, "2", 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] );
} }
} }
if ( rwy_info.end2_flags.substr(3,1) == "C" ) { if ( app2 == 5 /* ALSF-II */ ) {
superpoly_list s = gen_alsf( rwy_info, alt_m, "2", true ); superpoly_list s = gen_alsf( rwy_info, alt_m, "2", 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] );
@ -2704,13 +2692,13 @@ void gen_runway_lights( const TGRunway& rwy_info, float alt_m,
// Please send me documentation for this configuration // Please send me documentation for this configuration
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
if ( rwy_info.end2_flags.substr(3,1) == "D" ) { if ( app1 == 7 || app1 == 8 /* Calvert 1, 2, and 3 */ ) {
superpoly_list s = gen_calvert( rwy_info, alt_m, "1", true ); superpoly_list s = gen_calvert( rwy_info, alt_m, "1", 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] );
} }
} }
if ( rwy_info.end2_flags.substr(3,1) == "E" ) { if ( app2 == 7 || app2 == 8 /* Calvert 1, 2, and 3 */ ) {
superpoly_list s = gen_calvert( rwy_info, alt_m, "2", true ); superpoly_list s = gen_calvert( rwy_info, alt_m, "2", 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] );
@ -2725,28 +2713,26 @@ void gen_runway_lights( const TGRunway& rwy_info, float alt_m,
// data is provided in our database // data is provided in our database
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// MALS if ( app1 == -1 /* MALS not supported by data base */ ) {
if ( rwy_info.end1_flags.substr(3,1) == "G" ) {
superpoly_list s = gen_malsx( rwy_info, alt_m, "x", false ); superpoly_list s = gen_malsx( rwy_info, alt_m, "x", 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] );
} }
} }
if ( rwy_info.end2_flags.substr(3,1) == "G" ) { if ( app2 == -1 /* MALS not supported by data base */ ) {
superpoly_list s = gen_malsx( rwy_info, alt_m, "x", true ); superpoly_list s = gen_malsx( rwy_info, alt_m, "x", 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] );
} }
} }
// MALSF if ( app1 == -1 /* MALSF not supported by data base */ ) {
if ( rwy_info.end1_flags.substr(3,1) == "H" ) {
superpoly_list s = gen_malsx( rwy_info, alt_m, "F", false ); superpoly_list s = gen_malsx( rwy_info, alt_m, "F", 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] );
} }
} }
if ( rwy_info.end2_flags.substr(3,1) == "H" ) { if ( app2 == -1 /* MALSF not supported by data base */ ) {
superpoly_list s = gen_malsx( rwy_info, alt_m, "F", true ); superpoly_list s = gen_malsx( rwy_info, alt_m, "F", 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] );
@ -2761,14 +2747,13 @@ void gen_runway_lights( const TGRunway& rwy_info, float alt_m,
// This is also likely airport specific // This is also likely airport specific
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// MALSR if ( app1 == -1 /* MALSR not supported by data base */ ) {
if ( rwy_info.end1_flags.substr(3,1) == "J" ) {
superpoly_list s = gen_malsx( rwy_info, alt_m, "R", false ); superpoly_list s = gen_malsx( rwy_info, alt_m, "R", 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] );
} }
} }
if ( rwy_info.end2_flags.substr(3,1) == "J" ) { if ( app2 == -1 /* MALSR not supported by data base */ ) {
superpoly_list s = gen_malsx( rwy_info, alt_m, "R", true ); superpoly_list s = gen_malsx( rwy_info, alt_m, "R", 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] );
@ -2783,12 +2768,11 @@ void gen_runway_lights( const TGRunway& rwy_info, float alt_m,
// No clue ... // No clue ...
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// ODALS Omni-directional approach light system if ( app1 == 6 /* ODALS Omni-directional approach light system */ ) {
if ( rwy_info.end1_flags.substr(3,1) == "L" ) {
TGSuperPoly s = gen_odals( rwy_info, alt_m, false ); TGSuperPoly s = gen_odals( rwy_info, alt_m, false );
lights.push_back( s ); lights.push_back( s );
} }
if ( rwy_info.end2_flags.substr(3,1) == "L" ) { if ( app2 == 6 /* ODALS Omni-directional approach light system */ ) {
TGSuperPoly s = gen_odals( rwy_info, alt_m, true ); TGSuperPoly s = gen_odals( rwy_info, alt_m, true );
lights.push_back( s ); lights.push_back( s );
} }
@ -2802,69 +2786,65 @@ void gen_runway_lights( const TGRunway& rwy_info, float alt_m,
// SALS (Essentially ALSF-1 without the lead in rabbit lights, and // SALS (Essentially ALSF-1 without the lead in rabbit lights, and
// a shorter center bar) // a shorter center bar)
if ( rwy_info.end1_flags.substr(3,1) == "O" ) { if ( app1 == -1 /* SALS not supported by database */ ) {
superpoly_list s = gen_alsf( rwy_info, alt_m, "O", false ); superpoly_list s = gen_alsf( rwy_info, alt_m, "O", 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] );
} }
} }
if ( rwy_info.end2_flags.substr(3,1) == "O" ) { if ( app2 == -1 /* SALS not supported by database */ ) {
superpoly_list s = gen_alsf( rwy_info, alt_m, "O", true ); superpoly_list s = gen_alsf( rwy_info, alt_m, "O", 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] );
} }
} }
// SALSF if ( app1 == 3 /* SALSF */ ) {
if ( rwy_info.end1_flags.substr(3,1) == "P" ) {
superpoly_list s = gen_alsf( rwy_info, alt_m, "P", false ); superpoly_list s = gen_alsf( rwy_info, alt_m, "P", 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] );
} }
} }
if ( rwy_info.end2_flags.substr(3,1) == "P" ) { if ( app2 == 3 /* SALSF */ ) {
superpoly_list s = gen_alsf( rwy_info, alt_m, "P", true ); superpoly_list s = gen_alsf( rwy_info, alt_m, "P", 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] );
} }
} }
// SSALF if ( app1 == -1 /* SSALF not supported by database */ ) {
if ( rwy_info.end1_flags.substr(3,1) == "Q" ) {
superpoly_list s = gen_ssalx( rwy_info, alt_m, "F", false ); superpoly_list s = gen_ssalx( rwy_info, alt_m, "F", 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] );
} }
} }
if ( rwy_info.end2_flags.substr(3,1) == "Q" ) { if ( app2 == -1 /* SSALF not supported by database */ ) {
superpoly_list s = gen_ssalx( rwy_info, alt_m, "F", true ); superpoly_list s = gen_ssalx( rwy_info, alt_m, "F", 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] );
} }
} }
// SSALR if ( app1 == -1 /* SSALR not supported by database */ ) {
if ( rwy_info.end1_flags.substr(3,1) == "R" ) {
superpoly_list s = gen_ssalx( rwy_info, alt_m, "R", false ); superpoly_list s = gen_ssalx( rwy_info, alt_m, "R", 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] );
} }
} }
if ( rwy_info.end2_flags.substr(3,1) == "R" ) { if ( app2 == -1 /* SSALR not supported by database */ ) {
superpoly_list s = gen_ssalx( rwy_info, alt_m, "R", true ); superpoly_list s = gen_ssalx( rwy_info, alt_m, "R", 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] );
} }
} }
// SSALS if ( app1 == 2 /* SSALS */ ) {
if ( rwy_info.end1_flags.substr(3,1) == "S" ) {
superpoly_list s = gen_ssalx( rwy_info, alt_m, "S", false ); superpoly_list s = gen_ssalx( rwy_info, alt_m, "S", 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] );
} }
} }
if ( rwy_info.end2_flags.substr(3,1) == "S" ) { if ( app2 == 2 /* SSALS */ ) {
superpoly_list s = gen_ssalx( rwy_info, alt_m, "S", true ); superpoly_list s = gen_ssalx( rwy_info, alt_m, "S", 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] );
@ -2875,25 +2855,25 @@ void gen_runway_lights( const TGRunway& rwy_info, float alt_m,
// needed, but for those that don't (i.e. REIL, ODALS, or Edge // needed, but for those that don't (i.e. REIL, ODALS, or Edge
// lights defined but no approach lights.) // lights defined but no approach lights.)
// Make threshold lighting // Make threshold lighting
if ( rwy_info.end1_flags.substr(1,1) == "Y" || if ( rwylt1 >= 3 /* Has REIL lighting */
rwy_info.end1_flags.substr(3,1) == "L" || || app1 == 6 /* ODALS Omni-directional approach light system */
( rwy_info.surface_flags.substr(3,1) != (string)"N" && || ( rwylt1 >= 2 /* Has edge lighting */
rwy_info.end1_flags.substr(3,1) == "N") ) && app1 == 0 /* No approach lighting */ ) )
{ {
// forward direction // forward direction
superpoly_list s = gen_runway_threshold_lights( rwy_info, edge_type, superpoly_list s = gen_runway_threshold_lights( rwy_info, rwylt1,
alt_m, false ); alt_m, 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] );
} }
} }
if ( rwy_info.end2_flags.substr(1,1) == "Y" || if ( rwylt2 >= 3 /* Has REIL lighting */
rwy_info.end2_flags.substr(3,1) == "L" || || app2 == 6 /* ODALS Omni-directional approach light system */
( rwy_info.surface_flags.substr(3,1) != (string)"N" && || ( rwylt2 >= 2 /* Has edge lighting */
rwy_info.end2_flags.substr(3,1) == "N" ) ) && app2 == 0 /* No approach lighting */ ) )
{ {
// reverse direction // reverse direction
superpoly_list s = gen_runway_threshold_lights( rwy_info, edge_type, superpoly_list s = gen_runway_threshold_lights( rwy_info, rwylt1,
alt_m, true ); alt_m, 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] );
@ -2904,35 +2884,43 @@ void gen_runway_lights( const TGRunway& rwy_info, float alt_m,
// top level taxiway light generator // top level taxiway light generator
void gen_taxiway_lights( const TGRunway& taxiway_info, float alt_m, void gen_taxiway_lights( const TGRunway& taxiway_info, float alt_m,
superpoly_list &lights ) { superpoly_list &lights )
{
SG_LOG( SG_GENERAL, SG_DEBUG, "gen taxiway lights "
<< taxiway_info.rwy_no << " "
<< taxiway_info.lighting_flags );
SG_LOG(SG_GENERAL, SG_DEBUG, "gen taxiway lights " << taxiway_info.rwy_no << " " string lighting_flags = taxiway_info.lighting_flags;
<< taxiway_info.end1_flags << " " << taxiway_info.end2_flags); int rwylt1 = atoi( lighting_flags.substr(1,1).c_str() );
int rwylt2 = atoi( lighting_flags.substr(4,1).c_str() );
unsigned int i; unsigned int i;
// Centerline lighting // Centerline lighting
if ( taxiway_info.surface_flags.substr(0,1) == "Y" ) { if ( rwylt1 == 6 /* taxiway lit, assume centerline too */ ) {
// forward direction // forward direction
superpoly_list s; superpoly_list s
s = gen_taxiway_center_line_lights( taxiway_info, false ); = 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] );
} }
}
if ( rwylt2 == 6 /* taxiway lit, assume centerline too */ ) {
// reverse direction // reverse direction
s = gen_taxiway_center_line_lights( taxiway_info, true ); superpoly_list 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] );
} }
} }
// Make edge lighting // Make edge lighting
string edge_type = taxiway_info.surface_flags.substr(2,1); if ( rwylt1 == 6 /* taxiway blue lit */ ) {
if ( taxiway_info.surface_flags.substr(2,1) == "B" ) { // forward direction (blue lights are omni-directional so we
// forward direction // don't need to generate the reverse direction
superpoly_list s; superpoly_list s;
s = gen_taxiway_edge_lights( taxiway_info, "B", false ); s = gen_taxiway_edge_lights( taxiway_info, rwylt1, 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] );
} }

View file

@ -34,6 +34,8 @@
#endif #endif
#include <list> #include <list>
#include <vector>
SG_USING_STD(vector);
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -43,6 +45,7 @@
#include <simgear/bucket/newbucket.hxx> #include <simgear/bucket/newbucket.hxx>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <simgear/misc/sgstream.hxx> #include <simgear/misc/sgstream.hxx>
#include <simgear/misc/strutils.hxx>
#include <Polygon/index.hxx> #include <Polygon/index.hxx>
#include <Geometry/util.hxx> #include <Geometry/util.hxx>
@ -54,6 +57,8 @@
# include <Win32/mkdir.hpp> # include <Win32/mkdir.hpp>
#endif #endif
int nudge = 10; int nudge = 10;
@ -232,11 +237,11 @@ int main( int argc, char **argv ) {
} }
string_list runways_list; string_list runways_list;
string_list taxiways_list;
string_list beacon_list; string_list beacon_list;
string_list tower_list; string_list tower_list;
string_list windsock_list; string_list windsock_list;
vector<string> token;
string last_apt_id = ""; string last_apt_id = "";
string last_apt_info = ""; string last_apt_info = "";
string line; string line;
@ -245,34 +250,48 @@ int main( int argc, char **argv ) {
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_DEBUG, "-> '" << line << "'" );
if ( line.length() ) {
token = simgear::strutils::split( line );
SG_LOG( SG_GENERAL, SG_DEBUG, "token[0] " << token[0] );
} else {
token.clear();
}
if ( line.length() == 0 ) { if ( !line.length() ) {
// empty, skip // empty line, skip
} else if (( line[0] == '#' ) || (line[0] == '/' && line[1] == '/')) { } else if ( (token[0] == "#") || (token[0] == "//") ) {
// comment, skip // comment, skip
} else if ( line[0] == 'A' || line[0] == 'H' || line[0] == 'S' ) { } else if ( token[0] == "I" ) {
// extract some airport runway info // First line, indicates IBM (i.e. DOS line endings I
char ctmp, tmpid[32], rwy[32]; // believe.)
string id;
float lat, lon;
int elev = 0;
sscanf( line.c_str(), "%c %s %d", // move past this line and read and discard the next line
&ctmp, tmpid, &elev ); // which is the version and copyright information
id = tmpid; in.getline(tmp, 2048);
SG_LOG( SG_GENERAL, SG_DEBUG, "Next airport = " << id << " " vector<string> vers_token = simgear::strutils::split( tmp );
SG_LOG( SG_GENERAL, SG_INFO, "Data version = " << vers_token[0] );
} else if ( token[0] == "1" /* Airport */
|| token[0] == "16" /* Seaplane Base */
|| token[0] == "17" /* Heliport */ )
{
// extract some airport runway info
string rwy;
float lat, lon;
string id = token[4];
int elev = atoi( token[1].c_str() );
SG_LOG( SG_GENERAL, SG_INFO, "Next airport = " << id << " "
<< elev ); << elev );
if ( !last_apt_id.empty()) { if ( !last_apt_id.empty()) {
if ( runways_list.size() ) { if ( runways_list.size() ) {
sscanf( runways_list[0].c_str(), "%c %s %s %f %f", vector<string> rwy_token
&ctmp, tmpid, rwy, &lat, &lon ); = simgear::strutils::split( runways_list[0] );
} rwy = token[3];
lat = atof( token[1].c_str() );
lon = atof( token[2].c_str() );
if ( lon >= min_lon && lon <= max_lon &&
lat >= min_lat && lat <= max_lat )
{
if ( airport_id.length() && airport_id == last_apt_id ) { if ( airport_id.length() && airport_id == last_apt_id ) {
ready_to_go = true; ready_to_go = true;
} else if ( start_id.length() && start_id == last_apt_id ) { } else if ( start_id.length() && start_id == last_apt_id ) {
@ -290,9 +309,11 @@ int main( int argc, char **argv ) {
// process previous record // process previous record
// process_airport(last_apt_id, runways_list, argv[2]); // process_airport(last_apt_id, runways_list, argv[2]);
try { try {
build_airport( last_apt_id, elev * SG_FEET_TO_METER, build_airport( last_apt_id,
runways_list, taxiways_list, elev * SG_FEET_TO_METER,
beacon_list, tower_list, runways_list,
beacon_list,
tower_list,
windsock_list, windsock_list,
work_dir, elev_src ); work_dir, elev_src );
} catch (sg_exception &e) { } catch (sg_exception &e) {
@ -303,37 +324,44 @@ int main( int argc, char **argv ) {
<< e.getMessage() ); << e.getMessage() );
exit(-1); exit(-1);
} }
if(airport_id.length()) ready_to_go = false; if ( airport_id.length() ) {
ready_to_go = false;
}
} }
} else { } else {
if(!airport_id.length()) { if(!airport_id.length()) {
SG_LOG(SG_GENERAL, SG_INFO, "Skipping airport " << id); SG_LOG(SG_GENERAL, SG_INFO,
"ERRO: No runways, skipping = " << id);
} }
} }
} }
last_apt_id = id; last_apt_id = id;
last_apt_info = line; 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();
beacon_list.clear(); beacon_list.clear();
tower_list.clear(); tower_list.clear();
windsock_list.clear(); windsock_list.clear();
} else if ( line[0] == 'R' ) { } else if ( token[0] == "10" ) {
// runway entry // runway entry
runways_list.push_back(line); runways_list.push_back(line);
} else if ( line[0] == 'T' ) { } else if ( token[0] == "18" ) {
// taxiway entry
taxiways_list.push_back(line);
} else if ( line[0] == 'B' ) {
// beacon entry // beacon entry
beacon_list.push_back(line); beacon_list.push_back(line);
} else if ( line[0] == 'C' ) { } else if ( token[0] == "14" ) {
// control tower entry // control tower entry
tower_list.push_back(line); tower_list.push_back(line);
} else if ( line[0] == 'W' ) { } else if ( token[0] == "19" ) {
// control tower entry // windsock entry
windsock_list.push_back(line); windsock_list.push_back(line);
} else if ( token[0] == "15" ) {
// ignore custom startup locations
} else if ( token[0] == "50" || token[0] == "51" || token[0] == "52"
|| token[0] == "53" || token[0] == "54" || token[0] == "55"
|| token[0] == "56" )
{
// ignore frequency entries
} else { } else {
SG_LOG( SG_GENERAL, SG_ALERT, SG_LOG( SG_GENERAL, SG_ALERT,
"Unknown line in file: " << line ); "Unknown line in file: " << line );
@ -354,9 +382,6 @@ int main( int argc, char **argv ) {
&ctmp, tmpid, rwy, &lat, &lon ); &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 ) { if ( start_id.length() && start_id == last_apt_id ) {
ready_to_go = true; ready_to_go = true;
} }
@ -373,8 +398,9 @@ int main( int argc, char **argv ) {
// process_airport(last_apt_id, runways_list, argv[2]); // process_airport(last_apt_id, runways_list, argv[2]);
try { try {
build_airport( last_apt_id, elev * SG_FEET_TO_METER, build_airport( last_apt_id, elev * SG_FEET_TO_METER,
runways_list, taxiways_list, runways_list,
beacon_list, tower_list, beacon_list,
tower_list,
windsock_list, windsock_list,
work_dir, elev_src ); work_dir, elev_src );
} catch (sg_exception &e) { } catch (sg_exception &e) {
@ -385,7 +411,6 @@ int main( int argc, char **argv ) {
<< e.getMessage() ); << e.getMessage() );
exit(-1); exit(-1);
} }
}
} else { } else {
SG_LOG(SG_GENERAL, SG_INFO, "Skipping airport " << id); SG_LOG(SG_GENERAL, SG_INFO, "Skipping airport " << id);
} }

View file

@ -47,9 +47,12 @@ struct TGRunway {
double stopway1; double stopway1;
double stopway2; double stopway2;
string surface_flags; string lighting_flags;
string end1_flags; int surface_code;
string end2_flags; string shoulder_code;
int marking_code;
double smoothness;
bool dist_remaining;
TGPolygon threshold; TGPolygon threshold;
TGPolygon tens, tens_margin, ones, ones_margin; TGPolygon tens, tens_margin, ones, ones_margin;

View file

@ -94,7 +94,8 @@ void gen_visual_rwy( const TGRunway& rwy_info,
double length = rwy_info.length / 2.0 + 2.0; double length = rwy_info.length / 2.0 + 2.0;
if ( length < 1150 ) { if ( length < 1150 ) {
SG_LOG(SG_GENERAL, SG_ALERT, SG_LOG(SG_GENERAL, SG_ALERT,
"This runway is not long enough for visual markings!"); "This runway is not long enough for visual markings = "
<< rwy_info.length );
} }
double start1_pct = 0.0; double start1_pct = 0.0;