1
0
Fork 0

- fix taxiway texturing

- fix tgPolygon::FindIntermediateNodes
  we were messing up on east west segment nodes, so we had bad t-junctions
This commit is contained in:
Peter Sadrozinski 2012-11-13 21:09:23 -05:00 committed by Christian Schmitt
parent f6a08f3095
commit 79c9b17595
12 changed files with 193 additions and 59 deletions

View file

@ -183,6 +183,24 @@ bool Airport::isDebugPavement( int pvmt )
return dbg;
}
bool Airport::isDebugTaxiway( int taxi )
{
bool dbg = false;
debug_map_const_iterator it = debug_taxiways.find(icao);
if ( it != debug_taxiways.end() ) {
for ( unsigned int i=0; i<it->second.size() && !dbg; i++ ) {
if( it->second[i] == std::numeric_limits<int>::max() ) {
dbg = true;
} else if ( it->second[i] == taxi+1 ) {
dbg = true;
}
}
}
return dbg;
}
bool Airport::isDebugFeature( int feat )
{
bool dbg = false;
@ -297,7 +315,8 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
time_t log_time;
char shapefile_name[64];
std::string shapefile;
// Find the average of all the runway and heliport long / lats
int num_samples = 0;
for (unsigned int i=0; i<runways.size(); i++)
@ -420,14 +439,15 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
} else {
strcpy( shapefile_name, "" );
}
shapefile = shapefile_name;
if (boundary.size())
{
pavements[i]->BuildBtg( pvmt_polys, slivers, std::string(shapefile_name) );
pavements[i]->BuildBtg( pvmt_polys, slivers, shapefile );
}
else
{
pavements[i]->BuildBtg( pvmt_polys, slivers, apt_base, apt_clearing, std::string(shapefile_name) );
pavements[i]->BuildBtg( pvmt_polys, slivers, apt_base, apt_clearing, shapefile );
}
// Now try to merge any slivers we found
@ -447,13 +467,20 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
SG_LOG(SG_GENERAL, SG_INFO, "Build Taxiway " << i + 1 << " of " << taxiways.size());
slivers.clear();
if ( isDebugTaxiway(i) ) {
sprintf( shapefile_name, "taxiway_%d", i );
} else {
strcpy( shapefile_name, "" );
}
shapefile = shapefile_name;
if (boundary.size())
{
taxiways[i]->BuildBtg( pvmt_polys, rwy_lights, slivers, make_shapefiles );
taxiways[i]->BuildBtg( pvmt_polys, rwy_lights, slivers, shapefile );
}
else
{
taxiways[i]->BuildBtg( pvmt_polys, rwy_lights, slivers, apt_base, apt_clearing, make_shapefiles );
taxiways[i]->BuildBtg( pvmt_polys, rwy_lights, slivers, apt_base, apt_clearing, shapefile );
}
// Now try to merge any slivers we found
@ -513,10 +540,12 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
// build the base and clearing if there's a boundary
if (boundary.size())
{
shapefile = "";
for ( unsigned int i=0; i<boundary.size(); i++ )
{
SG_LOG(SG_GENERAL, SG_INFO, "Build Userdefined boundary " << i + 1 << " of " << boundary.size());
boundary[i]->BuildBtg( apt_base, apt_clearing, NULL );
boundary[i]->BuildBtg( apt_base, apt_clearing, shapefile );
}
}

View file

@ -122,15 +122,18 @@ public:
void set_debug( std::string& path,
debug_map& dbg_runways,
debug_map& dbg_pavements,
debug_map& dbg_taxiways,
debug_map& dbg_features ) {
debug_path = path;
debug_runways = dbg_runways;
debug_pavements = dbg_pavements;
debug_taxiways = dbg_taxiways;
debug_features = dbg_features;
};
bool isDebugRunway ( int i );
bool isDebugPavement( int i );
bool isDebugTaxiway ( int i );
bool isDebugFeature ( int i );
private:
@ -160,6 +163,7 @@ private:
string debug_path;
debug_map debug_runways;
debug_map debug_pavements;
debug_map debug_taxiways;
debug_map debug_features;
};

View file

