1
0
Fork 0

Add a second gen_wgs84_area function as preparation for shoulders.

This function uses the 2 runway end points as supplied by apt.dat,
which eliminates some inaccuracies that occur when calculating with
only one center point.
This commit is contained in:
Christian Schmitt 2011-10-19 18:24:56 +02:00
parent b24bcbb1ee
commit 09352611d5
4 changed files with 88 additions and 11 deletions

View file

@ -29,7 +29,7 @@
using std::string;
TGPolygon gen_wgs84_area( Point3D origin,
TGPolygon gen_wgs84_area( Point3D origin,
double length_m,
double displ1, double displ2,
double width_m,
@ -102,6 +102,79 @@ TGPolygon gen_wgs84_area( Point3D origin,
return result_list;
}
TGPolygon gen_wgs84_area( Point3D end1, Point3D end2,
double length_m,
double displ1, double displ2,
double width_m,
double heading_deg,
double alt_m,
bool add_mid )
{
TGPolygon result_list;
double left_hdg = heading_deg - 90.0;
if ( left_hdg < 0 ) { left_hdg += 360.0; }
// move from end2 to the displaced threshold
Point3D ref = end2;
double lon = 0, lat = 0, r = 0;
geo_direct_wgs_84 ( alt_m, ref.lat(), ref.lon(), heading_deg,
-displ2, &lat, &lon, &r );
ref = Point3D( lon, lat, 0.0 );
// 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 );
// 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 = Point3D( (end1.lon()+end2.lon())/2.0f, (end1.lat()+end2.lat())/2.0f, 0.0f);
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 );
}
// move to the end1 center to the displ. threshold
ref = end1;
geo_direct_wgs_84 ( alt_m, ref.lat(), ref.lon(), heading_deg,
displ1, &lat, &lon, &r );
ref = Point3D( lon, lat, 0.0 );
// 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 );
// 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 = Point3D( (end1.lon()+end2.lon())/2.0f, (end1.lat()+end2.lat())/2.0f, 0.0f);
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;
}
// generate a section of texture
void gen_tex_section( const TGPolygon& runway,
double startl_pct, double endl_pct,
@ -235,11 +308,7 @@ void gen_tex_section( const TGPolygon& runway,
double len = length / 2.0;
double sect_len = len * ( endl_pct - startl_pct );
// we add 0.6m to both sides of the runway (1.2m total) for texture
// overlap. This puts the lines on the texture back to the edge
// of the runway where they belong.
double wid = width + 1.2;
double sect_wid = wid * ( endw_pct - startw_pct );
double sect_wid = width * ( endw_pct - startw_pct );
TGTexParams tp;
tp = TGTexParams( p0,

View file

@ -15,6 +15,16 @@ using std::string;
TGPolygon gen_wgs84_area( Point3D origin, double length_m, double displ1, double displ2, double width_m, double heading_deg, double alt_m, bool add_mid );
// This function uses the 2 runway end points for calculation, which
// yields a higher precision
TGPolygon gen_wgs84_area( Point3D end1, Point3D end2,
double length_m,
double displ1, double displ2,
double width_m,
double heading_deg,
double alt_m,
bool add_mid );
void gen_tex_section( const TGPolygon& runway,
double startl_pct, double endl_pct,
double startw_pct, double endw_pct,

View file

@ -74,14 +74,14 @@ private:
// generate an area for a runway and include midpoints
TGPolygon gen_runway_w_mid( double alt_m, double length_extend_m, double width_extend_m )
{
return ( gen_wgs84_area(Point3D(GetMidpoint()), rwy.length + 2.0*length_extend_m, 0.0, 0.0, rwy.width + 2.0 * width_extend_m, rwy.heading, alt_m, true) );
return ( gen_wgs84_area( Point3D(GetStart()), Point3D(GetEnd()), rwy.length + 2.0*length_extend_m, 0.0, 0.0, rwy.width + 2.0 * width_extend_m, rwy.heading, alt_m, true) );
}
// generate an area for a runway with expansion specified in meters
// (return result points in degrees)
TGPolygon gen_runway_area_w_extend( double alt_m, double length_extend, double displ1, double displ2, double width_extend )
{
return ( gen_wgs84_area(Point3D(GetMidpoint()), rwy.length + 2.0*length_extend, displ1, displ2, rwy.width + 2.0*width_extend, rwy.heading, alt_m, false) );
return ( gen_wgs84_area( Point3D(GetStart()), Point3D(GetEnd()), rwy.length + 2.0*length_extend, displ1, displ2, rwy.width + 2.0*width_extend, rwy.heading, alt_m, false) );
}

View file

@ -149,9 +149,7 @@ void Runway::gen_rwy( double alt_m,
int i;
TGPolygon runway = gen_runway_w_mid( alt_m,
2 * SG_FEET_TO_METER,
2 * SG_FEET_TO_METER );
TGPolygon runway = gen_runway_w_mid( alt_m, 0, 0 );
TGPolygon runway_half;