1
0
Fork 0

Convert threshold lights to SGGeod and simplify the routine

This commit is contained in:
Christian Schmitt 2012-10-23 13:29:51 +02:00
parent 5e796d2dd5
commit 1c8dbead04

View file

@ -205,7 +205,7 @@ superpoly_list Runway::gen_runway_edge_lights( bool recip )
return result; return result;
} }
// generate threshold lights for a 3 degree approach // generate threshold lights for displaced/normal runways and with/without light bars
superpoly_list Runway::gen_runway_threshold_lights( const int kind, bool recip ) superpoly_list Runway::gen_runway_threshold_lights( const int kind, bool recip )
{ {
point_list g_lights; g_lights.clear(); point_list g_lights; g_lights.clear();
@ -214,158 +214,93 @@ superpoly_list Runway::gen_runway_threshold_lights( const int kind, bool recip )
point_list r_normals; r_normals.clear(); point_list r_normals; r_normals.clear();
int i; int i;
point_list corner = gen_corners( 2.0, rwy.threshold[0], rwy.threshold[1], 2.0 );
// determine the start point. // determine the start point.
Point3D ref1, ref2; SGGeod ref1, ref2;
double length_hdg, left_hdg; double length_hdg;
double lon, lat, r;
if ( recip ) { if ( recip ) {
ref1 = corner[0]; length_hdg = SGMiscd::normalizePeriodic(0, 360, rwy.heading + 180);
ref2 = corner[1]; ref1 = SGGeodesy::direct(GetEnd(), length_hdg, rwy.threshold[get_thresh0(recip)] - 1);
length_hdg = rwy.heading + 180.0; ref2 = GetEnd();
if ( length_hdg > 360.0 ) { length_hdg -= 360.0; }
} else { } else {
ref1 = corner[2];
ref2 = corner[3];
length_hdg = rwy.heading; length_hdg = rwy.heading;
ref1 = SGGeodesy::direct(GetStart(), length_hdg, rwy.threshold[get_thresh0(recip)] - 1);
ref2 = GetStart();
} }
left_hdg = length_hdg - 90.0; double left_hdg = SGMiscd::normalizePeriodic(0, 360, length_hdg - 90.0);
if ( left_hdg < 0 ) { left_hdg += 360.0; }
Point3D normal1 = gen_runway_light_vector( 3.0, recip ); Point3D normal1 = gen_runway_light_vector( 3.0, recip );
Point3D normal2 = gen_runway_light_vector( 3.0, !recip ); Point3D normal2 = gen_runway_light_vector( 3.0, !recip );
// offset 1m downwind int divs = (int)(rwy.width + 4) / 3.0;
geo_direct_wgs_84 ( ref1.lat(), ref1.lon(), length_hdg, double step = (rwy.width + 4) / divs;
-1.0, &lat, &lon, &r ); SGGeod pt1, pt2;
ref1 = Point3D( lon, lat, 0.0 ); double offset = 2 + rwy.width * 0.5;
geo_direct_wgs_84 ( ref2.lat(), ref2.lon(), length_hdg,
-1.0, &lat, &lon, &r );
ref2 = Point3D( lon, lat, 0.0 );
int divs = (int)(rwy.width / 3.0) + 1; if ( GetsThreshold(recip) ) {
Point3D inc; SGGeod thresh1 = pt1 = SGGeodesy::direct(ref1, left_hdg, offset);
Point3D pt1 = ref1; SGGeod thresh2 = SGGeodesy::direct(ref1, left_hdg, -offset);
Point3D pt2 = ref2;
// We're at the threshold:
if ( GetsThreshold(recip) )
{
// four lights for each side // four lights for each side
for ( i = 0; i < 4; ++i ) { for ( i = 0; i < 4; ++i ) {
g_lights.push_back( pt1 ); g_lights.push_back( Point3D::fromSGGeod(thresh1) );
g_normals.push_back( normal1 ); g_normals.push_back( normal1 );
g_lights.push_back( pt2 ); g_lights.push_back( Point3D::fromSGGeod(thresh2) );
g_normals.push_back( normal1 ); g_normals.push_back( normal1 );
// offset 3m towards outside // offset 3m towards outside
geo_direct_wgs_84 ( pt1.lat(), pt1.lon(), left_hdg, thresh1 = SGGeodesy::direct(thresh1, left_hdg, 3);
3, &lat, &lon, &r ); thresh2 = SGGeodesy::direct(thresh2, left_hdg, -3);
pt1 = Point3D( lon, lat, 0.0 );
geo_direct_wgs_84 ( pt2.lat(), pt2.lon(), left_hdg,
-3, &lat, &lon, &r );
pt2 = Point3D( lon, lat, 0.0 );
} }
if ( kind ) } else {
{ pt1 = SGGeodesy::direct(ref2, left_hdg, offset);
// Add a green threshold lights bar in between the four lights }
Point3D pt1 = ref1;
inc = (ref2 - ref1) / divs; if ( kind ) {
pt1 += inc; // Add a green and red threshold lights bar
g_lights.push_back( pt1 ); SGGeod redbar = SGGeodesy::direct(ref2, left_hdg, offset);
for ( i = 0; i < divs + 1; ++i ) {
g_lights.push_back( Point3D::fromSGGeod(pt1) );
g_normals.push_back( normal1 ); g_normals.push_back( normal1 );
for ( i = 0; i < divs-2; ++i ) { r_lights.push_back( Point3D::fromSGGeod(redbar) );
pt1 += inc; r_normals.push_back( normal2 );
g_lights.push_back( pt1 ); pt1 = SGGeodesy::direct(pt1, left_hdg, -step);
g_normals.push_back( normal1 ); redbar = SGGeodesy::direct(redbar, left_hdg, -step);
}
} }
} }
// Now create the lights at the front of the runway
pt1 = SGGeodesy::direct(ref2, left_hdg, offset);
pt2 = SGGeodesy::direct(ref2, left_hdg, -offset);
// Now step to the front of the runway point_list tmp; tmp.clear();
geo_direct_wgs_84 ( ref1.lat(), ref1.lon(), length_hdg, point_list tmp_norm; tmp_norm.clear();
-rwy.threshold[get_thresh0(recip)], &lat, &lon, &r );
ref1 = Point3D( lon, lat, 0.0 );
geo_direct_wgs_84 ( ref2.lat(), ref2.lon(), length_hdg,
-rwy.threshold[get_thresh0(recip)], &lat, &lon, &r );
ref2 = Point3D( lon, lat, 0.0 );
Point3D front1 = ref1;
Point3D front2 = ref2;
if ( !kind )// Create groups of four lights in front of the displaced threshold // Create groups of four lights in front of the displaced threshold
{ for ( i = 0; i < 4; ++i ) {
for ( i = 0; i < 4; ++i ) { tmp.push_back( Point3D::fromSGGeod(pt1) );
if (GetsThreshold(recip)) tmp_norm.push_back( normal1 );
{ tmp.push_back( Point3D::fromSGGeod(pt2) );
r_lights.push_back( front1 ); tmp_norm.push_back( normal1 );
r_normals.push_back( normal1 );
r_lights.push_back( front2 ); if (!kind) {
r_normals.push_back( normal1 ); r_lights.push_back( Point3D::fromSGGeod(pt1) );
} else {
g_lights.push_back( front1 );
g_normals.push_back( normal1 );
g_lights.push_back( front2 );
g_normals.push_back( normal1 );
}
r_lights.push_back( front1 );
r_normals.push_back( normal2 ); r_normals.push_back( normal2 );
r_lights.push_back( Point3D::fromSGGeod(pt2) );
r_lights.push_back( front2 );
r_normals.push_back( normal2 ); r_normals.push_back( normal2 );
// offset 3m towards center
geo_direct_wgs_84 ( front1.lat(), front1.lon(), left_hdg,
-3, &lat, &lon, &r );
front1 = Point3D( lon, lat, 0.0 );
geo_direct_wgs_84 ( front2.lat(), front2.lon(), left_hdg,
3, &lat, &lon, &r );
front2 = Point3D( lon, lat, 0.0 );
}
} else {
// Create the red (green) threshold lights bar
Point3D pt1 = ref1;
inc = (ref2 - ref1) / divs;
if (!GetsThreshold(recip))
{
g_lights.push_back( pt1 );
g_normals.push_back( normal1 );
}
r_lights.push_back( pt1 );
r_normals.push_back( normal2 );
for ( i = 0; i < divs; ++i ) {
pt1 += inc;
r_lights.push_back( pt1 );
r_normals.push_back( normal2 );
if (!GetsThreshold(recip))
{
g_lights.push_back( pt1 );
g_normals.push_back( normal1 );
}
}
if (GetsThreshold(recip))
{ // In case of a threshold there is no bar at the front of the runway
for ( i = 0; i < 4; ++i ) {
r_lights.push_back( ref1 );
r_normals.push_back( normal1 );
r_lights.push_back( ref2 );
r_normals.push_back( normal1 );
// offset 3m towards center
geo_direct_wgs_84 ( ref1.lat(), ref1.lon(), left_hdg,
-3, &lat, &lon, &r );
ref1 = Point3D( lon, lat, 0.0 );
geo_direct_wgs_84 ( ref2.lat(), ref2.lon(), left_hdg,
3, &lat, &lon, &r );
ref2 = Point3D( lon, lat, 0.0 );
} }
} // offset 3m towards center
pt1 = SGGeodesy::direct(pt1, left_hdg, -3);
pt2 = SGGeodesy::direct(pt2, left_hdg, 3);
}
if (GetsThreshold(recip) ) {
r_lights.insert(r_lights.end(), tmp.begin(), tmp.end());
r_normals.insert(r_normals.end(), tmp_norm.begin(), tmp_norm.end());
} else if (!kind) {
g_lights.insert(g_lights.end(), tmp.begin(), tmp.end());
g_normals.insert(g_normals.end(), tmp_norm.begin(), tmp_norm.end());
} }
TGPolygon lights_poly; lights_poly.erase(); TGPolygon lights_poly; lights_poly.erase();