Adding new construct style debug to genapt850.
format is --debug-runways=icao:rwy#,rw#... --debug-pavements=icao:rwy#,rw#... --debug-features=icao:feat#,feat#... I think it may be time to stop running each airport in its own process and run in seperate threads. The passing of parameters is geting confusing, and the reason for it seams to have disapeared with the removal of triangleJRS
This commit is contained in:
parent
620f941609
commit
76ee23a294
11 changed files with 458 additions and 101 deletions
|
@ -86,13 +86,6 @@ Airport::Airport( int c, char* def)
|
|||
|
||||
altitude *= SG_FEET_TO_METER;
|
||||
|
||||
dbg_rwy_poly = 0;
|
||||
dbg_pvmt_poly = 0;
|
||||
dbg_feat_poly = 0;
|
||||
dbg_base_poly = 0;
|
||||
dbg_taxi_poly = 0;
|
||||
|
||||
|
||||
SG_LOG( SG_GENERAL, SG_DEBUG, "Read airport with icao " << icao << ", control tower " << ct << ", and description " << description );
|
||||
}
|
||||
|
||||
|
@ -154,15 +147,61 @@ Airport::~Airport()
|
|||
}
|
||||
}
|
||||
|
||||
void Airport::SetDebugPolys( int rwy, int taxi, int pvmt, int feat, int base )
|
||||
bool Airport::isDebugRunway( int rwy )
|
||||
{
|
||||
dbg_rwy_poly = rwy;
|
||||
dbg_taxi_poly = taxi;
|
||||
dbg_pvmt_poly = pvmt;
|
||||
dbg_feat_poly = feat;
|
||||
dbg_base_poly = base;
|
||||
bool dbg = false;
|
||||
|
||||
debug_map_const_iterator it = debug_runways.find(icao);
|
||||
if ( it != debug_runways.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] == rwy+1 ) {
|
||||
dbg = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dbg;
|
||||
}
|
||||
|
||||
bool Airport::isDebugPavement( int pvmt )
|
||||
{
|
||||
bool dbg = false;
|
||||
|
||||
debug_map_const_iterator it = debug_pavements.find(icao);
|
||||
if ( it != debug_pavements.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] == pvmt+1 ) {
|
||||
dbg = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dbg;
|
||||
}
|
||||
|
||||
bool Airport::isDebugFeature( int feat )
|
||||
{
|
||||
bool dbg = false;
|
||||
|
||||
debug_map_const_iterator it = debug_features.find(icao);
|
||||
if ( it != debug_features.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] == feat+1 ) {
|
||||
dbg = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dbg;
|
||||
}
|
||||
|
||||
|
||||
// TODO : Add somewhere
|
||||
// Determine node elevations of a point_list based on the provided
|
||||
// TGAptSurface. Offset is added to the final elevation
|
||||
|
@ -257,6 +296,8 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
|||
SGTimeStamp triangulation_end;
|
||||
time_t log_time;
|
||||
|
||||
char shapefile_name[64];
|
||||
|
||||
// Find the average of all the runway and heliport long / lats
|
||||
int num_samples = 0;
|
||||
for (unsigned int i=0; i<runways.size(); i++)
|
||||
|
@ -374,13 +415,19 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
|||
SG_LOG(SG_GENERAL, SG_INFO, "Build Pavement " << i + 1 << " of " << pavements.size() << " : " << pavements[i]->GetDescription());
|
||||
slivers.clear();
|
||||
|
||||
if ( isDebugPavement(i) ) {
|
||||
sprintf( shapefile_name, "pvmnt_%d", i );
|
||||
} else {
|
||||
strcpy( shapefile_name, "" );
|
||||
}
|
||||
|
||||
if (boundary.size())
|
||||
{
|
||||
pavements[i]->BuildBtg( pvmt_polys, slivers, make_shapefiles );
|
||||
pavements[i]->BuildBtg( pvmt_polys, slivers, std::string(shapefile_name) );
|
||||
}
|
||||
else
|
||||
{
|
||||
pavements[i]->BuildBtg( pvmt_polys, slivers, apt_base, apt_clearing, make_shapefiles );
|
||||
pavements[i]->BuildBtg( pvmt_polys, slivers, apt_base, apt_clearing, std::string(shapefile_name) );
|
||||
}
|
||||
|
||||
// Now try to merge any slivers we found
|
||||
|
@ -469,7 +516,7 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
|||
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, false );
|
||||
boundary[i]->BuildBtg( apt_base, apt_clearing, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
|
||||
using std::string;
|
||||
|
||||
typedef std::map<std::string, std::vector<int>, std::less<std::string> > debug_map;
|
||||
typedef debug_map::iterator debug_map_iterator;
|
||||
typedef debug_map::const_iterator debug_map_const_iterator;
|
||||
|
||||
class Airport
|
||||
{
|
||||
public:
|
||||
|
@ -113,9 +117,22 @@ public:
|
|||
void merge_slivers( tgpolygon_list& polys, tgcontour_list& slivers );
|
||||
void BuildBtg( const string& root, const string_list& elev_src );
|
||||
|
||||
void SetDebugPolys( int rwy, int taxi, int pvmt, int feat, int base );
|
||||
void DumpStats( void );
|
||||
|
||||
void set_debug( std::string& path,
|
||||
debug_map& dbg_runways,
|
||||
debug_map& dbg_pavements,
|
||||
debug_map& dbg_features ) {
|
||||
debug_path = path;
|
||||
debug_runways = dbg_runways;
|
||||
debug_pavements = dbg_pavements;
|
||||
debug_features = dbg_features;
|
||||
};
|
||||
|
||||
bool isDebugRunway ( int i );
|
||||
bool isDebugPavement( int i );
|
||||
bool isDebugFeature ( int i );
|
||||
|
||||
private:
|
||||
int code; // airport, heliport or sea port
|
||||
int altitude; // in meters
|
||||
|
@ -140,11 +157,10 @@ private:
|
|||
SGTimeStamp triangulation_time;
|
||||
|
||||
// debug
|
||||
int dbg_rwy_poly;
|
||||
int dbg_taxi_poly;
|
||||
int dbg_pvmt_poly;
|
||||
int dbg_feat_poly;
|
||||
int dbg_base_poly;
|
||||
string debug_path;
|
||||
debug_map debug_runways;
|
||||
debug_map debug_pavements;
|
||||
debug_map debug_features;
|
||||
};
|
||||
|
||||
typedef std::vector <Airport *> AirportList;
|
||||
|
|
|
@ -418,13 +418,13 @@ std::string ClosedPoly::GetMaterial( int surface )
|
|||
return material;
|
||||
}
|
||||
|
||||
int ClosedPoly::BuildBtg( tgpolygon_list& rwy_polys, tgcontour_list& slivers, tgPolygon& apt_base, tgPolygon& apt_clearing, bool make_shapefiles )
|
||||
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() )
|
||||
{
|
||||
tgPolygon base, safe_base;
|
||||
|
||||
BuildBtg( rwy_polys, slivers, make_shapefiles );
|
||||
BuildBtg( rwy_polys, slivers, shapefile_name );
|
||||
|
||||
base = tgPolygon::Expand( pre_tess, 20.0 );
|
||||
safe_base = tgPolygon::Expand( pre_tess, 50.0);
|
||||
|
@ -440,13 +440,25 @@ int ClosedPoly::BuildBtg( tgpolygon_list& rwy_polys, tgcontour_list& slivers, tg
|
|||
return 1;
|
||||
}
|
||||
|
||||
int ClosedPoly::BuildBtg( tgpolygon_list& rwy_polys, tgcontour_list& slivers, bool make_shapefiles )
|
||||
int ClosedPoly::BuildBtg( tgpolygon_list& rwy_polys, tgcontour_list& slivers, std::string shapefile_name )
|
||||
{
|
||||
if ( is_pavement && pre_tess.Contours() )
|
||||
{
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "BuildBtg: original poly has " << pre_tess.Contours() << " contours" << " and " << pre_tess.TotalNodes() << " points" );
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "BuildBtg: original poly has " << pre_tess.Contours() << " contours" << " and " << pre_tess.TotalNodes() << " points : shapefile_name is " << shapefile_name );
|
||||
|
||||
if( shapefile_name.size() ) {
|
||||
tgPolygon::ToShapefile( pre_tess, "./airport_dbg", std::string("preclip"), shapefile_name );
|
||||
tgPolygon::AccumulatorToShapefiles( "./airport_dbg", "accum" );
|
||||
}
|
||||
|
||||
tgPolygon clipped = tgPolygon::DiffWithAccumulator( pre_tess );
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "BuildBtg: clipped poly has " << clipped.Contours() << " contours" << " and " << clipped.TotalNodes() << " points : shapefile_name is " << shapefile_name );
|
||||
|
||||
if( shapefile_name.size() ) {
|
||||
tgPolygon::ToShapefile( pre_tess, "./airport_dbg", std::string("postclip"), shapefile_name );
|
||||
}
|
||||
|
||||
tgPolygon::RemoveSlivers( clipped, slivers );
|
||||
|
||||
clipped.SetMaterial( GetMaterial( surface_type ) );
|
||||
|
@ -466,7 +478,7 @@ int ClosedPoly::BuildBtg( tgpolygon_list& rwy_polys, tgcontour_list& slivers, bo
|
|||
|
||||
// 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, bool make_shapefiles )
|
||||
int ClosedPoly::BuildBtg( tgPolygon& apt_base, tgPolygon& apt_clearing, std::string shapefile_name )
|
||||
{
|
||||
tgPolygon base, safe_base;
|
||||
|
||||
|
|
|
@ -27,18 +27,18 @@ public:
|
|||
// Build BTG for airport base for airports with boundary
|
||||
int BuildBtg( tgPolygon& apt_base,
|
||||
tgPolygon& apt_clearing,
|
||||
bool make_shapefiles );
|
||||
std::string shapefile_name );
|
||||
|
||||
// Build BTG for pavements for airports with no boundary
|
||||
int BuildBtg( tgpolygon_list& rwy_polys,
|
||||
tgcontour_list& slivers,
|
||||
bool make_shapefiles );
|
||||
std::string shapefile_name );
|
||||
|
||||
int BuildBtg( tgpolygon_list& rwy_polys,
|
||||
tgcontour_list& slivers,
|
||||
tgPolygon& apt_base,
|
||||
tgPolygon& apt_clearing,
|
||||
bool make_shapefiles );
|
||||
std::string shapefile_name );
|
||||
|
||||
FeatureList* GetFeatures()
|
||||
{
|
||||
|
|
|
@ -142,6 +142,11 @@ int main(int argc, char **argv)
|
|||
elev_src.clear();
|
||||
setup_default_elevation_sources(elev_src);
|
||||
|
||||
string debug_dir = ".";
|
||||
vector<string> debug_runway_defs;
|
||||
vector<string> debug_pavement_defs;
|
||||
vector<string> debug_feature_defs;
|
||||
|
||||
// Set Normal logging
|
||||
sglog().setLogLevels( SG_GENERAL, SG_INFO );
|
||||
|
||||
|
@ -154,11 +159,6 @@ int main(int argc, char **argv)
|
|||
string airport_id = "";
|
||||
long airport_pos = -1;
|
||||
string last_apt_file = "./last_apt.txt";
|
||||
int dump_rwy_poly = -1;
|
||||
int dump_taxi_poly = -1;
|
||||
int dump_pvmt_poly = -1;
|
||||
int dump_feat_poly = -1;
|
||||
int dump_base_poly = -1;
|
||||
int num_threads = 1;
|
||||
int redirect_port = -1;
|
||||
|
||||
|
@ -250,35 +250,31 @@ int main(int argc, char **argv)
|
|||
{
|
||||
slope_max = atof( arg.substr(12).c_str() );
|
||||
}
|
||||
else if ( (arg.find("--threads=") == 0) )
|
||||
else if ( (arg.find("--threads=") == 0) )
|
||||
{
|
||||
num_threads = atoi( arg.substr(10).c_str() );
|
||||
}
|
||||
else if ( (arg.find("--threads") == 0) )
|
||||
else if ( (arg.find("--threads") == 0) )
|
||||
{
|
||||
num_threads = Poco::Environment::processorCount();
|
||||
}
|
||||
else if ( arg.find("--dump-rwy=") == 0 )
|
||||
else if (arg.find("--debug-dir=") == 0)
|
||||
{
|
||||
dump_rwy_poly = atoi( arg.substr(11).c_str() );
|
||||
}
|
||||
else if ( arg.find("--dump-taxi=") == 0 )
|
||||
debug_dir = arg.substr(12);
|
||||
}
|
||||
else if (arg.find("--debug-runways=") == 0)
|
||||
{
|
||||
dump_taxi_poly = atoi( arg.substr(12).c_str() );
|
||||
}
|
||||
else if ( arg.find("--dump-pvmt=") == 0 )
|
||||
debug_runway_defs.push_back( arg.substr(16) );
|
||||
}
|
||||
else if (arg.find("--debug-pavements=") == 0)
|
||||
{
|
||||
dump_pvmt_poly = atoi( arg.substr(12).c_str() );
|
||||
}
|
||||
else if ( arg.find("--dump-feat=") == 0 )
|
||||
debug_pavement_defs.push_back( arg.substr(18) );
|
||||
}
|
||||
else if (arg.find("--debug-features=") == 0)
|
||||
{
|
||||
dump_feat_poly = atoi( arg.substr(12).c_str() );
|
||||
}
|
||||
else if ( arg.find("--dump-base=") == 0 )
|
||||
{
|
||||
dump_base_poly = atoi( arg.substr(12).c_str() );
|
||||
}
|
||||
else if ( (arg.find("--help") == 0) || (arg.find("-h") == 0) )
|
||||
debug_feature_defs.push_back( arg.substr(17) );
|
||||
}
|
||||
else if ( (arg.find("--help") == 0) || (arg.find("-h") == 0) )
|
||||
{
|
||||
help( argc, argv, elev_src );
|
||||
exit(-1);
|
||||
|
@ -290,6 +286,23 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
// check for output redirect
|
||||
if ( redirect_port >= 0 ) {
|
||||
|
||||
// create a stream socket back to the main process
|
||||
Net::SocketAddress sa( "localhost", redirect_port );
|
||||
ss.connect(sa);
|
||||
|
||||
// then a buffered stream to write to the socket
|
||||
os.rdbuf(&ssb);
|
||||
|
||||
// then hook up SG_LOG to the stream buf
|
||||
sglog().set_output( os );
|
||||
} else {
|
||||
// this is the main program -
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Launch command was " << argv[0] );
|
||||
}
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Run genapts with " << num_threads << " threads" );
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Input file = " << input_file);
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Terrain sources = ");
|
||||
|
@ -353,24 +366,7 @@ int main(int argc, char **argv)
|
|||
Scheduler* scheduler = new Scheduler(command, input_file, work_dir, elev_src);
|
||||
|
||||
// Add any debug
|
||||
// TODO : parser->SetDebugPolys( dump_rwy_poly, dump_taxi_poly, dump_pvmt_poly, dump_feat_poly, dump_base_poly );
|
||||
|
||||
// check for output redirect
|
||||
if ( redirect_port >= 0 ) {
|
||||
|
||||
// create a stream socket back to the main process
|
||||
Net::SocketAddress sa( "localhost", redirect_port );
|
||||
ss.connect(sa);
|
||||
|
||||
// then a buffered stream to write to the socket
|
||||
os.rdbuf(&ssb);
|
||||
|
||||
// then hook up SG_LOG to the stream buf
|
||||
sglog().set_output( os );
|
||||
} else {
|
||||
// this is the main program -
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Launch command was " << argv[0] );
|
||||
}
|
||||
scheduler->set_debug( debug_dir, debug_runway_defs, debug_pavement_defs, debug_feature_defs );
|
||||
|
||||
// just one airport
|
||||
if ( airport_id != "" )
|
||||
|
@ -388,7 +384,8 @@ int main(int argc, char **argv)
|
|||
{
|
||||
// create and start the real parser
|
||||
Parser parser(input_file, work_dir, elev_src);
|
||||
parser.Parse( airport_pos );
|
||||
parser.set_debug( debug_dir, debug_runway_defs, debug_pavement_defs, debug_feature_defs );
|
||||
parser.Parse( airport_pos );
|
||||
}
|
||||
else if ( start_id != "" )
|
||||
{
|
||||
|
|
|
@ -53,13 +53,101 @@ bool Parser::GetAirportDefinition( char* line, string& icao )
|
|||
return match;
|
||||
}
|
||||
|
||||
void Parser::SetDebugPolys( int rwy, int taxi, int pvmt, int feat, int base )
|
||||
void Parser::set_debug( std::string path, std::vector<string> runway_defs,
|
||||
std::vector<string> pavement_defs,
|
||||
std::vector<string> feature_defs )
|
||||
{
|
||||
rwy_poly = rwy;
|
||||
taxi_poly = taxi;
|
||||
pvmt_poly = pvmt;
|
||||
feat_poly = feat;
|
||||
base_poly = base;
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "Set debug Path " << path);
|
||||
|
||||
debug_path = path;
|
||||
|
||||
/* Find any ids for our tile */
|
||||
for (unsigned int i=0; i< runway_defs.size(); i++) {
|
||||
string dsd = runway_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 runway " << i);
|
||||
|
||||
shapes.push_back(i);
|
||||
|
||||
if (ss.peek() == ',')
|
||||
ss.ignore();
|
||||
}
|
||||
}
|
||||
debug_runways[icao] = shapes;
|
||||
}
|
||||
|
||||
for (unsigned int i=0; i< pavement_defs.size(); i++) {
|
||||
string dsd = pavement_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 pavement " << i);
|
||||
|
||||
shapes.push_back(i);
|
||||
|
||||
if (ss.peek() == ',')
|
||||
ss.ignore();
|
||||
}
|
||||
}
|
||||
debug_pavements[icao] = shapes;
|
||||
}
|
||||
|
||||
for (unsigned int i=0; i< feature_defs.size(); i++) {
|
||||
string dsd = feature_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 feature " << i);
|
||||
|
||||
shapes.push_back(i);
|
||||
|
||||
if (ss.peek() == ',')
|
||||
ss.ignore();
|
||||
}
|
||||
}
|
||||
debug_features[icao] = shapes;
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::Parse( long pos )
|
||||
|
@ -110,10 +198,11 @@ void Parser::Parse( long pos )
|
|||
|
||||
parse_end.stamp();
|
||||
parse_time = parse_end - parse_start;
|
||||
|
||||
|
||||
// write the airport BTG
|
||||
if (cur_airport)
|
||||
{
|
||||
cur_airport->set_debug( debug_path, debug_runways, debug_pavements, debug_features );
|
||||
cur_airport->BuildBtg( work_dir, elevation );
|
||||
|
||||
cur_airport->GetBuildTime( build_time );
|
||||
|
@ -393,7 +482,6 @@ int Parser::ParseLine(char* line)
|
|||
SetState( STATE_PARSE_SIMPLE );
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Parsing land airport: " << line);
|
||||
cur_airport = new Airport( code, line );
|
||||
cur_airport->SetDebugPolys( rwy_poly, taxi_poly, pvmt_poly, feat_poly, base_poly );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -406,7 +494,6 @@ int Parser::ParseLine(char* line)
|
|||
SetState( STATE_PARSE_SIMPLE );
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Parsing heliport: " << line);
|
||||
cur_airport = new Airport( code, line );
|
||||
cur_airport->SetDebugPolys( rwy_poly, taxi_poly, pvmt_poly, feat_poly, base_poly );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -81,17 +81,15 @@ public:
|
|||
cur_sign = NULL;
|
||||
prev_node = NULL;
|
||||
cur_state = STATE_NONE;
|
||||
|
||||
// Debug
|
||||
rwy_poly = -1;
|
||||
pvmt_poly = -1;
|
||||
feat_poly = -1;
|
||||
base_poly = -1;
|
||||
}
|
||||
|
||||
void SetDebugPolys( int rwy, int taxi, int pvmt, int feat, int base );
|
||||
void Parse( long pos );
|
||||
|
||||
// Debug
|
||||
void set_debug( std::string path, std::vector<std::string> runway_defs,
|
||||
std::vector<std::string> pavement_defs,
|
||||
std::vector<std::string> feature_defs );
|
||||
|
||||
private:
|
||||
bool IsAirportDefinition( char* line, string icao );
|
||||
bool GetAirportDefinition( char* line, string& icao );
|
||||
|
@ -127,11 +125,10 @@ private:
|
|||
Sign* cur_sign;
|
||||
|
||||
// debug
|
||||
int rwy_poly;
|
||||
int taxi_poly;
|
||||
int pvmt_poly;
|
||||
int feat_poly;
|
||||
int base_poly;
|
||||
string debug_path;
|
||||
debug_map debug_runways;
|
||||
debug_map debug_pavements;
|
||||
debug_map debug_features;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -194,7 +194,8 @@ 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 )
|
||||
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 )
|
||||
{
|
||||
Process::Args args;
|
||||
char arg[512];
|
||||
|
@ -216,6 +217,79 @@ void ProcessList::Launch( string command, string work_dir, string file, AirportI
|
|||
sprintf( arg, "--redirect-port=%d", GENAPT_PORT );
|
||||
args.push_back(arg);
|
||||
|
||||
// check if we have any debug defs
|
||||
debug_map_const_iterator it = debug_runways.find( pai->GetIcao() );
|
||||
std::string runway_def;
|
||||
if ( it != debug_runways.end() ) {
|
||||
runway_def = "--debug-runways=";
|
||||
runway_def.append( pai->GetIcao() );
|
||||
runway_def.append( ":" );
|
||||
for ( unsigned int i=0; i < it->second.size(); i++ ) {
|
||||
char int_str[16];
|
||||
sprintf( int_str, "%d", it->second[i] );
|
||||
runway_def.append( int_str );
|
||||
|
||||
if ( i < it->second.size()-1 ) {
|
||||
runway_def.append( "," );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it = debug_pavements.find( pai->GetIcao() );
|
||||
std::string pavement_def;
|
||||
if ( it != debug_pavements.end() ) {
|
||||
pavement_def = "--debug-pavements=";
|
||||
pavement_def.append( pai->GetIcao() );
|
||||
pavement_def.append( ":" );
|
||||
for ( unsigned int i=0; i < it->second.size(); i++ ) {
|
||||
char int_str[16];
|
||||
sprintf( int_str, "%d", it->second[i] );
|
||||
pavement_def.append( int_str );
|
||||
|
||||
if ( i < it->second.size()-1 ) {
|
||||
pavement_def.append( "," );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it = debug_features.find( pai->GetIcao() );
|
||||
std::string feature_def;
|
||||
if ( it != debug_features.end() ) {
|
||||
feature_def = "--debug-features=";
|
||||
feature_def.append( pai->GetIcao() );
|
||||
feature_def.append( ":" );
|
||||
for ( unsigned int i=0; i < it->second.size(); i++ ) {
|
||||
char int_str[16];
|
||||
sprintf( int_str, "%d", it->second[i] );
|
||||
pavement_def.append( int_str );
|
||||
|
||||
if ( i < it->second.size()-1 ) {
|
||||
feature_def.append( "," );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( runway_def.size() || pavement_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);
|
||||
|
||||
if ( runway_def.size() ) {
|
||||
SG_LOG( SG_GENERAL, SG_INFO, "Created runway arg " << runway_def );
|
||||
args.push_back( runway_def.c_str() );
|
||||
}
|
||||
|
||||
if ( pavement_def.size() ) {
|
||||
SG_LOG( SG_GENERAL, SG_INFO, "Created pavement arg " << pavement_def );
|
||||
args.push_back( pavement_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() );
|
||||
}
|
||||
}
|
||||
|
||||
// Launch the child process
|
||||
ProcessHandle ph = Process::launch(command, args, 0, &outPipe, &outPipe);
|
||||
|
||||
|
@ -448,6 +522,103 @@ void ProcessMonitor::run()
|
|||
}
|
||||
|
||||
/*** SCEDULER ***/
|
||||
void Scheduler::set_debug( std::string path, std::vector<string> runway_defs,
|
||||
std::vector<string> pavement_defs,
|
||||
std::vector<string> feature_defs )
|
||||
{
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "Set debug Path " << path);
|
||||
|
||||
debug_path = path;
|
||||
|
||||
/* Find any ids for our tile */
|
||||
for (unsigned int i=0; i< runway_defs.size(); i++) {
|
||||
string dsd = runway_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 runway " << i << " for " << icao );
|
||||
|
||||
shapes.push_back(i);
|
||||
|
||||
if (ss.peek() == ',')
|
||||
ss.ignore();
|
||||
}
|
||||
}
|
||||
debug_runways[icao] = shapes;
|
||||
}
|
||||
|
||||
for (unsigned int i=0; i< pavement_defs.size(); i++) {
|
||||
string dsd = pavement_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 pavement " << i << " for " << icao );
|
||||
|
||||
shapes.push_back(i);
|
||||
|
||||
if (ss.peek() == ',')
|
||||
ss.ignore();
|
||||
}
|
||||
}
|
||||
debug_pavements[icao] = shapes;
|
||||
}
|
||||
|
||||
for (unsigned int i=0; i< feature_defs.size(); i++) {
|
||||
string dsd = feature_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 feature " << i << " for " << icao );
|
||||
|
||||
shapes.push_back(i);
|
||||
|
||||
if (ss.peek() == ',')
|
||||
ss.ignore();
|
||||
}
|
||||
}
|
||||
debug_features[icao] = shapes;
|
||||
}
|
||||
}
|
||||
|
||||
bool Scheduler::IsAirportDefinition( char* line, string icao )
|
||||
{
|
||||
char* tok;
|
||||
|
@ -808,7 +979,7 @@ void Scheduler::Schedule( int num_threads, string& summaryfile )
|
|||
}
|
||||
|
||||
// Launch a new parser
|
||||
procList->Launch( command, work_dir, filename, &originalList[i], last );
|
||||
procList->Launch( command, work_dir, filename, &originalList[i], last, debug_path, debug_runways, debug_pavements, debug_features );
|
||||
}
|
||||
|
||||
// Sync up before relaunching
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <simgear/compiler.h>
|
||||
#include <simgear/math/sg_types.hxx>
|
||||
#include <simgear/timing/timestamp.hxx>
|
||||
#include <CGAL/Plane_3.h>
|
||||
#include <Geometry/rectangle.hxx>
|
||||
|
||||
#define P_STATE_INIT (0)
|
||||
|
@ -140,8 +141,9 @@ public:
|
|||
inline void WaitForSlot(void);
|
||||
|
||||
// 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 );
|
||||
// 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 );
|
||||
Timespan GetNextTimeout();
|
||||
void HandleReceivedMessages( Net::Socket::SocketList& slr );
|
||||
void HandleTimeouts();
|
||||
|
@ -182,6 +184,12 @@ public:
|
|||
|
||||
void Schedule( int num_threads, string& summaryfile );
|
||||
|
||||
// Debug
|
||||
void set_debug( std::string path, std::vector<std::string> runway_defs,
|
||||
std::vector<std::string> pavement_defs,
|
||||
std::vector<std::string> feature_defs );
|
||||
|
||||
|
||||
Net::ServerSocket* GetServerSocket( void ) { return &ss; }
|
||||
|
||||
private:
|
||||
|
@ -197,5 +205,11 @@ private:
|
|||
// List of positions in database file to parse
|
||||
parseList originalList;
|
||||
parseList retryList;
|
||||
|
||||
// debug
|
||||
string debug_path;
|
||||
debug_map debug_runways;
|
||||
debug_map debug_pavements;
|
||||
debug_map debug_features;
|
||||
};
|
||||
|
||||
|
|
|
@ -2087,6 +2087,21 @@ tg::Rectangle tgPolygon::GetBoundingBox( void ) const
|
|||
return tg::Rectangle( min, max );
|
||||
}
|
||||
|
||||
void clipperToShapefile( ClipperLib::Polygons polys, const std::string& path, const std::string&layer, const std::string& name )
|
||||
{
|
||||
tgPolygon poly = tgPolygon::FromClipper(polys);
|
||||
tgPolygon::ToShapefile( poly, path, layer, name);
|
||||
}
|
||||
|
||||
void tgPolygon::AccumulatorToShapefiles( const std::string& path, const std::string& layer )
|
||||
{
|
||||
char shapefile[16];
|
||||
for (unsigned int i=0; i < clipper_accumulator.size(); i++) {
|
||||
sprintf( shapefile, "accum_%d", i );
|
||||
clipperToShapefile( clipper_accumulator[i], path, layer, std::string(shapefile) );
|
||||
}
|
||||
}
|
||||
|
||||
tgPolygon tgPolygon::DiffWithAccumulator( const tgPolygon& subject )
|
||||
{
|
||||
tgPolygon result;
|
||||
|
@ -2106,9 +2121,6 @@ tgPolygon tgPolygon::DiffWithAccumulator( const tgPolygon& subject )
|
|||
for (unsigned int i=0; i < clipper_accumulator.size(); i++) {
|
||||
tg::Rectangle box2 = BoundingBox_FromClipper( clipper_accumulator[i] );
|
||||
|
||||
//get_Clipper_bounding_box( clipper_accumulator[i], min, max);
|
||||
//tg::Rectangle box2 = (min, max);
|
||||
|
||||
if ( box2.intersects(box1) )
|
||||
{
|
||||
c.AddPolygons(clipper_accumulator[i], ClipperLib::ptClip);
|
||||
|
@ -2121,6 +2133,9 @@ tgPolygon tgPolygon::DiffWithAccumulator( const tgPolygon& subject )
|
|||
SG_LOG(SG_GENERAL, SG_ALERT, "Diff With Accumulator returned FALSE" );
|
||||
exit(-1);
|
||||
}
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "Diff With Accumulator had " << num_hits << " hits " );
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, " cklipper_result has " << clipper_result.size() << " contours " );
|
||||
|
||||
result = tgPolygon::FromClipper( clipper_result );
|
||||
|
||||
// Make sure we keep texturing info
|
||||
|
|
|
@ -594,6 +594,7 @@ public:
|
|||
|
||||
static tgPolygon DiffWithAccumulator( const tgPolygon& subject );
|
||||
static void AddToAccumulator( const tgPolygon& subject );
|
||||
static void AccumulatorToShapefiles( const std::string& path, const std::string& layer );
|
||||
|
||||
// Conversions
|
||||
static ClipperLib::Polygons ToClipper( const tgPolygon& subject );
|
||||
|
|
Loading…
Add table
Reference in a new issue