1
0
Fork 0

Rework the runway designation code. All put into one function.

This does now support literal runway names like "07" instead of "7".
Also support upcoming "XX" designation which marks a runway as
non-numbered. Testing needed.
This commit is contained in:
Christian Schmitt 2011-10-10 13:56:06 +02:00
parent 10260917f8
commit 812dd638af
3 changed files with 77 additions and 108 deletions

View file

@ -88,9 +88,9 @@ private:
} }
void gen_number_block( const std::string& material, void gen_rw_designation( const std::string& material,
TGPolygon poly, double heading, int num, TGPolygon poly, double heading, string rwname,
double start_pct, double end_pct, double &start_pct, double &end_pct,
superpoly_list* rwy_polys, superpoly_list* rwy_polys,
texparams_list* texparams, texparams_list* texparams,
TGPolygon* accum ); TGPolygon* accum );

View file

@ -35,44 +35,54 @@
using std::string; using std::string;
void Runway::gen_number_block( const string& material, void Runway::gen_rw_designation( const string& material,
TGPolygon poly, double heading, int num, TGPolygon poly, double heading, string rwname,
double start_pct, double end_pct, double &start_pct, double &end_pct,
superpoly_list *rwy_polys, superpoly_list *rwy_polys,
texparams_list *texparams, texparams_list *texparams,
TGPolygon *accum ) TGPolygon *accum )
{ {
char tex1[32]; tex1[0] = '\0'; if (rwname != "XX"){ /* Do not create a designation block if the runway name is set to none */
char tex2[32]; tex2[0] = '\0'; string letter = "";
double length = rwy.length / 2.0;
SG_LOG(SG_GENERAL, SG_DEBUG, "Runway num = " << num); for ( int i = 0; i < rwname.length(); ++i ) {
string tmp = rwname.substr(i, 1);
if ( num == 0 ) { if ( tmp == "L" || tmp == "R" || tmp == "C" ) {
SG_LOG( SG_GENERAL, SG_ALERT, rwname = rwname.substr(0, i);
"Ack! Someone passed in a runway number of '0'" ); letter = tmp;
exit(-1);
} }
if ( num == 11 ) {
sprintf( tex1, "11" );
} else if ( num < 10 ) {
sprintf( tex1, "%dc", num );
} else {
sprintf( tex1, "%dl", num / 10 );
sprintf( tex2, "%dr", num - (num / 10 * 10));
} }
SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation letter = " << letter);
// printf("tex1 = '%s' tex2 = '%s'\n", tex1, tex2); // create runway designation letter
if ( !letter.empty() ) {
if ( num < 10 || num == 11 ) { start_pct = end_pct;
end_pct = start_pct + ( 90.0 * SG_FEET_TO_METER / length );
gen_runway_section( poly, gen_runway_section( poly,
start_pct, end_pct, start_pct, end_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,
heading, heading,
material, tex1, material, letter,
rwy_polys, texparams, accum ); rwy_polys, texparams, accum );
} else { }
// create runway designation number(s)
if (rwname == "0")
rwname = "36";
SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation = " << rwname);
char tex1[32]; tex1[0] = '\0';
char tex2[32]; tex2[0] = '\0';
start_pct = end_pct;
end_pct = start_pct + ( 80.0 * SG_FEET_TO_METER / length );
if (rwname.length() == 2) {
sprintf( tex1, "%c%c", rwname[0], 'l');
sprintf( tex2, "%c%c", rwname[1], 'r');
gen_runway_section( poly, gen_runway_section( poly,
start_pct, end_pct, start_pct, end_pct,
0.0, 0.5, 0.0, 0.5,
@ -87,6 +97,18 @@ void Runway::gen_number_block( const string& material,
heading, heading,
material, tex2, material, tex2,
rwy_polys, texparams, accum ); rwy_polys, texparams, accum );
} else if (rwname.length() == 1) {
sprintf( tex1, "%c%c", rwname[0], 'c');
gen_runway_section( poly,
start_pct, end_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
heading,
material, tex1,
rwy_polys, texparams, accum );
}
} }
} }

View file

@ -289,63 +289,10 @@ for ( int rwhalf=0; rwhalf<2; ++rwhalf ){
rwy_polys, texparams, accum ); rwy_polys, texparams, accum );
} }
if (!rwy.marking[rwhalf] == 0){ // Runway designation block
// gen_rw_designation( material, runway_half, heading,
// Runway designation letter rwname, start1_pct, end1_pct, rwy_polys, texparams, accum );
//
int len = rwname.length();
string letter = "";
for ( i = 0; i < len; ++i ) {
string tmp = rwname.substr(i, 1);
if ( tmp == "L" ) {
letter = "L";
} else if ( tmp == "R" ) {
letter = "R";
} else if ( tmp == "C" ) {
letter = "C";
}
}
SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation = " << rwname);
SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation letter = " << letter);
if ( !letter.empty() ) {
start1_pct = end1_pct;
end1_pct = start1_pct + ( 90.0 * SG_FEET_TO_METER / length );
gen_runway_section( runway_half,
start1_pct, end1_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
heading,
material, letter,
rwy_polys, texparams, accum );
}
//
// Runway designation number(s)
//
len = rwname.length();
string snum = rwname;
for ( i = 0; i < len; ++i ) {
string tmp = rwname.substr(i, 1);
if ( tmp == "L" || tmp == "R" || tmp == "C" || tmp == " " ) {
snum = rwname.substr(0, i);
}
}
SG_LOG(SG_GENERAL, SG_INFO, "Runway num = '" << snum );
int num = atoi( snum.c_str() );
while ( num <= 0 ) {
num += 36;
}
start1_pct = end1_pct;
end1_pct = start1_pct + ( 80.0 * SG_FEET_TO_METER / length );
gen_number_block( material, runway_half, heading,
num, start1_pct, end1_pct, rwy_polys, texparams, accum );
}
if (rwy.marking[rwhalf] > 1){ if (rwy.marking[rwhalf] > 1){