1
0
Fork 0

Move the whole genapts over to the metric system.

Now we calculate with metric values internally, however, the
fixed feet values in the source will have to be converted or
be used with SG_FEET_TO_METER for now.
This commit is contained in:
Christian Schmitt 2011-09-22 19:26:13 +02:00
parent 2fff6d803e
commit 785c4afcda
6 changed files with 79 additions and 79 deletions

View file

@ -274,9 +274,9 @@ static void build_runway( const TGRunway& rwy_info,
TGPolygon base, safe_base;
base = gen_runway_area_w_extend( rwy_info, 0.0, 20.0, -rwy_info.stopway1* SG_FEET_TO_METER, -rwy_info.stopway2* SG_FEET_TO_METER, 20.0 );
base = gen_runway_area_w_extend( rwy_info, 0.0, 20.0, -rwy_info.stopway1, -rwy_info.stopway2, 20.0 );
// also clear a safe area around the runway
safe_base = gen_runway_area_w_extend( rwy_info, 0.0, 180.0, -rwy_info.stopway1* SG_FEET_TO_METER, -rwy_info.stopway2* SG_FEET_TO_METER, 50.0 );
safe_base = gen_runway_area_w_extend( rwy_info, 0.0, 180.0, -rwy_info.stopway1, -rwy_info.stopway2, 50.0 );
*apt_clearing = tgPolygonUnion(safe_base, *apt_clearing);
// add base to apt_base
@ -354,7 +354,7 @@ void build_airport( string airport_id, float alt_m,
double rwcourse(SGGeodesy::courseDeg(pos_1, pos_2));
//calculate runway length
double rwlength((SGGeodesy::distanceM(pos_1, pos_2)) * SG_METER_TO_FEET);
double rwlength(SGGeodesy::distanceM(pos_1, pos_2));
//calculate runway centerpoint
double rwcenter_lat = (lat_1 + lat_2) / 2;
@ -374,13 +374,13 @@ void build_airport( string airport_id, float alt_m,
rwy.heading = rwcourse;
rwy.length = rwlength;
rwy.width = atoi( token[1].c_str() ) * SG_METER_TO_FEET;
rwy.width = atoi( token[1].c_str() );
rwy.disp_thresh1 = atoi( token[11].c_str() ) * SG_METER_TO_FEET;
rwy.disp_thresh2 = atoi( token[20].c_str() ) * SG_METER_TO_FEET;
rwy.disp_thresh1 = atoi( token[11].c_str() );
rwy.disp_thresh2 = atoi( token[20].c_str() );
rwy.stopway1 = atoi( token[12].c_str() ) * SG_METER_TO_FEET;
rwy.stopway2 = atoi( token[21].c_str() ) * SG_METER_TO_FEET;
rwy.stopway1 = atoi( token[12].c_str() );
rwy.stopway2 = atoi( token[21].c_str() );
rwy.marking_code1 = atoi( token[13].c_str() );
rwy.marking_code2 = atoi( token[22].c_str() );

View file

@ -98,7 +98,7 @@ static superpoly_list gen_runway_edge_lights( const TGRunway& rwy_info,
point_list y_normals; y_normals.clear();
int i;
double len = rwy_info.length * SG_FEET_TO_METER;
double len = rwy_info.length;
int divs = (int)(len / 60.0) + 1;
Point3D normal = gen_runway_light_vector( rwy_info, 3.0, recip );
@ -107,8 +107,8 @@ static superpoly_list gen_runway_edge_lights( const TGRunway& rwy_info,
// routine returns.
TGPolygon poly_corners
= gen_runway_area_w_extend( rwy_info, 0.0, 2.0,
rwy_info.disp_thresh1 * SG_FEET_TO_METER,
rwy_info.disp_thresh2 * SG_FEET_TO_METER,
rwy_info.disp_thresh1,
rwy_info.disp_thresh2,
2.0 );
point_list corner;
@ -205,7 +205,7 @@ static superpoly_list gen_taxiway_edge_lights( const TGRunway& rwy_info,
point_list b_normals; b_normals.clear();
int i;
double len = rwy_info.length * SG_FEET_TO_METER;
double len = rwy_info.length;
int divs;
if ( len > 100.0 ) {
// for lengths of 300' or more, max spacing is 200'
@ -297,8 +297,8 @@ static superpoly_list gen_runway_threshold_lights( const TGRunway& rwy_info,
// routine returns.
TGPolygon poly_corners
= gen_runway_area_w_extend( rwy_info, 0.0, 0.0,
rwy_info.disp_thresh1 * SG_FEET_TO_METER,
rwy_info.disp_thresh2 * SG_FEET_TO_METER,
rwy_info.disp_thresh1,
rwy_info.disp_thresh2,
0.0 );
point_list corner;
@ -422,8 +422,8 @@ static superpoly_list gen_runway_center_line_lights( const TGRunway& rwy_info,
// routine returns.
TGPolygon poly_corners
= gen_runway_area_w_extend( rwy_info, 0.0, 2.0,
rwy_info.disp_thresh1 * SG_FEET_TO_METER,
rwy_info.disp_thresh2 * SG_FEET_TO_METER,
rwy_info.disp_thresh1,
rwy_info.disp_thresh2,
2.0 );
point_list corner;
@ -593,8 +593,8 @@ static TGSuperPoly gen_touchdown_zone_lights( const TGRunway& rwy_info,
// routine returns.
TGPolygon poly_corners
= gen_runway_area_w_extend( rwy_info, 0.0, 0.0,
rwy_info.disp_thresh1 * SG_FEET_TO_METER,
rwy_info.disp_thresh2 * SG_FEET_TO_METER,
rwy_info.disp_thresh1,
rwy_info.disp_thresh2,
0.0 );
point_list corner;
@ -702,8 +702,8 @@ static TGSuperPoly gen_vasi( const TGRunway& rwy_info, float alt_m,
// routine returns.
TGPolygon poly_corners
= gen_runway_area_w_extend( rwy_info, 0.0, 0.0,
rwy_info.disp_thresh1 * SG_FEET_TO_METER,
rwy_info.disp_thresh2 * SG_FEET_TO_METER,
rwy_info.disp_thresh1,
rwy_info.disp_thresh2,
0.0 );
point_list corner;
@ -868,8 +868,8 @@ static TGSuperPoly gen_papi( const TGRunway& rwy_info, float alt_m,
// routine returns.
TGPolygon poly_corners
= gen_runway_area_w_extend( rwy_info, 0.0, 0.0,
rwy_info.disp_thresh1 * SG_FEET_TO_METER,
rwy_info.disp_thresh2 * SG_FEET_TO_METER,
rwy_info.disp_thresh1,
rwy_info.disp_thresh2,
0.0 );
point_list corner;
@ -981,8 +981,8 @@ static TGSuperPoly gen_reil( const TGRunway& rwy_info, float alt_m,
// routine returns.
TGPolygon poly_corners
= gen_runway_area_w_extend( rwy_info, 0.0, 0.0,
rwy_info.disp_thresh1 * SG_FEET_TO_METER,
rwy_info.disp_thresh2 * SG_FEET_TO_METER,
rwy_info.disp_thresh1,
rwy_info.disp_thresh2,
0.0 );
point_list corner;
@ -1080,15 +1080,15 @@ static superpoly_list gen_calvert( const TGRunway& rwy_info,
// Generate the threshold lights
double len = rwy_info.length * SG_FEET_TO_METER;
double len = rwy_info.length;
int divs = (int)(len / 10.0) + 1;
// using TGPolygon is a bit innefficient, but that's what the
// routine returns.
TGPolygon poly_corners
= gen_runway_area_w_extend( rwy_info, 0.0, 2.0,
rwy_info.disp_thresh1 * SG_FEET_TO_METER,
rwy_info.disp_thresh2 * SG_FEET_TO_METER,
rwy_info.disp_thresh1,
rwy_info.disp_thresh2,
2.0 );
point_list corner;
@ -1466,15 +1466,15 @@ static superpoly_list gen_alsf( const TGRunway& rwy_info,
// Generate the threshold lights
double len = rwy_info.length * SG_FEET_TO_METER;
double len = rwy_info.length;
int divs = (int)(len / 10.0) + 1;
// using TGPolygon is a bit innefficient, but that's what the
// routine returns.
TGPolygon poly_corners
= gen_runway_area_w_extend( rwy_info, 0.0, 2.0,
rwy_info.disp_thresh1 * SG_FEET_TO_METER,
rwy_info.disp_thresh2 * SG_FEET_TO_METER,
rwy_info.disp_thresh1,
rwy_info.disp_thresh2,
2.0 );
point_list corner;
@ -1980,8 +1980,8 @@ static TGSuperPoly gen_odals( const TGRunway& rwy_info, float alt_m,
// routine returns.
TGPolygon poly_corners
= gen_runway_area_w_extend( rwy_info, 0.0, 0.0,
rwy_info.disp_thresh1 * SG_FEET_TO_METER,
rwy_info.disp_thresh2 * SG_FEET_TO_METER,
rwy_info.disp_thresh1,
rwy_info.disp_thresh2,
0.0 );
point_list corner;
@ -2084,15 +2084,15 @@ static superpoly_list gen_ssalx( const TGRunway& rwy_info,
// Generate the threshold lights
double len = rwy_info.length * SG_FEET_TO_METER;
double len = rwy_info.length;
int divs = (int)(len / 10.0) + 1;
// using TGPolygon is a bit innefficient, but that's what the
// routine returns.
TGPolygon poly_corners
= gen_runway_area_w_extend( rwy_info, 0.0, 2.0,
rwy_info.disp_thresh1 * SG_FEET_TO_METER,
rwy_info.disp_thresh2 * SG_FEET_TO_METER,
rwy_info.disp_thresh1,
rwy_info.disp_thresh2,
2.0 );
point_list corner;
@ -2354,15 +2354,15 @@ static superpoly_list gen_malsx( const TGRunway& rwy_info,
// Generate the threshold lights
double len = rwy_info.length * SG_FEET_TO_METER;
double len = rwy_info.length;
int divs = (int)(len / 10.0) + 1;
// using TGPolygon is a bit innefficient, but that's what the
// routine returns.
TGPolygon poly_corners
= gen_runway_area_w_extend( rwy_info, 0.0, 2.0,
rwy_info.disp_thresh1 * SG_FEET_TO_METER,
rwy_info.disp_thresh2 * SG_FEET_TO_METER,
rwy_info.disp_thresh1,
rwy_info.disp_thresh2,
2.0 );
point_list corner;

View file

@ -122,9 +122,9 @@ TGPolygon gen_runway_area_w_scale( const TGRunway& runway,
Point3D origin(runway.lon, runway.lat, 0);
result_list = gen_wgs84_area( origin,
runway.length*length_scale * SG_FEET_TO_METER,
runway.length*length_scale,
0.0, 0.0,
runway.width*width_scale * SG_FEET_TO_METER,
runway.width*width_scale,
runway.heading, alt_m, false );
// display points
@ -150,9 +150,9 @@ TGPolygon gen_runway_area_w_extend( const TGRunway& runway,
result_list
= gen_wgs84_area( origin,
runway.length*SG_FEET_TO_METER + 2.0*length_extend,
runway.length + 2.0*length_extend,
displ1, displ2,
runway.width*SG_FEET_TO_METER + 2.0*width_extend,
runway.width + 2.0*width_extend,
runway.heading, alt_m, false );
// display points
@ -174,10 +174,10 @@ TGPolygon gen_runway_w_mid( const TGRunway& runway,
Point3D origin(runway.lon, runway.lat, 0);
result_list = gen_wgs84_area( origin,
runway.length * SG_FEET_TO_METER
runway.length
+ 2.0*length_extend_m,
0.0, 0.0,
runway.width * SG_FEET_TO_METER
runway.width
+ 2.0 * width_extend_m,
runway.heading, alt_m, true );

View file

@ -98,7 +98,7 @@ void gen_runway_stopway( const TGRunway& rwy_info,
superpoly_list *rwy_polys,
texparams_list *texparams,
TGPolygon* accum ) {
const float length = rwy_info.length / 2.0 + 2.0;
const float length = rwy_info.length / 2.0 + 2.0 * SG_FEET_TO_METER;
double start1_pct = 0.0;
double end1_pct = 0.0;
double part_len = 0.0;
@ -276,19 +276,19 @@ void gen_runway_section( const TGRunway& rwy_info,
// 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
// belong.
double len = rwy_info.length / 2.0 + 2;
double len = rwy_info.length / 2.0 + 2 * SG_FEET_TO_METER;
double sect_len = len * ( endl_pct - startl_pct );
// we add 2' to both sides of the runway (4' total) for texture
// overlap. This puts the lines on the texture back to the edge
// of the runway where they belong.
double wid = rwy_info.width + 4;
double wid = rwy_info.width + 4 * SG_FEET_TO_METER;
double sect_wid = wid * ( endw_pct - startw_pct );
TGTexParams tp;
tp = TGTexParams( p0,
sect_wid * SG_FEET_TO_METER,
sect_len * SG_FEET_TO_METER,
sect_wid,
sect_len,
heading );
tp.set_minu( minu );
tp.set_maxu( maxu );

View file

@ -48,19 +48,19 @@ void gen_prec_marking( const TGRunway& rwy_info,
// 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 }
{ "tz_three", 380 * SG_FEET_TO_METER },
{ "rest", 200 * SG_FEET_TO_METER },
{ "aim", 400 * SG_FEET_TO_METER },
{ "tz_two_a", 400 * SG_FEET_TO_METER },
{ "rest", 200 * SG_FEET_TO_METER },
{ "tz_two_b", 200 * SG_FEET_TO_METER },
{ "rest", 200 * SG_FEET_TO_METER },
{ "tz_one_a", 400 * SG_FEET_TO_METER },
{ "rest", 200 * SG_FEET_TO_METER },
{ "tz_one_b", 200 * SG_FEET_TO_METER }
};
double length = rwy_info.length / 2.0 + 2.0;
double length = rwy_info.length / 2.0 + 2.0 * SG_FEET_TO_METER;
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);
@ -90,11 +90,11 @@ void gen_non_prec_marking( const TGRunway& rwy_info,
// 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 }
{ "centerline", 200 * SG_FEET_TO_METER },
{ "aim", 400 * SG_FEET_TO_METER }
};
double length = rwy_info.length / 2.0 + 2.0;
double length = rwy_info.length / 2.0 + 2.0 * SG_FEET_TO_METER;
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);
@ -169,8 +169,8 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){
// 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
// belong.
double length = rwy_info.length / 2.0 + 2.0;
if ( length < 3075 ) {
double length = rwy_info.length / 2.0 + 2.0 * SG_FEET_TO_METER;
if ( length < 3075 * SG_FEET_TO_METER ) {
SG_LOG( SG_GENERAL, SG_ALERT,
"Runway " << rwy_info.rwy_no1 << " is not long enough ("
<< rwy_info.length << ") for precision markings!");
@ -206,14 +206,14 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){
<< disp_thresh );
// reserve 90' for final arrows
double thresh = disp_thresh - 90.0;
double thresh = disp_thresh - 90.0 * SG_FEET_TO_METER;
// number of full center arrows
int count = (int)(thresh / 200.0);
int count = (int)(thresh / 200.0 * SG_FEET_TO_METER);
// length of starting partial arrow
double part_len = thresh - ( count * 200.0 );
double tex_pct = (200.0 - part_len) / 200.0;
double part_len = thresh - ( count * 200.0 * SG_FEET_TO_METER);
double tex_pct = (200.0 * SG_FEET_TO_METER - part_len) / 200.0 * SG_FEET_TO_METER;
// starting (possibly partial chunk)
start1_pct = end1_pct;
@ -229,7 +229,7 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){
// main chunks
for ( i = 0; i < count; ++i ) {
start1_pct = end1_pct;
end1_pct = start1_pct + ( 200.0 / length );
end1_pct = start1_pct + ( 200.0 * SG_FEET_TO_METER / length );
gen_runway_section( rwy_info, runway_half,
start1_pct, end1_pct,
0.0, 1.0,
@ -241,7 +241,7 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){
// final arrows
start1_pct = end1_pct;
end1_pct = start1_pct + ( 90.0 / length );
end1_pct = start1_pct + ( 90.0 * SG_FEET_TO_METER / length );
gen_runway_section( rwy_info, runway_half,
start1_pct, end1_pct,
0.0, 1.0,
@ -259,7 +259,7 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){
//
start1_pct = end1_pct;
end1_pct = start1_pct + ( 202.0 / length );
end1_pct = start1_pct + ( 202.0 * SG_FEET_TO_METER / length );
gen_runway_section( rwy_info, runway_half,
start1_pct, end1_pct,
0.0, 1.0,
@ -292,7 +292,7 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){
if ( !letter.empty() ) {
start1_pct = end1_pct;
end1_pct = start1_pct + ( 90.0 / length );
end1_pct = start1_pct + ( 90.0 * SG_FEET_TO_METER / length );
gen_runway_section( rwy_info, runway_half,
start1_pct, end1_pct,
0.0, 1.0,
@ -323,7 +323,7 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){
}
start1_pct = end1_pct;
end1_pct = start1_pct + ( 80.0 / length );
end1_pct = start1_pct + ( 80.0 * SG_FEET_TO_METER / length );
gen_number_block( rwy_info, material, runway_half, heading,
num, start1_pct, end1_pct, rwy_polys, texparams, accum );
}
@ -351,7 +351,7 @@ for ( int rwhalf=1; rwhalf<3; ++rwhalf ){
// fit the 'rest' texture in as many times as will go evenly into
// the remaining distance so we don't end up with a super short
// section at the end.
double ideal_rest_inc = ( 200.0 / length );
double ideal_rest_inc = ( 200.0 * SG_FEET_TO_METER / length );
int divs = (int)((1.0 - end1_pct) / ideal_rest_inc) + 1;
double rest1_inc = (1.0 - end1_pct) / divs;

View file

@ -86,8 +86,8 @@ void gen_simple_rwy( const TGRunway& rwy_info,
SG_LOG(SG_GENERAL, SG_DEBUG, "clipped_a = " << clipped_a.contours());
*accum = tgPolygonUnion( runway_a, *accum );
tp = TGTexParams( runway_a.get_pt(0,0),
rwy_info.width * SG_FEET_TO_METER,
rwy_info.length * SG_FEET_TO_METER / 2.0,
rwy_info.width,
rwy_info.length / 2.0,
rwy_info.heading );
texparams->push_back( tp );
@ -100,8 +100,8 @@ void gen_simple_rwy( const TGRunway& rwy_info,
SG_LOG(SG_GENERAL, SG_DEBUG, "clipped_b = " << clipped_b.contours());
*accum = tgPolygonUnion( runway_b, *accum );
tp = TGTexParams( runway_b.get_pt(0,2),
rwy_info.width * SG_FEET_TO_METER,
rwy_info.length * SG_FEET_TO_METER / 2.0,
rwy_info.width,
rwy_info.length / 2.0,
rwy_info.heading + 180.0 );
texparams->push_back( tp );