Use wgs_84 math to layout runways. My original method was a little backwards,
it involved creating a 2d runway object of the right size, rotating it and then trying to back solve for the actual lon/lat. This and a few other problems was causing problems with subsequent texture coordinate calcs for the runway surface textures. It also could have contributed to runways/lighting being slightly misaligned with the ILS's. Then lots of minor cascading changes as a result.
This commit is contained in:
parent
9d44a4ae64
commit
9f6fdee612
14 changed files with 164 additions and 202 deletions
|
@ -256,6 +256,7 @@ static void my_chomp( string& str ) {
|
|||
|
||||
// build a runway
|
||||
void build_runway( const FGRunway& rwy_info,
|
||||
double alt_m,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum,
|
||||
|
@ -306,24 +307,24 @@ void build_runway( const FGRunway& rwy_info,
|
|||
SG_LOG(SG_GENERAL, SG_DEBUG, "type flag = " << type_flag);
|
||||
|
||||
if ( rwy_info.really_taxiway ) {
|
||||
gen_taxiway( rwy_info, material,
|
||||
gen_taxiway( rwy_info, alt_m,material,
|
||||
rwy_polys, texparams, accum );
|
||||
} else if ( surface_flag == "D" || surface_flag == "G" ||
|
||||
surface_flag == "T" )
|
||||
{
|
||||
gen_simple_rwy( rwy_info, material,
|
||||
gen_simple_rwy( rwy_info, alt_m, material,
|
||||
rwy_polys, texparams, accum );
|
||||
} else if ( type_flag == "P" ) {
|
||||
// precision runway markings
|
||||
gen_precision_rwy( rwy_info, material,
|
||||
gen_precision_rwy( rwy_info, alt_m, material,
|
||||
rwy_polys, texparams, accum );
|
||||
} else if ( type_flag == "R" ) {
|
||||
// non-precision runway markings
|
||||
gen_non_precision_rwy( rwy_info, material,
|
||||
gen_non_precision_rwy( rwy_info, alt_m, material,
|
||||
rwy_polys, texparams, accum );
|
||||
} else if ( type_flag == "V" ) {
|
||||
// visual runway markings
|
||||
gen_visual_rwy( rwy_info, material,
|
||||
gen_visual_rwy( rwy_info, alt_m, material,
|
||||
rwy_polys, texparams, accum );
|
||||
} else if ( type_flag == "B" ) {
|
||||
// bouys (sea plane base)
|
||||
|
@ -337,12 +338,13 @@ void build_runway( const FGRunway& rwy_info,
|
|||
|
||||
FGPolygon base;
|
||||
if ( rwy_info.really_taxiway ) {
|
||||
base = gen_runway_area_w_expand( rwy_info, 10, 10 );
|
||||
base = gen_runway_area_w_extend( rwy_info, 10, 10 );
|
||||
} else {
|
||||
// clear a safe area around the runway
|
||||
base = gen_runway_area_w_expand( rwy_info, 300, 120 );
|
||||
*apt_clearing = polygon_union(base, *apt_clearing);
|
||||
base = gen_runway_area_w_scale( rwy_info, 1.05, 1.5 );
|
||||
base = gen_runway_area_w_extend( rwy_info, 20, 20 );
|
||||
|
||||
// also clear a safe area around the runway
|
||||
FGPolygon safe_base = gen_runway_area_w_extend( rwy_info, 300, 120 );
|
||||
*apt_clearing = polygon_union(safe_base, *apt_clearing);
|
||||
}
|
||||
|
||||
// add base to apt_base
|
||||
|
@ -530,7 +532,7 @@ void build_airport( string airport_raw, float alt_m, string_list& runways_raw,
|
|||
for ( i = 0; i < (int)runways.size(); ++i ) {
|
||||
string type_flag = runways[i].surface_flags.substr(2, 1);
|
||||
if ( type_flag == "P" ) {
|
||||
build_runway( runways[i],
|
||||
build_runway( runways[i], elev * SG_FEET_TO_METER,
|
||||
&rwy_polys, &texparams, &accum, &apt_base,
|
||||
&apt_clearing );
|
||||
}
|
||||
|
@ -540,7 +542,7 @@ void build_airport( string airport_raw, float alt_m, string_list& runways_raw,
|
|||
for ( i = 0; i < (int)runways.size(); ++i ) {
|
||||
string type_flag = runways[i].surface_flags.substr(2, 1);
|
||||
if ( type_flag == "R" || type_flag == "V" ) {
|
||||
build_runway( runways[i],
|
||||
build_runway( runways[i], elev * SG_FEET_TO_METER,
|
||||
&rwy_polys, &texparams, &accum, &apt_base,
|
||||
&apt_clearing );
|
||||
}
|
||||
|
@ -550,7 +552,7 @@ void build_airport( string airport_raw, float alt_m, string_list& runways_raw,
|
|||
for ( i = 0; i < (int)runways.size(); ++i ) {
|
||||
string type_flag = runways[i].surface_flags.substr(2, 1);
|
||||
if ( type_flag != "P" && type_flag != "R" && type_flag != "V" ) {
|
||||
build_runway( runways[i],
|
||||
build_runway( runways[i], elev * SG_FEET_TO_METER,
|
||||
&rwy_polys, &texparams, &accum, &apt_base,
|
||||
&apt_clearing );
|
||||
}
|
||||
|
@ -576,7 +578,8 @@ void build_airport( string airport_raw, float alt_m, string_list& runways_raw,
|
|||
|
||||
if ( largest_idx >= 0 ) {
|
||||
SG_LOG( SG_GENERAL, SG_INFO, "generating " << largest_idx );
|
||||
build_runway( taxiways[largest_idx], &rwy_polys, &texparams, &accum,
|
||||
build_runway( taxiways[largest_idx], elev * SG_FEET_TO_METER,
|
||||
&rwy_polys, &texparams, &accum,
|
||||
&apt_base, &apt_clearing );
|
||||
taxiways[largest_idx].generated = true;
|
||||
} else {
|
||||
|
|
|
@ -40,7 +40,7 @@ static Point3D gen_runway_light_vector( const FGRunway& rwy_info,
|
|||
double length;
|
||||
|
||||
// Generate the 4 corners of the runway
|
||||
FGPolygon poly_corners = gen_runway_area_w_expand( rwy_info, 0.0, 0.0 );
|
||||
FGPolygon poly_corners = gen_runway_area_w_extend( rwy_info, 0.0, 0.0 );
|
||||
point_list corner;
|
||||
for ( int i = 0; i < poly_corners.contour_size( 0 ); ++i ) {
|
||||
corner.push_back( poly_corners.get_pt( 0, i ) );
|
||||
|
@ -85,7 +85,7 @@ static Point3D gen_runway_length_vector( const FGRunway& rwy_info, bool recip )
|
|||
double length;
|
||||
|
||||
// Generate the 4 corners of the runway
|
||||
FGPolygon poly_corners = gen_runway_area_w_expand( rwy_info, 0.0, 0.0 );
|
||||
FGPolygon poly_corners = gen_runway_area_w_extend( rwy_info, 0.0, 0.0 );
|
||||
point_list corner;
|
||||
for ( int i = 0; i < poly_corners.contour_size( 0 ); ++i ) {
|
||||
corner.push_back( poly_corners.get_pt( 0, i ) );
|
||||
|
@ -120,7 +120,7 @@ static Point3D gen_runway_left_vector( const FGRunway& rwy_info, bool recip )
|
|||
double length;
|
||||
|
||||
// Generate the 4 corners of the runway
|
||||
FGPolygon poly_corners = gen_runway_area_w_expand( rwy_info, 0.0, 0.0 );
|
||||
FGPolygon poly_corners = gen_runway_area_w_extend( rwy_info, 0.0, 0.0 );
|
||||
point_list corner;
|
||||
for ( int i = 0; i < poly_corners.contour_size( 0 ); ++i ) {
|
||||
corner.push_back( poly_corners.get_pt( 0, i ) );
|
||||
|
@ -166,7 +166,7 @@ static superpoly_list gen_runway_edge_lights( const FGRunway& rwy_info,
|
|||
|
||||
// using FGPolygon is a bit innefficient, but that's what the
|
||||
// routine returns.
|
||||
FGPolygon poly_corners = gen_runway_area_w_expand( rwy_info, 2.0, 2.0 );
|
||||
FGPolygon poly_corners = gen_runway_area_w_extend( rwy_info, 2.0, 2.0 );
|
||||
|
||||
point_list corner;
|
||||
for ( i = 0; i < poly_corners.contour_size( 0 ); ++i ) {
|
||||
|
@ -276,7 +276,7 @@ static superpoly_list gen_taxiway_edge_lights( const FGRunway& rwy_info,
|
|||
|
||||
// using FGPolygon is a bit innefficient, but that's what the
|
||||
// routine returns.
|
||||
FGPolygon poly_corners = gen_runway_area_w_expand( rwy_info, 2.0, 2.0 );
|
||||
FGPolygon poly_corners = gen_runway_area_w_extend( rwy_info, 2.0, 2.0 );
|
||||
|
||||
point_list corner;
|
||||
for ( i = 0; i < poly_corners.contour_size( 0 ); ++i ) {
|
||||
|
@ -355,7 +355,7 @@ static superpoly_list gen_runway_threshold_lights( const FGRunway& rwy_info,
|
|||
|
||||
// using FGPolygon is a bit innefficient, but that's what the
|
||||
// routine returns.
|
||||
FGPolygon poly_corners = gen_runway_area_w_expand( rwy_info, 0.0, 0.0 );
|
||||
FGPolygon poly_corners = gen_runway_area_w_extend( rwy_info, 0.0, 0.0 );
|
||||
|
||||
point_list corner;
|
||||
for ( i = 0; i < poly_corners.contour_size( 0 ); ++i ) {
|
||||
|
@ -493,7 +493,7 @@ static superpoly_list gen_runway_center_line_lights( const FGRunway& rwy_info,
|
|||
|
||||
// using FGPolygon is a bit innefficient, but that's what the
|
||||
// routine returns.
|
||||
FGPolygon poly_corners = gen_runway_area_w_expand( rwy_info, 2.0, 2.0 );
|
||||
FGPolygon poly_corners = gen_runway_area_w_extend( rwy_info, 2.0, 2.0 );
|
||||
|
||||
point_list corner;
|
||||
for ( i = 0; i < poly_corners.contour_size( 0 ); ++i ) {
|
||||
|
@ -584,7 +584,7 @@ static FGSuperPoly gen_touchdown_zone_lights( const FGRunway& rwy_info,
|
|||
|
||||
// using FGPolygon is a bit innefficient, but that's what the
|
||||
// routine returns.
|
||||
FGPolygon poly_corners = gen_runway_area_w_expand( rwy_info, 0.0, 0.0 );
|
||||
FGPolygon poly_corners = gen_runway_area_w_extend( rwy_info, 0.0, 0.0 );
|
||||
|
||||
point_list corner;
|
||||
for ( i = 0; i < poly_corners.contour_size( 0 ); ++i ) {
|
||||
|
@ -687,7 +687,7 @@ static FGSuperPoly gen_vasi( const FGRunway& rwy_info, float alt_m,
|
|||
|
||||
// using FGPolygon is a bit innefficient, but that's what the
|
||||
// routine returns.
|
||||
FGPolygon poly_corners = gen_runway_area_w_expand( rwy_info, 0.0, 0.0 );
|
||||
FGPolygon poly_corners = gen_runway_area_w_extend( rwy_info, 0.0, 0.0 );
|
||||
|
||||
point_list corner;
|
||||
for ( i = 0; i < poly_corners.contour_size( 0 ); ++i ) {
|
||||
|
@ -823,7 +823,7 @@ static FGSuperPoly gen_papi( const FGRunway& rwy_info, float alt_m,
|
|||
|
||||
// using FGPolygon is a bit innefficient, but that's what the
|
||||
// routine returns.
|
||||
FGPolygon poly_corners = gen_runway_area_w_expand( rwy_info, 0.0, 0.0 );
|
||||
FGPolygon poly_corners = gen_runway_area_w_extend( rwy_info, 0.0, 0.0 );
|
||||
|
||||
point_list corner;
|
||||
for ( i = 0; i < poly_corners.contour_size( 0 ); ++i ) {
|
||||
|
@ -914,7 +914,7 @@ static FGSuperPoly gen_reil( const FGRunway& rwy_info, float alt_m,
|
|||
|
||||
// using FGPolygon is a bit innefficient, but that's what the
|
||||
// routine returns.
|
||||
FGPolygon poly_corners = gen_runway_area_w_expand( rwy_info, 0.0, 0.0 );
|
||||
FGPolygon poly_corners = gen_runway_area_w_extend( rwy_info, 0.0, 0.0 );
|
||||
|
||||
point_list corner;
|
||||
for ( i = 0; i < poly_corners.contour_size( 0 ); ++i ) {
|
||||
|
@ -1005,7 +1005,7 @@ static superpoly_list gen_alsf( const FGRunway& rwy_info,
|
|||
|
||||
// using FGPolygon is a bit innefficient, but that's what the
|
||||
// routine returns.
|
||||
FGPolygon poly_corners = gen_runway_area_w_expand( rwy_info, 2.0, 2.0 );
|
||||
FGPolygon poly_corners = gen_runway_area_w_extend( rwy_info, 2.0, 2.0 );
|
||||
|
||||
point_list corner;
|
||||
for ( i = 0; i < poly_corners.contour_size( 0 ); ++i ) {
|
||||
|
@ -1499,7 +1499,7 @@ static superpoly_list gen_ssalx( const FGRunway& rwy_info,
|
|||
|
||||
// using FGPolygon is a bit innefficient, but that's what the
|
||||
// routine returns.
|
||||
FGPolygon poly_corners = gen_runway_area_w_expand( rwy_info, 2.0, 2.0 );
|
||||
FGPolygon poly_corners = gen_runway_area_w_extend( rwy_info, 2.0, 2.0 );
|
||||
|
||||
point_list corner;
|
||||
for ( i = 0; i < poly_corners.contour_size( 0 ); ++i ) {
|
||||
|
@ -1762,7 +1762,7 @@ static superpoly_list gen_malsx( const FGRunway& rwy_info,
|
|||
|
||||
// using FGPolygon is a bit innefficient, but that's what the
|
||||
// routine returns.
|
||||
FGPolygon poly_corners = gen_runway_area_w_expand( rwy_info, 2.0, 2.0 );
|
||||
FGPolygon poly_corners = gen_runway_area_w_extend( rwy_info, 2.0, 2.0 );
|
||||
|
||||
point_list corner;
|
||||
for ( i = 0; i < poly_corners.contour_size( 0 ); ++i ) {
|
||||
|
|
|
@ -34,80 +34,72 @@
|
|||
#include "point2d.hxx"
|
||||
|
||||
|
||||
// calc new x, y for a rotation
|
||||
double rot_x(double x, double y, double theta) {
|
||||
return ( x * cos(theta) + y * sin(theta) );
|
||||
}
|
||||
|
||||
|
||||
// calc new x, y for a rotation
|
||||
double rot_y(double x, double y, double theta) {
|
||||
return ( -x * sin(theta) + y * cos(theta) );
|
||||
}
|
||||
|
||||
|
||||
FGPolygon batch_cart_to_polar_2d( const FGPolygon& in_list ) {
|
||||
FGPolygon out_list;
|
||||
Point3D p;
|
||||
|
||||
out_list.erase();
|
||||
for ( int i = 0; i < (int)in_list.contour_size( 0 ); ++i ) {
|
||||
p = cart_to_polar_2d( in_list.get_pt( 0, i ) );
|
||||
out_list.add_node( 0, p );
|
||||
}
|
||||
|
||||
return out_list;
|
||||
}
|
||||
|
||||
|
||||
// given a set of 2d coordinates relative to a center point, and the
|
||||
// lon, lat of that center point (specified in degrees), as well as a
|
||||
// potential orientation angle, generate the corresponding lon and lat
|
||||
// of the original 2d verticies.
|
||||
FGPolygon gen_area(Point3D origin, double angle, const FGPolygon& cart_list) {
|
||||
FGPolygon rad_list;
|
||||
// given a runway center point, length, width, and heading, and
|
||||
// altitude (meters) generate the lon and lat 4 corners using wgs84
|
||||
// math.
|
||||
FGPolygon gen_wgs84_area( Point3D origin, double length_m, double width_m,
|
||||
double heading_deg, double alt_m, bool add_mid )
|
||||
{
|
||||
FGPolygon result_list;
|
||||
Point3D p;
|
||||
int i;
|
||||
double length_hdg = heading_deg;
|
||||
double left_hdg = length_hdg - 90.0;
|
||||
if ( left_hdg < 0 ) { left_hdg += 360.0; }
|
||||
|
||||
// convert to polar coordinates
|
||||
rad_list = batch_cart_to_polar_2d(cart_list);
|
||||
// move to the +l end/center of the runway
|
||||
Point3D ref = origin;
|
||||
double lon, lat, r;
|
||||
geo_direct_wgs_84 ( alt_m, ref.lat(), ref.lon(), length_hdg,
|
||||
length_m / 2.0, &lat, &lon, &r );
|
||||
ref = Point3D( lon, lat, 0.0 );
|
||||
|
||||
// display points
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, "converted to polar");
|
||||
// for ( i = 0; i < rad_list.contour_size( 0 ); ++i ) {
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, " " << rad_list.get_pt(0, i));
|
||||
// }
|
||||
// move to the l,-w corner (then we add points in a clockwise direction)
|
||||
geo_direct_wgs_84 ( alt_m, ref.lat(), ref.lon(), left_hdg,
|
||||
-width_m / 2.0, &lat, &lon, &r );
|
||||
Point3D p = Point3D( lon, lat, 0.0 );
|
||||
result_list.add_node( 0, p );
|
||||
|
||||
// rotate by specified angle
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, "Rotating points by " << angle);
|
||||
for ( i = 0; i < rad_list.contour_size( 0 ); ++i) {
|
||||
p = rad_list.get_pt( 0, i );
|
||||
double theta = p.y() + angle;
|
||||
while ( theta < SGD_2PI ) {
|
||||
theta += SGD_2PI;
|
||||
}
|
||||
p.sety( theta );
|
||||
rad_list.set_pt( 0, i, p );
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, " " << p);
|
||||
// move to the l,w corner
|
||||
geo_direct_wgs_84 ( alt_m, ref.lat(), ref.lon(), left_hdg,
|
||||
width_m / 2.0, &lat, &lon, &r );
|
||||
p = Point3D( lon, lat, 0.0 );
|
||||
result_list.add_node( 0, p );
|
||||
|
||||
if ( add_mid ) {
|
||||
// move to the 0,w point (then we add points in a clockwise direction)
|
||||
|
||||
ref = origin;
|
||||
geo_direct_wgs_84 ( alt_m, ref.lat(), ref.lon(), left_hdg,
|
||||
width_m / 2.0, &lat, &lon, &r );
|
||||
p = Point3D( lon, lat, 0.0 );
|
||||
result_list.add_node( 0, p );
|
||||
}
|
||||
|
||||
// find actual lon,lat of coordinates
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, "convert to lon, lat relative to " << origin);
|
||||
for ( i = 0; i < (int)rad_list.contour_size( 0 ); ++i ) {
|
||||
// p = calc_lon_lat(origin_rad, rad_list.get_pt(0, i) );
|
||||
// move to the -l end/center of the runway
|
||||
ref = origin;
|
||||
geo_direct_wgs_84 ( alt_m, ref.lat(), ref.lon(), length_hdg,
|
||||
-length_m / 2.0, &lat, &lon, &r );
|
||||
ref = Point3D( lon, lat, 0.0 );
|
||||
|
||||
double lat2, lon2, az2;
|
||||
geo_direct_wgs_84 ( 0, origin.y(), origin.x(),
|
||||
rad_list.get_pt(0, i).y() * SGD_RADIANS_TO_DEGREES,
|
||||
rad_list.get_pt(0, i).x(),
|
||||
&lat2, &lon2, &az2 );
|
||||
// move to the -l,w corner (then we add points in a clockwise direction)
|
||||
geo_direct_wgs_84 ( alt_m, ref.lat(), ref.lon(), left_hdg,
|
||||
width_m / 2.0, &lat, &lon, &r );
|
||||
p = Point3D( lon, lat, 0.0 );
|
||||
result_list.add_node( 0, p );
|
||||
|
||||
// convert from radians to degress
|
||||
p.setx( lon2 );
|
||||
p.sety( lat2 );
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, " " << p);
|
||||
result_list.add_node( 0, p );
|
||||
// move to the -l,-w corner
|
||||
geo_direct_wgs_84 ( alt_m, ref.lat(), ref.lon(), left_hdg,
|
||||
-width_m / 2.0, &lat, &lon, &r );
|
||||
p = Point3D( lon, lat, 0.0 );
|
||||
result_list.add_node( 0, p );
|
||||
|
||||
if ( add_mid ) {
|
||||
// move to the 0,-w point (then we add points in a clockwise direction)
|
||||
|
||||
ref = origin;
|
||||
geo_direct_wgs_84 ( alt_m, ref.lat(), ref.lon(), left_hdg,
|
||||
-width_m / 2.0, &lat, &lon, &r );
|
||||
p = Point3D( lon, lat, 0.0 );
|
||||
result_list.add_node( 0, p );
|
||||
}
|
||||
|
||||
return result_list;
|
||||
|
@ -117,43 +109,23 @@ FGPolygon gen_area(Point3D origin, double angle, const FGPolygon& cart_list) {
|
|||
// generate an area for a runway with expantion specified as a scale
|
||||
// factor (return result points in degrees)
|
||||
FGPolygon gen_runway_area_w_scale( const FGRunway& runway,
|
||||
double alt_m,
|
||||
double len_scale,
|
||||
double width_scale ) {
|
||||
|
||||
FGPolygon result_list;
|
||||
FGPolygon tmp_list;
|
||||
|
||||
double l, w;
|
||||
|
||||
/*
|
||||
printf("runway: lon = %.2f lat = %.2f hdg = %.2f len = %.2f width = %.2f\n",
|
||||
lon, lat, heading, length, width);
|
||||
*/
|
||||
|
||||
Point3D origin(runway.lon, runway.lat, 0);
|
||||
l = runway.length * len_scale * SG_FEET_TO_METER / 2.0;
|
||||
w = runway.width * width_scale * SG_FEET_TO_METER / 2.0;
|
||||
|
||||
// generate untransformed runway area vertices
|
||||
tmp_list.add_node( 0, Point3D( l, w, 0 ) );
|
||||
tmp_list.add_node( 0, Point3D( l, -w, 0 ) );
|
||||
tmp_list.add_node( 0, Point3D( -l, -w, 0 ) );
|
||||
tmp_list.add_node( 0, Point3D( -l, w, 0 ) );
|
||||
result_list = gen_wgs84_area( origin,
|
||||
runway.length * len_scale * SG_FEET_TO_METER,
|
||||
runway.width * len_scale * SG_FEET_TO_METER,
|
||||
runway.heading, alt_m, false );
|
||||
|
||||
// display points
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, "Untransformed, unrotated runway");
|
||||
// for ( int i = 0; i < tmp_list.contour_size( 0 ); ++i ) {
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, " " << tmp_list.get_pt(0, i));
|
||||
// }
|
||||
|
||||
// rotate, transform, and convert points to lon, lat in degrees
|
||||
result_list = gen_area(origin, runway.heading * SGD_DEGREES_TO_RADIANS, tmp_list);
|
||||
|
||||
// display points
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, "Results in radians.");
|
||||
// for ( int i = 0; i < result_list.contour_size( 0 ); ++i ) {
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, " " << result_list.get_pt(0, i));
|
||||
// }
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Results w/ scale (new way)");
|
||||
for ( int i = 0; i < result_list.contour_size( 0 ); ++i ) {
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, " " << result_list.get_pt(0, i));
|
||||
}
|
||||
|
||||
return result_list;
|
||||
}
|
||||
|
@ -161,44 +133,25 @@ FGPolygon gen_runway_area_w_scale( const FGRunway& runway,
|
|||
|
||||
// generate an area for a runway with expansion specified in meters
|
||||
// (return result points in degrees)
|
||||
FGPolygon gen_runway_area_w_expand( const FGRunway& runway,
|
||||
double len_expand,
|
||||
double wid_expand ) {
|
||||
FGPolygon gen_runway_area_w_extend( const FGRunway& runway,
|
||||
double alt_m,
|
||||
double len_extend,
|
||||
double wid_extend ) {
|
||||
|
||||
FGPolygon result_list;
|
||||
FGPolygon tmp_list;
|
||||
|
||||
double l, w;
|
||||
|
||||
/*
|
||||
printf("runway: lon = %.2f lat = %.2f hdg = %.2f len = %.2f width = %.2f\n",
|
||||
lon, lat, heading, length, width);
|
||||
*/
|
||||
|
||||
Point3D origin(runway.lon, runway.lat, 0);
|
||||
l = runway.length * SG_FEET_TO_METER / 2.0 + len_expand;
|
||||
w = runway.width * SG_FEET_TO_METER / 2.0 + wid_expand;
|
||||
|
||||
// generate untransformed runway area vertices
|
||||
tmp_list.add_node( 0, Point3D( l, w, 0 ) );
|
||||
tmp_list.add_node( 0, Point3D( l, -w, 0 ) );
|
||||
tmp_list.add_node( 0, Point3D( -l, -w, 0 ) );
|
||||
tmp_list.add_node( 0, Point3D( -l, w, 0 ) );
|
||||
result_list
|
||||
= gen_wgs84_area( origin,
|
||||
runway.length * SG_FEET_TO_METER + 2.0 * len_extend,
|
||||
runway.width * SG_FEET_TO_METER + 2.0 * len_extend,
|
||||
runway.heading, alt_m, false );
|
||||
|
||||
// display points
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, "Untransformed, unrotated runway");
|
||||
// for ( int i = 0; i < tmp_list.contour_size( 0 ); ++i ) {
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, " " << tmp_list.get_pt(0, i));
|
||||
// }
|
||||
|
||||
// rotate, transform, and convert points to lon, lat in degrees
|
||||
result_list = gen_area(origin, runway.heading * SGD_DEGREES_TO_RADIANS, tmp_list);
|
||||
|
||||
// display points
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, "Results in radians.");
|
||||
// for ( int i = 0; i < result_list.contour_size( 0 ); ++i ) {
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, " " << result_list.get_pt(0, i));
|
||||
// }
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Results w/ extend (new way)");
|
||||
for ( int i = 0; i < result_list.contour_size( 0 ); ++i ) {
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, " " << result_list.get_pt(0, i));
|
||||
}
|
||||
|
||||
return result_list;
|
||||
}
|
||||
|
@ -206,44 +159,24 @@ FGPolygon gen_runway_area_w_expand( const FGRunway& runway,
|
|||
|
||||
// generate an area for a runway and include midpoints
|
||||
FGPolygon gen_runway_w_mid( const FGRunway& runway,
|
||||
double len_scale,
|
||||
double width_scale ) {
|
||||
double alt_m,
|
||||
double len_extend_m,
|
||||
double wid_extend_m ) {
|
||||
FGPolygon result_list;
|
||||
FGPolygon tmp_list;
|
||||
|
||||
double l, w;
|
||||
|
||||
/*
|
||||
printf("runway: lon = %.2f lat = %.2f hdg = %.2f len = %.2f width = %.2f\n",
|
||||
lon, lat, heading, length, width);
|
||||
*/
|
||||
|
||||
Point3D origin(runway.lon, runway.lat, 0);
|
||||
l = runway.length * len_scale * SG_FEET_TO_METER / 2.0;
|
||||
w = runway.width * width_scale * SG_FEET_TO_METER / 2.0;
|
||||
|
||||
// generate untransformed runway area vertices
|
||||
tmp_list.add_node( 0, Point3D( l, w, 0 ) );
|
||||
tmp_list.add_node( 0, Point3D( l, -w, 0 ) );
|
||||
tmp_list.add_node( 0, Point3D( 0, -w, 0 ) );
|
||||
tmp_list.add_node( 0, Point3D( -l, -w, 0 ) );
|
||||
tmp_list.add_node( 0, Point3D( -l, w, 0 ) );
|
||||
tmp_list.add_node( 0, Point3D( 0, w, 0 ) );
|
||||
result_list = gen_wgs84_area( origin,
|
||||
runway.length * SG_FEET_TO_METER
|
||||
+ 2.0 * len_extend_m,
|
||||
runway.width * SG_FEET_TO_METER
|
||||
+ 2.0 * wid_extend_m,
|
||||
runway.heading, alt_m, true );
|
||||
|
||||
// display points
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, "Untransformed, unrotated runway");
|
||||
// for ( int i = 0; i < tmp_list.contour_size( 0 ); ++i ) {
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, " " << tmp_list.get_pt(0, i));
|
||||
// }
|
||||
|
||||
// rotate, transform, and convert points to lon, lat in degrees
|
||||
result_list = gen_area(origin, runway.heading * SGD_DEGREES_TO_RADIANS, tmp_list);
|
||||
|
||||
// display points
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, "Results in radians.");
|
||||
// for ( int i = 0; i < result_list.contour_size( 0 ); ++i ) {
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, " " << result_list.get_pt(0, i));
|
||||
// }
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Results w/ mid (new way)");
|
||||
for ( int i = 0; i < result_list.contour_size( 0 ); ++i ) {
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, " " << result_list.get_pt(0, i));
|
||||
}
|
||||
|
||||
return result_list;
|
||||
}
|
||||
|
|
|
@ -70,20 +70,23 @@ typedef runway_list::const_iterator const_runway_list_iterator;
|
|||
// generate an area for a runway with expantion specified as a scale
|
||||
// factor (return result points in degrees)
|
||||
FGPolygon gen_runway_area_w_scale( const FGRunway& runway,
|
||||
double alt_m,
|
||||
double len_scale = 1.0,
|
||||
double width_scale = 1.0 );
|
||||
|
||||
// generate an area for a runway with expansion specified in meters
|
||||
// (return result points in degrees)
|
||||
FGPolygon gen_runway_area_w_expand( const FGRunway& runway,
|
||||
double len_expand = 0.0,
|
||||
double wid_expand = 0.0 );
|
||||
FGPolygon gen_runway_area_w_extend( const FGRunway& runway,
|
||||
double alt_m,
|
||||
double len_extend = 0.0,
|
||||
double wid_extend = 0.0 );
|
||||
|
||||
|
||||
// generate an area for half a runway
|
||||
FGPolygon gen_runway_w_mid( const FGRunway& runway,
|
||||
double len_scale = 1.0,
|
||||
double width_scale = 1.0 );
|
||||
double alt_m,
|
||||
double len_extend_m = 0.0,
|
||||
double wid_extend_m = 0.0 );
|
||||
|
||||
|
||||
#endif // _RUNWAY_HXX
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
//
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/constants.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include "rwy_common.hxx"
|
||||
|
@ -34,6 +35,7 @@
|
|||
// document AC 150/5340-1H
|
||||
|
||||
void gen_non_precision_rwy( const FGRunway& rwy_info,
|
||||
double alt_m,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
|
@ -45,7 +47,9 @@ void gen_non_precision_rwy( const FGRunway& rwy_info,
|
|||
// Generate the basic runway outlines
|
||||
//
|
||||
|
||||
FGPolygon runway = gen_runway_w_mid( rwy_info );
|
||||
FGPolygon runway = gen_runway_w_mid( rwy_info, alt_m,
|
||||
2 * SG_FEET_TO_METER,
|
||||
2 * SG_FEET_TO_METER );
|
||||
|
||||
// runway half "a"
|
||||
FGPolygon runway_a;
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
// document AC 150/5340-1H
|
||||
|
||||
void gen_non_precision_rwy( const FGRunway& rwy_info,
|
||||
double alt_m,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
//
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/constants.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include "rwy_common.hxx"
|
||||
|
@ -34,6 +35,7 @@
|
|||
// document AC 150/5340-1H
|
||||
|
||||
void gen_precision_rwy( const FGRunway& rwy_info,
|
||||
double alt_m,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
|
@ -46,7 +48,9 @@ void gen_precision_rwy( const FGRunway& rwy_info,
|
|||
|
||||
int i, j;
|
||||
|
||||
FGPolygon runway = gen_runway_w_mid( rwy_info );
|
||||
FGPolygon runway = gen_runway_w_mid( rwy_info, alt_m,
|
||||
2 * SG_FEET_TO_METER,
|
||||
2 * SG_FEET_TO_METER );
|
||||
|
||||
// runway half "a"
|
||||
FGPolygon runway_a;
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
// document AC 150/5340-1H
|
||||
|
||||
void gen_precision_rwy( const FGRunway& rwy_info,
|
||||
double alt_m,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
|
|
|
@ -34,14 +34,16 @@
|
|||
|
||||
// generate a simple runway. The routine modifies rwy_polys,
|
||||
// texparams, and accum
|
||||
void gen_simple_rwy( const FGRunway& rwy_info, const string& material,
|
||||
void gen_simple_rwy( const FGRunway& rwy_info,
|
||||
double alt_m,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum )
|
||||
{
|
||||
int j, k;
|
||||
|
||||
FGPolygon runway = gen_runway_w_mid( rwy_info );
|
||||
FGPolygon runway = gen_runway_w_mid( rwy_info, alt_m );
|
||||
|
||||
// runway half "a"
|
||||
FGPolygon runway_a;
|
||||
|
|
|
@ -35,7 +35,9 @@
|
|||
|
||||
// generate a simple runway. The routine modifies rwy_polys,
|
||||
// texparams, and accum
|
||||
void gen_simple_rwy( const FGRunway& rwy_info, const string& material,
|
||||
void gen_simple_rwy( const FGRunway& rwy_info,
|
||||
double alt_m,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum );
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/constants.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include "rwy_common.hxx"
|
||||
|
@ -35,6 +36,7 @@
|
|||
// 150/5340-1H
|
||||
|
||||
void gen_visual_rwy( const FGRunway& rwy_info,
|
||||
double alt_m,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
|
@ -46,7 +48,9 @@ void gen_visual_rwy( const FGRunway& rwy_info,
|
|||
// Generate the basic runway outlines
|
||||
//
|
||||
|
||||
FGPolygon runway = gen_runway_w_mid( rwy_info );
|
||||
FGPolygon runway = gen_runway_w_mid( rwy_info, alt_m,
|
||||
2 * SG_FEET_TO_METER,
|
||||
2 * SG_FEET_TO_METER );
|
||||
|
||||
// runway half "a"
|
||||
FGPolygon runway_a;
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
// 150/5340-1H
|
||||
|
||||
void gen_visual_rwy( const FGRunway& rwy_info,
|
||||
double alt_m,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
|
|
|
@ -34,14 +34,16 @@
|
|||
|
||||
// generate a taxiway. The routine modifies rwy_polys, texparams, and
|
||||
// accum
|
||||
void gen_taxiway( const FGRunway& rwy_info, const string& material,
|
||||
void gen_taxiway( const FGRunway& rwy_info,
|
||||
double alt_m,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum )
|
||||
{
|
||||
int j, k;
|
||||
|
||||
FGPolygon runway = gen_runway_w_mid( rwy_info );
|
||||
FGPolygon runway = gen_runway_w_mid( rwy_info, alt_m );
|
||||
|
||||
// runway half "a"
|
||||
FGPolygon runway_a;
|
||||
|
|
|
@ -35,7 +35,9 @@
|
|||
|
||||
// generate a taxiway. The routine modifies rwy_polys, texparams, and
|
||||
// accum
|
||||
void gen_taxiway( const FGRunway& rwy_info, const string& material,
|
||||
void gen_taxiway( const FGRunway& rwy_info,
|
||||
double alt_m,
|
||||
const string& material,
|
||||
superpoly_list *rwy_polys,
|
||||
texparams_list *texparams,
|
||||
FGPolygon *accum );
|
||||
|
|
Loading…
Add table
Reference in a new issue