Force each light in an approach lighting groups to have the same elevation
equal to the elevation of the highest light. Approach lighting systems don't rise and fall with the prevailing terrain. This prevents portions of the approach lighting system from dipping below ground level in cases where the surrounding terrain is simplified and doesn't perfectly match the DEM data.
This commit is contained in:
parent
5f502fc76b
commit
ab5ae52e7d
3 changed files with 406 additions and 332 deletions
|
@ -36,6 +36,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <map>
|
||||||
#include STL_STRING
|
#include STL_STRING
|
||||||
|
|
||||||
#include <plib/sg.h> // plib include
|
#include <plib/sg.h> // plib include
|
||||||
|
@ -168,8 +169,10 @@ static FGPolygon rwy_section_tex_coords( const FGPolygon& in_poly,
|
||||||
|
|
||||||
|
|
||||||
// fix node elevations. Offset is added to the final elevation
|
// fix node elevations. Offset is added to the final elevation
|
||||||
point_list calc_elevations( const string& root, const point_list& geod_nodes,
|
static point_list calc_elevations( const string& root,
|
||||||
double offset ) {
|
const point_list& geod_nodes,
|
||||||
|
double offset )
|
||||||
|
{
|
||||||
bool done = false;
|
bool done = false;
|
||||||
point_list result = geod_nodes;
|
point_list result = geod_nodes;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -255,7 +258,7 @@ static void my_chomp( string& str ) {
|
||||||
|
|
||||||
|
|
||||||
// build a runway
|
// build a runway
|
||||||
void build_runway( const FGRunway& rwy_info,
|
static void build_runway( const FGRunway& rwy_info,
|
||||||
double alt_m,
|
double alt_m,
|
||||||
superpoly_list *rwy_polys,
|
superpoly_list *rwy_polys,
|
||||||
texparams_list *texparams,
|
texparams_list *texparams,
|
||||||
|
@ -353,7 +356,8 @@ void build_runway( const FGRunway& rwy_info,
|
||||||
|
|
||||||
|
|
||||||
// build 3d airport
|
// build 3d airport
|
||||||
void build_airport( string airport_raw, float alt_m, string_list& runways_raw,
|
void build_airport( string airport_raw, float alt_m,
|
||||||
|
string_list& runways_raw,
|
||||||
string_list& taxiways_raw, const string& root )
|
string_list& taxiways_raw, const string& root )
|
||||||
{
|
{
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
|
@ -752,8 +756,8 @@ void build_airport( string airport_raw, float alt_m, string_list& runways_raw,
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "total size after = " << tri.total_size());
|
SG_LOG(SG_GENERAL, SG_DEBUG, "total size after = " << tri.total_size());
|
||||||
|
|
||||||
FGPolygon tc;
|
FGPolygon tc;
|
||||||
if ( rwy_polys[i].get_flag() ) {
|
if ( rwy_polys[i].get_flag() == "taxi" ) {
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "no clip");
|
SG_LOG(SG_GENERAL, SG_DEBUG, "taxiway, no clip");
|
||||||
tc = rwy_section_tex_coords( tri, texparams[i], false );
|
tc = rwy_section_tex_coords( tri, texparams[i], false );
|
||||||
} else {
|
} else {
|
||||||
tc = rwy_section_tex_coords( tri, texparams[i], true );
|
tc = rwy_section_tex_coords( tri, texparams[i], true );
|
||||||
|
@ -906,7 +910,8 @@ void build_airport( string airport_raw, float alt_m, string_list& runways_raw,
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate node elevations
|
// calculate node elevations
|
||||||
point_list geod_nodes = calc_elevations( root, nodes.get_node_list(), 0.0 );
|
point_list geod_nodes = calc_elevations( root, nodes.get_node_list(),
|
||||||
|
0.0 );
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Done with calc_elevations()");
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Done with calc_elevations()");
|
||||||
|
|
||||||
// add base skirt (to hide potential cracks)
|
// add base skirt (to hide potential cracks)
|
||||||
|
@ -1003,6 +1008,14 @@ void build_airport( string airport_raw, float alt_m, string_list& runways_raw,
|
||||||
}
|
}
|
||||||
|
|
||||||
// add light points
|
// add light points
|
||||||
|
|
||||||
|
superpoly_list tmp_light_list; tmp_light_list.clear();
|
||||||
|
typedef map < string, double, less<string> > elev_map_type;
|
||||||
|
typedef elev_map_type::const_iterator const_elev_map_iterator;
|
||||||
|
elev_map_type elevation_map;
|
||||||
|
|
||||||
|
// pass one, calculate raw elevations from DEM
|
||||||
|
|
||||||
for ( i = 0; i < (int)rwy_lights.size(); ++i ) {
|
for ( i = 0; i < (int)rwy_lights.size(); ++i ) {
|
||||||
FGTriNodes light_nodes;
|
FGTriNodes light_nodes;
|
||||||
light_nodes.clear();
|
light_nodes.clear();
|
||||||
|
@ -1013,9 +1026,49 @@ void build_airport( string airport_raw, float alt_m, string_list& runways_raw,
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate light node elevations
|
// calculate light node elevations
|
||||||
|
|
||||||
point_list geod_light_nodes
|
point_list geod_light_nodes
|
||||||
= calc_elevations( root, light_nodes.get_node_list(), 0.5 );
|
= calc_elevations( root, light_nodes.get_node_list(), 0.5 );
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Done with (light) calc_elevations()");
|
FGPolygon p;
|
||||||
|
p.add_contour( geod_light_nodes, 0 );
|
||||||
|
FGSuperPoly s;
|
||||||
|
s.set_poly( p );
|
||||||
|
tmp_light_list.push_back( s );
|
||||||
|
|
||||||
|
string flag = rwy_lights[i].get_flag();
|
||||||
|
if ( flag != (string)"" ) {
|
||||||
|
double max = -9999;
|
||||||
|
const_elev_map_iterator it = elevation_map.find( flag );
|
||||||
|
if ( it != elevation_map.end() ) {
|
||||||
|
max = elevation_map[rwy_lights[i].get_flag()];
|
||||||
|
}
|
||||||
|
for ( j = 0; j < (int)geod_light_nodes.size(); ++j ) {
|
||||||
|
if ( max < geod_light_nodes[i].z() ) {
|
||||||
|
max = geod_light_nodes[i].z();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elevation_map[rwy_lights[i].get_flag()] = max;
|
||||||
|
cout << "max = " << max << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// pass two, for each light group check if we need to lift (based
|
||||||
|
// on flag) and do so, then output next structures.
|
||||||
|
for ( i = 0; i < (int)rwy_lights.size(); ++i ) {
|
||||||
|
// tmp_light_list is a parallel structure to rwy_lights
|
||||||
|
point_list geod_light_nodes
|
||||||
|
= tmp_light_list[i].get_poly().get_contour(0);
|
||||||
|
|
||||||
|
string flag = rwy_lights[i].get_flag();
|
||||||
|
if ( flag != (string)"" ) {
|
||||||
|
const_elev_map_iterator it = elevation_map.find( flag );
|
||||||
|
if ( it != elevation_map.end() ) {
|
||||||
|
double force_elev = elevation_map[flag];
|
||||||
|
for ( j = 0; j < (int)geod_light_nodes.size(); ++j ) {
|
||||||
|
geod_light_nodes[j].setz( force_elev );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// this is a little round about, but what we want to calculate the
|
// this is a little round about, but what we want to calculate the
|
||||||
// light node elevations as ground + an offset so we do them
|
// light node elevations as ground + an offset so we do them
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -95,7 +95,7 @@ void gen_taxiway( const FGRunway& rwy_info,
|
||||||
|
|
||||||
sp.set_poly( split_a );
|
sp.set_poly( split_a );
|
||||||
sp.set_material( material );
|
sp.set_material( material );
|
||||||
sp.set_flag( 1 ); // mark as a taxiway
|
sp.set_flag( "taxi" ); // mark as a taxiway
|
||||||
rwy_polys->push_back( sp );
|
rwy_polys->push_back( sp );
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "clipped_a = " << clipped_a.contours());
|
SG_LOG(SG_GENERAL, SG_DEBUG, "clipped_a = " << clipped_a.contours());
|
||||||
*accum = polygon_union( runway_a, *accum );
|
*accum = polygon_union( runway_a, *accum );
|
||||||
|
|
Loading…
Reference in a new issue