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:
parent
10260917f8
commit
812dd638af
3 changed files with 77 additions and 108 deletions
|
@ -88,9 +88,9 @@ private:
|
|||
}
|
||||
|
||||
|
||||
void gen_number_block( const std::string& material,
|
||||
TGPolygon poly, double heading, int num,
|
||||
double start_pct, double end_pct,
|
||||
void gen_rw_designation( const std::string& material,
|
||||
TGPolygon poly, double heading, string rwname,
|
||||
double &start_pct, double &end_pct,
|
||||
superpoly_list* rwy_polys,
|
||||
texparams_list* texparams,
|
||||
TGPolygon* accum );
|
||||
|
|
|
@ -35,44 +35,54 @@
|
|||
using std::string;
|
||||
|
||||
|
||||
void Runway::gen_number_block( const string& material,
|
||||
TGPolygon poly, double heading, int num,
|
||||
double start_pct, double end_pct,
|
||||
void Runway::gen_rw_designation( const string& material,
|
||||
TGPolygon poly, double heading, string rwname,
|
||||
double &start_pct, double &end_pct,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
TGPolygon *accum )
|
||||
{
|
||||
char tex1[32]; tex1[0] = '\0';
|
||||
char tex2[32]; tex2[0] = '\0';
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Runway num = " << num);
|
||||
|
||||
if ( num == 0 ) {
|
||||
SG_LOG( SG_GENERAL, SG_ALERT,
|
||||
"Ack! Someone passed in a runway number of '0'" );
|
||||
exit(-1);
|
||||
if (rwname != "XX"){ /* Do not create a designation block if the runway name is set to none */
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if ( num < 10 || num == 11 ) {
|
||||
// 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, tex1,
|
||||
material, letter,
|
||||
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,
|
||||
start_pct, end_pct,
|
||||
0.0, 0.5,
|
||||
|
@ -87,6 +97,18 @@ void Runway::gen_number_block( const string& material,
|
|||
heading,
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -289,63 +289,10 @@ for ( int rwhalf=0; rwhalf<2; ++rwhalf ){
|
|||
rwy_polys, texparams, accum );
|
||||
}
|
||||
|
||||
if (!rwy.marking[rwhalf] == 0){
|
||||
//
|
||||
// Runway designation letter
|
||||
//
|
||||
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";
|
||||
}
|
||||
}
|
||||
// Runway designation block
|
||||
gen_rw_designation( material, runway_half, heading,
|
||||
rwname, start1_pct, end1_pct, rwy_polys, texparams, accum );
|
||||
|
||||
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){
|
||||
|
|
Loading…
Reference in a new issue