@ -418,7 +418,7 @@ std::string ClosedPoly::GetMaterial( int surface )
return material;
}
int ClosedPoly::BuildBtg( tgpolygon_list& rwy_polys, tgcontour_list& slivers, tgPolygon& apt_base, tgPolygon& apt_clearing, std::string shapefile_name )
int ClosedPoly::BuildBtg( tgpolygon_list& rwy_polys, tgcontour_list& slivers, tgPolygon& apt_base, tgPolygon& apt_clearing, std::string& shapefile_name )
{
if (is_pavement && pre_tess.Contours() )
{
@ -440,7 +440,7 @@ int ClosedPoly::BuildBtg( tgpolygon_list& rwy_polys, tgcontour_list& slivers, tg
return 1;
}
int ClosedPoly::BuildBtg( tgpolygon_list& rwy_polys, tgcontour_list& slivers, std::string shapefile_name )
int ClosedPoly::BuildBtg( tgpolygon_list& rwy_polys, tgcontour_list& slivers, std::string& shapefile_name )
{
if ( is_pavement && pre_tess.Contours() )
{
@ -477,7 +477,7 @@ int ClosedPoly::BuildBtg( tgpolygon_list& rwy_polys, tgcontour_list& slivers, st
// Just used for user defined border - add a little bit, as some modelers made the border exactly on the edges
// - resulting in no base, which we can't handle
int ClosedPoly::BuildBtg( tgPolygon& apt_base, tgPolygon& apt_clearing, std::string shapefile_name )
int ClosedPoly::BuildBtg( tgPolygon& apt_base, tgPolygon& apt_clearing, std::string& shapefile_name )
{
tgPolygon base, safe_base;

View file

@ -27,18 +27,18 @@ public:
// Build BTG for airport base for airports with boundary
int BuildBtg( tgPolygon& apt_base,
tgPolygon& apt_clearing,
std::string shapefile_name );
std::string& shapefile_name );
// Build BTG for pavements for airports with no boundary
int BuildBtg( tgpolygon_list& rwy_polys,
tgcontour_list& slivers,
std::string shapefile_name );
std::string& shapefile_name );
int BuildBtg( tgpolygon_list& rwy_polys,
tgcontour_list& slivers,
tgPolygon& apt_base,
tgPolygon& apt_clearing,
std::string shapefile_name );
std::string& shapefile_name );
FeatureList* GetFeatures()
{

View file

@ -145,6 +145,7 @@ int main(int argc, char **argv)
string debug_dir = ".";
vector<string> debug_runway_defs;
vector<string> debug_pavement_defs;
vector<string> debug_taxiway_defs;
vector<string> debug_feature_defs;
// Set Normal logging
@ -270,6 +271,11 @@ int main(int argc, char **argv)
{
debug_pavement_defs.push_back( arg.substr(18) );
}
else if (arg.find("--debug-taxiways=") == 0)
{
SG_LOG(SG_GENERAL, SG_INFO, "add debug taxiway " << arg.substr(17) );
debug_taxiway_defs.push_back( arg.substr(17) );
}
else if (arg.find("--debug-features=") == 0)
{
debug_feature_defs.push_back( arg.substr(17) );
@ -366,7 +372,7 @@ int main(int argc, char **argv)
Scheduler* scheduler = new Scheduler(command, input_file, work_dir, elev_src);
// Add any debug
scheduler->set_debug( debug_dir, debug_runway_defs, debug_pavement_defs, debug_feature_defs );
scheduler->set_debug( debug_dir, debug_runway_defs, debug_pavement_defs, debug_taxiway_defs, debug_feature_defs );
// just one airport
if ( airport_id != "" )
@ -384,7 +390,7 @@ int main(int argc, char **argv)
{
// create and start the real parser
Parser parser(input_file, work_dir, elev_src);
parser.set_debug( debug_dir, debug_runway_defs, debug_pavement_defs, debug_feature_defs );
parser.set_debug( debug_dir, debug_runway_defs, debug_pavement_defs, debug_taxiway_defs, debug_feature_defs );
parser.Parse( airport_pos );
}
else if ( start_id != "" )

View file

@ -55,6 +55,7 @@ bool Parser::GetAirportDefinition( char* line, string& icao )
void Parser::set_debug( std::string path, std::vector<string> runway_defs,
std::vector<string> pavement_defs,
std::vector<string> taxiway_defs,
std::vector<string> feature_defs )
{
SG_LOG(SG_GENERAL, SG_ALERT, "Set debug Path " << path);
@ -120,6 +121,35 @@ void Parser::set_debug( std::string path, std::vector<string> runway_defs,
debug_pavements[icao] = shapes;
}
for (unsigned int i=0; i< taxiway_defs.size(); i++) {
string dsd = taxiway_defs[i];
size_t d_pos = dsd.find(":");
string icao = dsd.substr(0, d_pos);
std::vector<int> shapes;
shapes.clear();
dsd.erase(0, d_pos+1);
if ( dsd == "all" ) {
shapes.push_back( std::numeric_limits<int>::max() );
} else {
std::stringstream ss(dsd);
int i;
while (ss >> i)
{
SG_LOG(SG_GENERAL, SG_ALERT, "Adding debug taxiway " << i);
shapes.push_back(i);
if (ss.peek() == ',')
ss.ignore();
}
}
debug_taxiways[icao] = shapes;
}
for (unsigned int i=0; i< feature_defs.size(); i++) {
string dsd = feature_defs[i];
size_t d_pos = dsd.find(":");
@ -202,7 +232,7 @@ void Parser::Parse( long pos )
// write the airport BTG
if (cur_airport)
{
cur_airport->set_debug( debug_path, debug_runways, debug_pavements, debug_features );
cur_airport->set_debug( debug_path, debug_runways, debug_pavements, debug_taxiways, debug_features );
cur_airport->BuildBtg( work_dir, elevation );
cur_airport->GetBuildTime( build_time );

View file

@ -88,6 +88,7 @@ public:
// Debug
void set_debug( std::string path, std::vector<std::string> runway_defs,
std::vector<std::string> pavement_defs,
std::vector<std::string> taxiway_defs,
std::vector<std::string> feature_defs );
private:
@ -128,6 +129,7 @@ private:
string debug_path;
debug_map debug_runways;
debug_map debug_pavements;
debug_map debug_taxiways;
debug_map debug_features;
};

View file

@ -195,7 +195,7 @@ ProcessList::ProcessList( int n, string& summaryfile, Scheduler* pScheduler ) :
// When a slot is available, the main thread calls launch to instantiate a
// new pareser process
void ProcessList::Launch( string command, string work_dir, string file, AirportInfo* pai, bool last, string debug_path,
const debug_map& debug_runways, const debug_map& debug_pavements, const debug_map& debug_features )
const debug_map& debug_runways, const debug_map& debug_pavements, const debug_map& debug_taxiways, const debug_map& debug_features )
{
Process::Args args;
char arg[512];
@ -252,6 +252,23 @@ void ProcessList::Launch( string command, string work_dir, string file, AirportI
}
}
it = debug_taxiways.find( pai->GetIcao() );
std::string taxiway_def;
if ( it != debug_taxiways.end() ) {
taxiway_def = "--debug-taxiways=";
taxiway_def.append( pai->GetIcao() );
taxiway_def.append( ":" );
for ( unsigned int i=0; i < it->second.size(); i++ ) {
char int_str[16];
sprintf( int_str, "%d", it->second[i] );
taxiway_def.append( int_str );
if ( i < it->second.size()-1 ) {
taxiway_def.append( "," );
}
}
}
it = debug_features.find( pai->GetIcao() );
std::string feature_def;
if ( it != debug_features.end() ) {
@ -269,7 +286,7 @@ void ProcessList::Launch( string command, string work_dir, string file, AirportI
}
}
if ( runway_def.size() || pavement_def.size() || feature_def.size() ) {
if ( runway_def.size() || pavement_def.size() || taxiway_def.size() || feature_def.size() ) {
// sprintf( arg, "--debug-path=%s", debug_path.c_str() );
// SG_LOG( SG_GENERAL, SG_INFO, "Created debug path arg " << arg );
// args.push_back(arg);
@ -284,6 +301,11 @@ void ProcessList::Launch( string command, string work_dir, string file, AirportI
args.push_back( pavement_def.c_str() );
}
if ( taxiway_def.size() ) {
SG_LOG( SG_GENERAL, SG_INFO, "Created taxiway arg " << runway_def );
args.push_back( taxiway_def.c_str() );
}
if ( feature_def.size() ) {
SG_LOG( SG_GENERAL, SG_INFO, "Created feature arg " << feature_def );
args.push_back( feature_def.c_str() );
@ -524,6 +546,7 @@ void ProcessMonitor::run()
/*** SCEDULER ***/
void Scheduler::set_debug( std::string path, std::vector<string> runway_defs,
std::vector<string> pavement_defs,
std::vector<string> taxiway_defs,
std::vector<string> feature_defs )
{
SG_LOG(SG_GENERAL, SG_ALERT, "Set debug Path " << path);
@ -589,6 +612,35 @@ void Scheduler::set_debug( std::string path, std::vector<string> runway_defs,
debug_pavements[icao] = shapes;
}
for (unsigned int i=0; i< taxiway_defs.size(); i++) {
string dsd = taxiway_defs[i];
size_t d_pos = dsd.find(":");
string icao = dsd.substr(0, d_pos);
std::vector<int> shapes;
shapes.clear();
dsd.erase(0, d_pos+1);
if ( dsd == "all" ) {
shapes.push_back( std::numeric_limits<int>::max() );
} else {
std::stringstream ss(dsd);
int i;
while (ss >> i)
{
SG_LOG(SG_GENERAL, SG_ALERT, "Adding debug taxiway " << i << " for " << icao );
shapes.push_back(i);
if (ss.peek() == ',')
ss.ignore();
}
}
debug_taxiways[icao] = shapes;
}
for (unsigned int i=0; i< feature_defs.size(); i++) {
string dsd = feature_defs[i];
size_t d_pos = dsd.find(":");
@ -979,7 +1031,7 @@ void Scheduler::Schedule( int num_threads, string& summaryfile )
}
// Launch a new parser
procList->Launch( command, work_dir, filename, &originalList[i], last, debug_path, debug_runways, debug_pavements, debug_features );
procList->Launch( command, work_dir, filename, &originalList[i], last, debug_path, debug_runways, debug_pavements, debug_taxiways, debug_features );
}
// Sync up before relaunching

View file

@ -143,7 +143,7 @@ public:
// When a slot is available, the main thread calls launch to instantiate a
// new pareser process
void Launch( string command, string work_dir, string file, AirportInfo* pai, bool last, string debug_path,
const debug_map& debug_runways, const debug_map& debug_pavements, const debug_map& debug_features );
const debug_map& debug_runways, const debug_map& debug_pavements, const debug_map& debug_taxiways, const debug_map& debug_features );
Timespan GetNextTimeout();
void HandleReceivedMessages( Net::Socket::SocketList& slr );
void HandleTimeouts();
@ -187,6 +187,7 @@ public:
// Debug
void set_debug( std::string path, std::vector<std::string> runway_defs,
std::vector<std::string> pavement_defs,
std::vector<std::string> taxiway_defs,
std::vector<std::string> feature_defs );
@ -210,6 +211,6 @@ private:
string debug_path;
debug_map debug_runways;
debug_map debug_pavements;
debug_map debug_taxiways;
debug_map debug_features;
};
};

View file

@ -48,33 +48,12 @@ Taxiway::Taxiway(char* definition)
// adjust lat / lon to the start of the taxiway, not the middle
origin = SGGeodesy::direct( SGGeod::fromDeg(lon, lat), heading, -length/2 );
taxi_contour = gen_wgs84_rect( origin, heading, length, width );
}
int Taxiway::BuildBtg( tgpolygon_list& rwy_polys, tglightcontour_list& rwy_lights, tgcontour_list& slivers, tgPolygon& apt_base, tgPolygon& apt_clearing, bool make_shapefiles )
int Taxiway::BuildBtg( tgpolygon_list& rwy_polys, tglightcontour_list& rwy_lights, tgcontour_list& slivers, std::string& shapefile_name )
{
tgContour taxi;
tgContour base, safe_base;
BuildBtg( rwy_polys, rwy_lights, slivers, make_shapefiles );
// generate a poly for this segment
taxi = gen_wgs84_rect( origin, heading, length, width );
base = tgContour::Expand( taxi, 20.0);
safe_base = tgContour::Expand( taxi, 50.0);
// add this to the airport clearing
apt_clearing = tgPolygon::Union( safe_base, apt_clearing);
// and add the clearing to the base
apt_base = tgPolygon::Union( base, apt_base );
return 0;
}
int Taxiway::BuildBtg( tgpolygon_list& rwy_polys, tglightcontour_list& rwy_lights, tgcontour_list& slivers, bool make_shapefiles )
{
tgContour taxi;
std::string material;
if ( surface == 1 /* Asphalt */ )
@ -123,20 +102,49 @@ int Taxiway::BuildBtg( tgpolygon_list& rwy_polys, tglightcontour_list& rwy_light
throw sg_exception("unknown runway type!");
}
// generate a poly for this segment
taxi = gen_wgs84_rect( origin, heading, length, width );
if( shapefile_name.size() ) {
tgPolygon taxi_poly;
taxi_poly.AddContour( taxi_contour );
tgPolygon clipped = tgContour::DiffWithAccumulator( taxi );
tgPolygon::RemoveSlivers( clipped, slivers );
tgPolygon::ToShapefile( taxi_poly, "./airport_dbg", std::string("preclip"), shapefile_name );
tgPolygon::AccumulatorToShapefiles( "./airport_dbg", "accum" );
}
SG_LOG(SG_GENERAL, SG_DEBUG, "tw2 clipped = " << clipped.Contours());
tgPolygon clipped = tgContour::DiffWithAccumulator( taxi_contour );
tgPolygon split = tgPolygon::SplitLongEdges( clipped, 100 );
tgPolygon::RemoveSlivers( split, slivers );
clipped.SetMaterial( material );
clipped.SetTexParams( taxi.GetNode(0), width, 250*SG_FEET_TO_METER, heading );
clipped.SetTexMethod( TG_TEX_BY_TPS_CLIPUV, 0.0, 0.0, 1.0, 1.0 );
rwy_polys.push_back( clipped );
split.SetMaterial( material );
split.SetTexParams( taxi_contour.GetNode(0), width, 25*SG_FEET_TO_METER, heading );
split.SetTexLimits( 0.0, 0.0, 1.0, 1.0 );
split.SetTexMethod( TG_TEX_BY_TPS_CLIPU, -1.0, -1.0, 1.0, 1.0 );
rwy_polys.push_back( split );
tgContour::AddToAccumulator( taxi );
if( shapefile_name.size() ) {
tgPolygon::ToShapefile( split, "./airport_dbg", std::string("postclip"), shapefile_name );
}
tgContour::AddToAccumulator( taxi_contour );
return 0;
}
int Taxiway::BuildBtg( tgpolygon_list& rwy_polys, tglightcontour_list& rwy_lights, tgcontour_list& slivers, tgPolygon& apt_base, tgPolygon& apt_clearing, std::string& shapefile_name )
{
tgContour base, safe_base;
BuildBtg( rwy_polys, rwy_lights, slivers, shapefile_name );
base = tgContour::Expand( taxi_contour, 20.0);
safe_base = tgContour::Expand( taxi_contour, 50.0);
// add this to the airport clearing
apt_clearing = tgPolygon::Union( safe_base, apt_clearing);
// and add the clearing to the base
apt_base = tgPolygon::Union( base, apt_base );
return 0;
}

View file

@ -19,14 +19,14 @@ public:
int BuildBtg( tgpolygon_list& taxi_polys,
tglightcontour_list& taxi_lights,
tgcontour_list& slivers,
bool make_shapefiles );
std::string& shapefile_name );
int BuildBtg( tgpolygon_list& taxi_polys,
tglightcontour_list& taxi_lights,
tgcontour_list& slivers,
tgPolygon& apt_base,
tgPolygon& apt_clearing,
bool make_shapefiles );
std::string& shapefile_name );
private:
SGGeod origin;
@ -35,6 +35,8 @@ private:
double width;
int surface;
char lighting[8];
tgContour taxi_contour;
};
typedef std::vector <Taxiway *> TaxiwayList;

View file

@ -1123,7 +1123,7 @@ bool FindIntermediateNode( const SGGeod& start, const SGGeod& end,
}
m = (p_min.getLatitudeDeg() - p_max.getLatitudeDeg()) / (p_min.getLongitudeDeg() - p_max.getLongitudeDeg());
b = p_max.getLongitudeDeg() - m * p_max.getLatitudeDeg();
b = p_max.getLatitudeDeg() - m * p_max.getLongitudeDeg();
for ( int i = 0; i < (int)nodes.size(); ++i ) {
// cout << i << endl;