1
0
Fork 0

Implement individual runway markings for both ends.

Simplified code a lot, removed runway-specific files with
a lot of duplicate code. Put marking logic into
functions.
This commit is contained in:
Christian Schmitt 2011-09-13 18:28:42 +02:00
parent 8ac29ac8a8
commit 66fc88c666
4 changed files with 200 additions and 513 deletions

View file

@ -275,7 +275,7 @@ static void build_runway( const TGRunway& rwy_info,
} }
SG_LOG(SG_GENERAL, SG_DEBUG, "marking code = " << rwy_info.marking_code); SG_LOG(SG_GENERAL, SG_DEBUG, "marking code = " << rwy_info.marking_code1 << " / " << rwy_info.marking_code2);
if ( rwy_info.really_taxiway ) { if ( rwy_info.really_taxiway ) {
gen_taxiway( rwy_info, alt_m, material, gen_taxiway( rwy_info, alt_m, material,
@ -286,22 +286,13 @@ static void build_runway( const TGRunway& rwy_info,
{ {
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 ( rwy_info.marking_code == 3 /* Precision */ ) { } else if ( rwy_info.marking_code1 == 3 ||
// precision runway markings rwy_info.marking_code1 == 2 ||
rwy_info.marking_code1 == 1 ||
rwy_info.marking_code1 == 0 ) {
gen_rwy( rwy_info, alt_m, material, gen_rwy( rwy_info, alt_m, material,
rwy_polys, texparams, accum ); rwy_polys, texparams, accum );
} else if ( rwy_info.marking_code == 2 /* Non-precision */ ) {
// non-precision runway markings
gen_rwy( rwy_info, alt_m, material,
rwy_polys, texparams, accum );
} else if ( rwy_info.marking_code == 1 /* Visual */ ) {
// visual runway markings
gen_rwy( rwy_info, alt_m, material,
rwy_polys, texparams, accum );
} else if ( rwy_info.marking_code == 0 /* No known markings, lets assume Visual */ ) {
// visual runway markings
gen_rwy( rwy_info, alt_m, material,
rwy_polys, texparams, accum );
} else if ( surface_code == 13 /* Water buoys */ ) { } else if ( surface_code == 13 /* Water buoys */ ) {
// do nothing for now. // do nothing for now.
} else { } else {
@ -309,7 +300,7 @@ static void build_runway( const TGRunway& rwy_info,
// 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 = " << SG_LOG( SG_GENERAL, SG_ALERT, "Unknown runway code = " <<
rwy_info.marking_code ); rwy_info.marking_code1 );
throw sg_exception("Unknown runway code in build.cxx:build_airport()"); throw sg_exception("Unknown runway code in build.cxx:build_airport()");
} }
@ -380,6 +371,10 @@ void build_airport( string airport_id, float alt_m,
rwy.really_taxiway = (rwy.rwy_no1 == "xxx"); rwy.really_taxiway = (rwy.rwy_no1 == "xxx");
rwy.generated = false; rwy.generated = false;
rwy.surface_code = atoi( token[2].c_str() );
rwy.shoulder_code = token[3];
rwy.smoothness = atof( token[4].c_str() );
//first runway end coordinates //first runway end coordinates
double lat_1 = atof( token[9].c_str() ); double lat_1 = atof( token[9].c_str() );
double lon_1 = atof( token[10].c_str() ); double lon_1 = atof( token[10].c_str() );
@ -422,11 +417,11 @@ void build_airport( string airport_id, float alt_m,
rwy.stopway1 = atoi( token[12].c_str() ) * SG_METER_TO_FEET; rwy.stopway1 = atoi( token[12].c_str() ) * SG_METER_TO_FEET;
rwy.stopway2 = atoi( token[21].c_str() ) * SG_METER_TO_FEET; rwy.stopway2 = atoi( token[21].c_str() ) * SG_METER_TO_FEET;
rwy.marking_code1 = atoi( token[13].c_str() );
rwy.marking_code2 = atoi( token[22].c_str() );
rwy.lighting_flags = token[9]; rwy.lighting_flags = token[9];
rwy.surface_code = atoi( token[2].c_str() );
rwy.shoulder_code = token[3];
rwy.marking_code = atoi( token[13].c_str() );
rwy.smoothness = atof( token[4].c_str() );
rwy.dist_remaining = (atoi( token[14].c_str() ) == 1 ); rwy.dist_remaining = (atoi( token[14].c_str() ) == 1 );
if (token.size()>15) { if (token.size()>15) {
@ -446,7 +441,7 @@ void build_airport( string airport_id, float alt_m,
SG_LOG( SG_GENERAL, SG_DEBUG, " width = " << rwy.width); SG_LOG( SG_GENERAL, SG_DEBUG, " width = " << rwy.width);
SG_LOG( SG_GENERAL, SG_DEBUG, " lighting = " << rwy.lighting_flags); SG_LOG( SG_GENERAL, SG_DEBUG, " lighting = " << rwy.lighting_flags);
SG_LOG( SG_GENERAL, SG_DEBUG, " sfc = " << rwy.surface_code); SG_LOG( SG_GENERAL, SG_DEBUG, " sfc = " << rwy.surface_code);
SG_LOG( SG_GENERAL, SG_DEBUG, " mrkgs = " << rwy.marking_code); SG_LOG( SG_GENERAL, SG_DEBUG, " mrkgs1/2 = " << rwy.marking_code1 << " / " << rwy.marking_code2);
SG_LOG( SG_GENERAL, SG_DEBUG, " dspth1= " << rwy.disp_thresh1); SG_LOG( SG_GENERAL, SG_DEBUG, " dspth1= " << rwy.disp_thresh1);
SG_LOG( SG_GENERAL, SG_DEBUG, " stop1 = " << rwy.stopway1); SG_LOG( SG_GENERAL, SG_DEBUG, " stop1 = " << rwy.stopway1);
SG_LOG( SG_GENERAL, SG_DEBUG, " dspth2= " << rwy.disp_thresh2); SG_LOG( SG_GENERAL, SG_DEBUG, " dspth2= " << rwy.disp_thresh2);
@ -528,13 +523,11 @@ void build_airport( string airport_id, float alt_m,
} }
} }
TGSuperPoly sp;
TGTexParams tp;
// 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 ) {
if ( runways[i].marking_code == 3 /* Precision */ ) { if ( runways[i].marking_code1 == 3 /* Precision */ ) {
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 );
@ -543,8 +536,8 @@ 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 ) {
if ( runways[i].marking_code == 2 /* Non-precision */ if ( runways[i].marking_code1 == 2 /* Non-precision */
|| runways[i].marking_code == 1 /* Visual */ ) || runways[i].marking_code1 == 1 /* Visual */ )
{ {
if ( runways[i].surface_code != 13 /* Water */ ) { if ( runways[i].surface_code != 13 /* Water */ ) {
// only build non-water runways // only build non-water runways
@ -557,9 +550,9 @@ 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 ) {
if ( runways[i].marking_code != 3 /* Precision */ if ( runways[i].marking_code1 != 3 /* Precision */
&& runways[i].marking_code != 2 /* Non-precision */ && runways[i].marking_code1 != 2 /* Non-precision */
&& runways[i].marking_code != 1 /* Visual */ ) && runways[i].marking_code1 != 1 /* Visual */ )
{ {
if ( runways[i].surface_code != 6 /* Asphalt Helipad */ && if ( runways[i].surface_code != 6 /* Asphalt Helipad */ &&
runways[i].surface_code != 7 /* Concrete Helipad */ && runways[i].surface_code != 7 /* Concrete Helipad */ &&
@ -577,37 +570,6 @@ void build_airport( string airport_id, float alt_m,
// 4th pass: generate all taxiways // 4th pass: generate all taxiways
#if 0
// we want to generate in order of largest size first so this will
// look a little weird, but that's all I'm doing, otherwise a
// simple list traversal would work fine.
bool done = false;
while ( !done ) {
// find the largest taxiway
int largest_idx = -1;
double max_size = 0;
for ( i = 0; i < (int)taxiways.size(); ++i ) {
SG_LOG( SG_GENERAL, SG_DEBUG, "taxiway i = " << i );
double size = taxiways[i].length * taxiways[i].width;
if ( size > max_size && !taxiways[i].generated ) {
SG_LOG( SG_GENERAL, SG_DEBUG, "taxiway max i = " << i );
max_size = size;
largest_idx = i;
}
}
if ( largest_idx >= 0 ) {
SG_LOG( SG_GENERAL, SG_DEBUG, "generating " << largest_idx );
build_runway( taxiways[largest_idx], alt_m,
&rwy_polys, &texparams, &accum,
&apt_base, &apt_clearing );
taxiways[largest_idx].generated = true;
} else {
SG_LOG( SG_GENERAL, SG_DEBUG, "done with taxiways." );
done = true;
}
}
#else
/* Ralf Gerlich: Generate Taxiways in specified order from bottom to top */ /* Ralf Gerlich: Generate Taxiways in specified order from bottom to top */
for ( i=0; i<taxiways.size(); ++i ) { for ( i=0; i<taxiways.size(); ++i ) {
SG_LOG( SG_GENERAL, SG_DEBUG, "generating " << i ); SG_LOG( SG_GENERAL, SG_DEBUG, "generating " << i );
@ -616,7 +578,6 @@ void build_airport( string airport_id, float alt_m,
&apt_base, &apt_clearing ); &apt_base, &apt_clearing );
taxiways[i].generated = true; taxiways[i].generated = true;
} }
#endif
// Now generate small surface for each beacon // Now generate small surface for each beacon
TGPolygon obj_base, obj_safe_base; TGPolygon obj_base, obj_safe_base;

View file

@ -51,7 +51,8 @@ struct TGRunway {
std::string lighting_flags; std::string lighting_flags;
int surface_code; int surface_code;
std::string shoulder_code; std::string shoulder_code;
int marking_code; int marking_code1;
int marking_code2;
double smoothness; double smoothness;
bool dist_remaining; bool dist_remaining;

View file

@ -64,15 +64,7 @@ void gen_number_block( const TGRunway& rwy_info,
// printf("tex1 = '%s' tex2 = '%s'\n", tex1, tex2); // printf("tex1 = '%s' tex2 = '%s'\n", tex1, tex2);
if ( num < 10 ) { if ( num < 10 || num == 11 ) {
gen_runway_section( rwy_info, poly,
start_pct, end_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
heading,
material, tex1,
rwy_polys, texparams, accum );
} else if ( num == 11 ) {
gen_runway_section( rwy_info, poly, gen_runway_section( rwy_info, poly,
start_pct, end_pct, start_pct, end_pct,
0.0, 1.0, 0.0, 1.0,

View file

@ -18,8 +18,6 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
// //
// $Id: rwy_gen.cxx,v 1.18 2004-11-19 22:25:49 curt Exp $
//
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/constants.h> #include <simgear/constants.h>
@ -31,7 +29,87 @@
using std::string; using std::string;
struct marking
{
const char* tex;
int size;
};
void gen_prec_marking( const TGRunway& rwy_info,
const TGPolygon& runway,
double &start1_pct, double &end1_pct,
double heading,
const string& material,
superpoly_list *rwy_polys,
texparams_list *texparams,
TGPolygon *accum) {
// Precision runway sections from after the designation number
// onwards to the middle (one half).
// Set order of sections and their corresponding size
static const struct marking prec_rw[] = {
{ "tz_three", 380 },
{ "rest", 200 },
{ "aim", 400 },
{ "tz_two_a", 400 },
{ "rest", 200 },
{ "tz_two_b", 200 },
{ "rest", 200 },
{ "tz_one_a", 400 },
{ "rest", 200 },
{ "tz_one_b", 200 }
};
double length = rwy_info.length / 2.0 + 2.0;
for ( int i=0; i < sizeof prec_rw / sizeof prec_rw[0]; ++i) {
SG_LOG(SG_GENERAL, SG_INFO, "PREC_RW = " << prec_rw[i].tex << " lenght: " << prec_rw[i].size);
start1_pct = end1_pct;
end1_pct = start1_pct + ( prec_rw[i].size / length );
gen_runway_section( rwy_info, runway,
start1_pct, end1_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
heading,
material, prec_rw[i].tex,
rwy_polys, texparams, accum );
}
}
void gen_non_prec_marking( const TGRunway& rwy_info,
const TGPolygon& runway,
double &start1_pct, double &end1_pct,
double heading,
const string& material,
superpoly_list *rwy_polys,
texparams_list *texparams,
TGPolygon *accum) {
// Non-precision runway sections from after the designation number
// onwards to the middle (one half).
// Set order of sections and their corresponding size
static const struct marking non_prec_rw[] = {
{ "centerline", 200 },
{ "aim", 400 }
};
double length = rwy_info.length / 2.0 + 2.0;
for ( int i=0; i < sizeof non_prec_rw / sizeof non_prec_rw[0]; ++i) {
SG_LOG(SG_GENERAL, SG_INFO, "NON_PREC_RW = " << non_prec_rw[i].tex << " lenght: " << non_prec_rw[i].size);
start1_pct = end1_pct;
end1_pct = start1_pct + ( non_prec_rw[i].size / length );
gen_runway_section( rwy_info, runway,
start1_pct, end1_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
heading,
material, non_prec_rw[i].tex,
rwy_polys, texparams, accum );
}
}
// generate a runway. The routine modifies // generate a runway. The routine modifies
// rwy_polys, texparams, and accum. For specific details and // rwy_polys, texparams, and accum. For specific details and
// dimensions of precision runway markings, please refer to FAA // dimensions of precision runway markings, please refer to FAA
@ -56,42 +134,37 @@ void gen_rwy( const TGRunway& rwy_info,
2 * SG_FEET_TO_METER, 2 * SG_FEET_TO_METER,
2 * SG_FEET_TO_METER ); 2 * SG_FEET_TO_METER );
// runway half "a" (actually the reverse half) TGPolygon runway_half;
TGPolygon runway_a;
runway_a.erase();
runway_a.add_node( 0, runway.get_pt(0, 0) );
runway_a.add_node( 0, runway.get_pt(0, 1) );
runway_a.add_node( 0, runway.get_pt(0, 2) );
runway_a.add_node( 0, runway.get_pt(0, 5) );
for ( int rwhalf=1; rwhalf<3; ++rwhalf ){
// runway half "b" (actually the forward half) if (rwhalf == 1) {
TGPolygon runway_b;
runway_b.erase(); //Create first half of the runway (first entry in apt.dat)
runway_b.add_node( 0, runway.get_pt(0, 3) ); // runway half "b" (actually the first half)
runway_b.add_node( 0, runway.get_pt(0, 4) ); runway_half.erase();
runway_b.add_node( 0, runway.get_pt(0, 5) ); runway_half.add_node( 0, runway.get_pt(0, 3) );
runway_b.add_node( 0, runway.get_pt(0, 2) ); runway_half.add_node( 0, runway.get_pt(0, 4) );
runway_half.add_node( 0, runway.get_pt(0, 5) );
runway_half.add_node( 0, runway.get_pt(0, 2) );
}
else if (rwhalf == 2) {
// runway half "a" (actually the second half in apt.dat)
runway_half.erase();
runway_half.add_node( 0, runway.get_pt(0, 0) );
runway_half.add_node( 0, runway.get_pt(0, 1) );
runway_half.add_node( 0, runway.get_pt(0, 2) );
runway_half.add_node( 0, runway.get_pt(0, 5) );
}
Point3D p; Point3D p;
SG_LOG(SG_GENERAL, SG_DEBUG, "raw runway pts (a half)"); SG_LOG(SG_GENERAL, SG_DEBUG, "raw runway half pts (run " << rwhalf << ")");
for ( i = 0; i < runway_a.contour_size( 0 ); ++i ) { for ( i = 0; i < runway_half.contour_size( 0 ); ++i ) {
p = runway_a.get_pt(0, i); p = runway_half.get_pt(0, i);
SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p); SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
} }
SG_LOG(SG_GENERAL, SG_DEBUG, "raw runway pts (b half)");
for ( i = 0; i < runway_b.contour_size( 0 ); ++i ) {
p = runway_b.get_pt(0, i);
SG_LOG(SG_GENERAL, SG_DEBUG, " point = " << p);
}
//
// Setup some variables and values to help us chop up the runway
// into its various sections
//
TGSuperPoly sp;
TGTexParams tp;
// we add 2' to the length for texture overlap. This puts the // we add 2' to the length for texture overlap. This puts the
// lines on the texture back to the edge of the runway where they // lines on the texture back to the edge of the runway where they
@ -104,70 +177,36 @@ void gen_rwy( const TGRunway& rwy_info,
} }
double start1_pct = 0.0; double start1_pct = 0.0;
double start2_pct = 0.0;
double end1_pct = 0.0; double end1_pct = 0.0;
double end2_pct = 0.0; double disp_thresh = 0.0;
double heading = 0.0;
double stopway = 0.0;
string rwname;
// //
// Displaced threshold if it exists // Displaced threshold if it exists
// //
if ( rwy_info.disp_thresh1 > 0.0 ) { if (rwhalf == 1) {
SG_LOG( SG_GENERAL, SG_INFO, "Forward displaced threshold = " disp_thresh = rwy_info.disp_thresh1;
<< rwy_info.disp_thresh1 ); heading = rwy_info.heading + 180.0;
rwname = rwy_info.rwy_no1;
// reserve 90' for final arrows stopway = rwy_info.stopway1;
double thresh = rwy_info.disp_thresh1 - 90.0;
// number of full center arrows
int count = (int)(thresh / 200.0);
// length of starting partial arrow
double part_len = thresh - ( count * 200.0 );
double tex_pct = (200.0 - part_len) / 200.0;
// starting (possibly partial chunk)
start2_pct = end2_pct;
end2_pct = start2_pct + ( part_len / length );
gen_runway_section( rwy_info, runway_b,
start2_pct, end2_pct,
0.0, 1.0,
0.0, 1.0, tex_pct, 1.0,
rwy_info.heading + 180.0,
material, "dspl_thresh",
rwy_polys, texparams, accum );
// main chunks
for ( i = 0; i < count; ++i ) {
start2_pct = end2_pct;
end2_pct = start2_pct + ( 200.0 / length );
gen_runway_section( rwy_info, runway_b,
start2_pct, end2_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading + 180.0,
material, "dspl_thresh",
rwy_polys, texparams, accum );
}
// final arrows
start2_pct = end2_pct;
end2_pct = start2_pct + ( 90.0 / length );
gen_runway_section( rwy_info, runway_b,
start2_pct, end2_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading + 180.0,
material, "dspl_arrows",
rwy_polys, texparams, accum );
} }
else if (rwhalf == 2) {
if ( rwy_info.disp_thresh2 > 0.0 ) { disp_thresh = rwy_info.disp_thresh2;
SG_LOG( SG_GENERAL, SG_INFO, "Reverse displaced threshold = " heading = rwy_info.heading;
<< rwy_info.disp_thresh2 ); rwname = rwy_info.rwy_no2;
stopway = rwy_info.stopway2;
}
if ( disp_thresh > 0.0 ) {
SG_LOG( SG_GENERAL, SG_INFO, "Displaced threshold for RW side " << rwhalf << " is "
<< disp_thresh );
// reserve 90' for final arrows // reserve 90' for final arrows
double thresh = rwy_info.disp_thresh2 - 90.0; double thresh = disp_thresh - 90.0;
// number of full center arrows // number of full center arrows
int count = (int)(thresh / 200.0); int count = (int)(thresh / 200.0);
@ -179,11 +218,11 @@ void gen_rwy( const TGRunway& rwy_info,
// starting (possibly partial chunk) // starting (possibly partial chunk)
start1_pct = end1_pct; start1_pct = end1_pct;
end1_pct = start1_pct + ( part_len / length ); end1_pct = start1_pct + ( part_len / length );
gen_runway_section( rwy_info, runway_a, gen_runway_section( rwy_info, runway_half,
start1_pct, end1_pct, start1_pct, end1_pct,
0.0, 1.0, 0.0, 1.0,
0.0, 1.0, tex_pct, 1.0, 0.0, 1.0, tex_pct, 1.0,
rwy_info.heading, heading,
material, "dspl_thresh", material, "dspl_thresh",
rwy_polys, texparams, accum ); rwy_polys, texparams, accum );
@ -191,11 +230,11 @@ void gen_rwy( const TGRunway& rwy_info,
for ( i = 0; i < count; ++i ) { for ( i = 0; i < count; ++i ) {
start1_pct = end1_pct; start1_pct = end1_pct;
end1_pct = start1_pct + ( 200.0 / length ); end1_pct = start1_pct + ( 200.0 / length );
gen_runway_section( rwy_info, runway_a, gen_runway_section( rwy_info, runway_half,
start1_pct, end1_pct, start1_pct, end1_pct,
0.0, 1.0, 0.0, 1.0,
0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0,
rwy_info.heading, heading,
material, "dspl_thresh", material, "dspl_thresh",
rwy_polys, texparams, accum ); rwy_polys, texparams, accum );
} }
@ -203,94 +242,63 @@ void gen_rwy( const TGRunway& rwy_info,
// final arrows // final arrows
start1_pct = end1_pct; start1_pct = end1_pct;
end1_pct = start1_pct + ( 90.0 / length ); end1_pct = start1_pct + ( 90.0 / length );
gen_runway_section( rwy_info, runway_a, gen_runway_section( rwy_info, runway_half,
start1_pct, end1_pct, start1_pct, end1_pct,
0.0, 1.0, 0.0, 1.0,
0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0,
rwy_info.heading, heading,
material, "dspl_arrows", material, "dspl_arrows",
rwy_polys, texparams, accum ); rwy_polys, texparams, accum );
} }
if ((rwhalf == 1 && !rwy_info.marking_code1 == 0) || (rwhalf == 2 && !rwy_info.marking_code2 == 0)){
// //
// Threshold // Threshold
// //
start1_pct = end1_pct; start1_pct = end1_pct;
end1_pct = start1_pct + ( 202.0 / length ); end1_pct = start1_pct + ( 202.0 / length );
gen_runway_section( rwy_info, runway_a, gen_runway_section( rwy_info, runway_half,
start1_pct, end1_pct, start1_pct, end1_pct,
0.0, 1.0, 0.0, 1.0,
0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0,
rwy_info.heading, heading,
material, "threshold", material, "threshold",
rwy_polys, texparams, accum ); rwy_polys, texparams, accum );
start2_pct = end2_pct;
end2_pct = start2_pct + ( 202.0 / length );
gen_runway_section( rwy_info, runway_b,
start2_pct, end2_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading + 180.0,
material, "threshold",
rwy_polys, texparams, accum );
// //
// Runway designation letter // Runway designation letter
// //
int len = rwy_info.rwy_no1.length(); int len = rwname.length();
string letter1 = ""; string letter = "";
string letter2 = "";
for ( i = 0; i < len; ++i ) { for ( i = 0; i < len; ++i ) {
string tmp = rwy_info.rwy_no1.substr(i, 1); string tmp = rwname.substr(i, 1);
if ( tmp == "L" ) { if ( tmp == "L" ) {
letter1 = "L"; letter = "L";
} else if ( tmp == "R" ) { } else if ( tmp == "R" ) {
letter1 = "R"; letter = "R";
} else if ( tmp == "C" ) { } else if ( tmp == "C" ) {
letter1 = "C"; letter = "C";
} }
} }
len = rwy_info.rwy_no2.length();
for ( i = 0; i < len; ++i ) {
string tmp = rwy_info.rwy_no2.substr(i, 1);
if ( tmp == "L" ) {
letter2 = "L";
} else if ( tmp == "R" ) {
letter2 = "R";
} else if ( tmp == "C" ) {
letter2 = "C";
}
}
SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation1 = " << rwy_info.rwy_no1); SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation1 = " << rwname);
SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation letter1 = " << letter1); SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation letter1 = " << letter);
SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation2 = " << rwy_info.rwy_no2);
SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation letter2 = " << letter2);
//TODO: add empty airport end generation if ( !letter.empty() ) {
if ( !letter1.empty() && !letter2.empty() ) {
start1_pct = end1_pct; start1_pct = end1_pct;
end1_pct = start1_pct + ( 90.0 / length ); end1_pct = start1_pct + ( 90.0 / length );
gen_runway_section( rwy_info, runway_a, gen_runway_section( rwy_info, runway_half,
start1_pct, end1_pct, start1_pct, end1_pct,
0.0, 1.0, 0.0, 1.0,
0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0,
rwy_info.heading, heading,
material, letter2, material, letter,
rwy_polys, texparams, accum );
start2_pct = end2_pct;
end2_pct = start2_pct + ( 90.0 / length );
gen_runway_section( rwy_info, runway_b,
start2_pct, end2_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading + 180.0,
material, letter1,
rwy_polys, texparams, accum ); rwy_polys, texparams, accum );
} }
@ -298,301 +306,43 @@ void gen_rwy( const TGRunway& rwy_info,
// Runway designation number(s) // Runway designation number(s)
// //
len = rwy_info.rwy_no1.length(); len = rwname.length();
string snum1 = rwy_info.rwy_no1; string snum = rwname;
for ( i = 0; i < len; ++i ) { for ( i = 0; i < len; ++i ) {
string tmp = rwy_info.rwy_no1.substr(i, 1); string tmp = rwname.substr(i, 1);
if ( tmp == "L" || tmp == "R" || tmp == "C" || tmp == " " ) { if ( tmp == "L" || tmp == "R" || tmp == "C" || tmp == " " ) {
snum1 = rwy_info.rwy_no1.substr(0, i); snum = rwname.substr(0, i);
} }
} }
len = rwy_info.rwy_no2.length(); SG_LOG(SG_GENERAL, SG_INFO, "Runway num = '" << snum );
string snum2 = rwy_info.rwy_no2;
for ( i = 0; i < len; ++i ) {
string tmp = rwy_info.rwy_no2.substr(i, 1);
if ( tmp == "L" || tmp == "R" || tmp == "C" || tmp == " " ) {
snum2 = rwy_info.rwy_no2.substr(0, i);
}
}
SG_LOG(SG_GENERAL, SG_INFO, "Runway num1 = '" << snum1 << "'");
SG_LOG(SG_GENERAL, SG_INFO, "Runway num2 = '" << snum2 << "'");
int num1 = atoi( snum1.c_str() ); int num = atoi( snum.c_str() );
int num2 = atoi( snum2.c_str() ); while ( num <= 0 ) {
while ( num1 <= 0 ) { num += 36;
num1 += 36;
}
start2_pct = end2_pct;
end2_pct = start2_pct + ( 80.0 / length );
gen_number_block( rwy_info, material, runway_b, rwy_info.heading + 180.0,
num1, start2_pct, end2_pct, rwy_polys, texparams, accum );
while ( num2 <= 0 ) {
num2 += 36;
} }
start1_pct = end1_pct; start1_pct = end1_pct;
end1_pct = start1_pct + ( 80.0 / length ); end1_pct = start1_pct + ( 80.0 / length );
gen_number_block( rwy_info, material, runway_a, rwy_info.heading, gen_number_block( rwy_info, material, runway_half, heading,
num2, start1_pct, end1_pct, rwy_polys, texparams, accum ); num, start1_pct, end1_pct, rwy_polys, texparams, accum );
}
//
// Touch down zone x3
//
start1_pct = end1_pct; if ((rwhalf == 1 && rwy_info.marking_code1 == 3) || (rwhalf == 2 && rwy_info.marking_code2 == 3)){
end1_pct = start1_pct + ( 380 / length ); gen_prec_marking( rwy_info, runway_half,
gen_runway_section( rwy_info, runway_a, start1_pct, end1_pct,
start1_pct, end1_pct, heading, material,
0.0, 1.0, rwy_polys, texparams, accum );
0.0, 1.0, 0.0, 1.0,
rwy_info.heading,
material, "tz_three",
rwy_polys, texparams, accum );
start2_pct = end2_pct;
end2_pct = start2_pct + ( 380 / length );
gen_runway_section( rwy_info, runway_b,
start2_pct, end2_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading + 180.0,
material, "tz_three",
rwy_polys, texparams, accum );
// add a section of center stripe
start1_pct = end1_pct;
end1_pct = start1_pct + ( 200 / length );
gen_runway_section( rwy_info, runway_a,
start1_pct, end1_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading,
material, "rest",
rwy_polys, texparams, accum );
start2_pct = end2_pct;
end2_pct = start2_pct + ( 200 / length );
gen_runway_section( rwy_info, runway_b,
start2_pct, end2_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading + 180.0,
material, "rest",
rwy_polys, texparams, accum );
//
// Aiming point
//
start1_pct = end1_pct;
end1_pct = start1_pct + ( 400 / length );
gen_runway_section( rwy_info, runway_a,
start1_pct, end1_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading,
material, "aim",
rwy_polys, texparams, accum );
start2_pct = end2_pct;
end2_pct = start2_pct + ( 400 / length );
gen_runway_section( rwy_info, runway_b,
start2_pct, end2_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading + 180.0,
material, "aim",
rwy_polys, texparams, accum );
//
// Touch down zone x2 (first)
//
if ( end1_pct < 1.0 ) {
start1_pct = end1_pct;
end1_pct = start1_pct + ( 400 / length );
gen_runway_section( rwy_info, runway_a,
start1_pct, end1_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading,
material, "tz_two_a",
rwy_polys, texparams, accum );
} }
if ( end2_pct < 1.0 ) { if ((rwhalf == 1 && rwy_info.marking_code1 == 2) || (rwhalf == 2 && rwy_info.marking_code2 == 2)){
start2_pct = end2_pct; gen_non_prec_marking( rwy_info, runway_half,
end2_pct = start2_pct + ( 400 / length ); start1_pct, end1_pct,
gen_runway_section( rwy_info, runway_b, heading, material,
start2_pct, end2_pct, rwy_polys, texparams, accum );
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading + 180.0,
material, "tz_two_a",
rwy_polys, texparams, accum );
} }
// add a section of center stripe
if ( end1_pct < 1.0 ) {
start1_pct = end1_pct;
end1_pct = start1_pct + ( 200 / length );
gen_runway_section( rwy_info, runway_a,
start1_pct, end1_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading,
material, "rest",
rwy_polys, texparams, accum );
}
if ( end2_pct < 1.0 ) {
start2_pct = end2_pct;
end2_pct = start2_pct + ( 200 / length );
gen_runway_section( rwy_info, runway_b,
start2_pct, end2_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading + 180.0,
material, "rest",
rwy_polys, texparams, accum );
}
//
// Touch down zone x2 (second)
//
if ( end1_pct < 1.0 ) {
start1_pct = end1_pct;
end1_pct = start1_pct + ( 200 / length );
gen_runway_section( rwy_info, runway_a,
start1_pct, end1_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading,
material, "tz_two_b",
rwy_polys, texparams, accum );
}
if ( end2_pct < 1.0 ) {
start2_pct = end2_pct;
end2_pct = start2_pct + ( 200 / length );
gen_runway_section( rwy_info, runway_b,
start2_pct, end2_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading + 180.0,
material, "tz_two_b",
rwy_polys, texparams, accum );
}
// add a section of center stripe
if ( end1_pct < 1.0 ) {
start1_pct = end1_pct;
end1_pct = start1_pct + ( 200 / length );
gen_runway_section( rwy_info, runway_a,
start1_pct, end1_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading,
material, "rest",
rwy_polys, texparams, accum );
}
if ( end2_pct < 1.0 ) {
start2_pct = end2_pct;
end2_pct = start2_pct + ( 200 / length );
gen_runway_section( rwy_info, runway_b,
start2_pct, end2_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading + 180.0,
material, "rest",
rwy_polys, texparams, accum );
}
//
// Touch down zone x1 (first)
//
if ( end1_pct < 1.0 ) {
start1_pct = end1_pct;
end1_pct = start1_pct + ( 400 / length );
gen_runway_section( rwy_info, runway_a,
start1_pct, end1_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading,
material, "tz_one_a",
rwy_polys, texparams, accum );
}
if ( end2_pct < 1.0 ) {
start2_pct = end2_pct;
end2_pct = start2_pct + ( 400 / length );
gen_runway_section( rwy_info, runway_b,
start2_pct, end2_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading + 180.0,
material, "tz_one_a",
rwy_polys, texparams, accum );
}
// add a section of center stripe
if ( end1_pct < 1.0 ) {
start1_pct = end1_pct;
end1_pct = start1_pct + ( 200 / length );
gen_runway_section( rwy_info, runway_a,
start1_pct, end1_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading,
material, "rest",
rwy_polys, texparams, accum );
}
if ( end2_pct < 1.0 ) {
start2_pct = end2_pct;
end2_pct = start2_pct + ( 200 / length );
gen_runway_section( rwy_info, runway_b,
start2_pct, end2_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading + 180.0,
material, "rest",
rwy_polys, texparams, accum );
}
//
// Touch down zone x1 (second)
//
if ( end1_pct < 1.0 ) {
start1_pct = end1_pct;
end1_pct = start1_pct + ( 200 / length );
gen_runway_section( rwy_info, runway_a,
start1_pct, end1_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading,
material, "tz_one_b",
rwy_polys, texparams, accum );
}
if ( end2_pct < 1.0 ) {
start2_pct = end2_pct;
end2_pct = start2_pct + ( 200 / length );
gen_runway_section( rwy_info, runway_b,
start2_pct, end2_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading + 180.0,
material, "tz_one_b",
rwy_polys, texparams, accum );
}
// //
// The rest ... // The rest ...
@ -609,33 +359,16 @@ void gen_rwy( const TGRunway& rwy_info,
start1_pct = end1_pct; start1_pct = end1_pct;
end1_pct = start1_pct + rest1_inc; end1_pct = start1_pct + rest1_inc;
gen_runway_section( rwy_info, runway_a, gen_runway_section( rwy_info, runway_half,
start1_pct, end1_pct, start1_pct, end1_pct,
0.0, 1.0, 0.0, 1.0,
0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0,
rwy_info.heading, heading,
material, "rest", material, "rest",
rwy_polys, texparams, accum ); rwy_polys, texparams, accum );
} }
ideal_rest_inc = ( 200.0 / length ); }
divs = (int)((1.0 - end2_pct) / ideal_rest_inc) + 1;
double rest2_inc = (1.0 - end2_pct) / divs;
while ( end2_pct < 1.0 ) {
start2_pct = end2_pct;
end2_pct = start2_pct + rest2_inc;
gen_runway_section( rwy_info, runway_b,
start2_pct, end2_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
rwy_info.heading + 180.0,
material, "rest",
rwy_polys, texparams, accum );
}
gen_runway_stopway( rwy_info, runway_a, runway_b,
material,
rwy_polys, texparams, accum );
} }