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,12 +88,12 @@ 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 );
// generate the runway overrun area // generate the runway overrun area
void gen_runway_overrun( const TGPolygon& runway_half, void gen_runway_overrun( const TGPolygon& runway_half,

View file

@ -35,58 +35,80 @@
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;
for ( int i = 0; i < rwname.length(); ++i ) {
string tmp = rwname.substr(i, 1);
if ( tmp == "L" || tmp == "R" || tmp == "C" ) {
rwname = rwname.substr(0, i);
letter = tmp;
}
}
SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation letter = " << letter);
SG_LOG(SG_GENERAL, SG_DEBUG, "Runway num = " << num); // create runway designation letter
if ( !letter.empty() ) {
start_pct = end_pct;
end_pct = start_pct + ( 90.0 * SG_FEET_TO_METER / length );
gen_runway_section( poly,
start_pct, end_pct,
0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
heading,
material, letter,
rwy_polys, texparams, accum );
}
if ( num == 0 ) {
SG_LOG( SG_GENERAL, SG_ALERT,
"Ack! Someone passed in a runway number of '0'" );
exit(-1);
}
if ( num == 11 ) { // create runway designation number(s)
sprintf( tex1, "11" ); if (rwname == "0")
} else if ( num < 10 ) { rwname = "36";
sprintf( tex1, "%dc", num ); SG_LOG(SG_GENERAL, SG_DEBUG, "Runway designation = " << rwname);
} else {
sprintf( tex1, "%dl", num / 10 );
sprintf( tex2, "%dr", num - (num / 10 * 10));
}
// printf("tex1 = '%s' tex2 = '%s'\n", tex1, tex2); char tex1[32]; tex1[0] = '\0';
char tex2[32]; tex2[0] = '\0';
if ( num < 10 || num == 11 ) { start_pct = end_pct;
gen_runway_section( poly, end_pct = start_pct + ( 80.0 * SG_FEET_TO_METER / length );
start_pct, end_pct,
0.0, 1.0, if (rwname.length() == 2) {
0.0, 1.0, 0.0, 1.0, sprintf( tex1, "%c%c", rwname[0], 'l');
heading, sprintf( tex2, "%c%c", rwname[1], 'r');
material, tex1,
rwy_polys, texparams, accum ); gen_runway_section( poly,
} else { start_pct, end_pct,
gen_runway_section( poly, 0.0, 0.5,
start_pct, end_pct, 0.0, 1.0, 0.0, 1.0,
0.0, 0.5, heading,
0.0, 1.0, 0.0, 1.0, material, tex1,
heading, rwy_polys, texparams, accum );
material, tex1, gen_runway_section( poly,
rwy_polys, texparams, accum ); start_pct, end_pct,
gen_runway_section( poly, 0.5, 1.0,
start_pct, end_pct, 0.0, 1.0, 0.0, 1.0,
0.5, 1.0, heading,
0.0, 1.0, 0.0, 1.0, material, tex2,
heading, rwy_polys, texparams, accum );
material, tex2,
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){