Use a SGGeod bounding box for the scheduler
This commit is contained in:
parent
8a12f010f5
commit
306b125044
5 changed files with 185 additions and 206 deletions
|
@ -127,11 +127,12 @@ ostream os(&ssb);
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
float min_lon = -180;
|
|
||||||
float max_lon = 180;
|
|
||||||
float min_lat = -90;
|
|
||||||
float max_lat = 90;
|
|
||||||
long position = 0;
|
long position = 0;
|
||||||
|
SGGeod max, min;
|
||||||
|
max.setLongitudeDeg(180);
|
||||||
|
max.setLatitudeDeg(90);
|
||||||
|
min.setLongitudeDeg(-180);
|
||||||
|
min.setLatitudeDeg(-90);
|
||||||
|
|
||||||
// Setup elevation directories
|
// Setup elevation directories
|
||||||
string_list elev_src;
|
string_list elev_src;
|
||||||
|
@ -196,35 +197,31 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
else if ( arg.find("--min-lon=") == 0 )
|
else if ( arg.find("--min-lon=") == 0 )
|
||||||
{
|
{
|
||||||
min_lon = atof( arg.substr(10).c_str() );
|
min.setLongitudeDeg(atof( arg.substr(10).c_str() ));
|
||||||
}
|
}
|
||||||
else if ( arg.find("--max-lon=") == 0 )
|
else if ( arg.find("--max-lon=") == 0 )
|
||||||
{
|
{
|
||||||
max_lon = atof( arg.substr(10).c_str() );
|
max.setLongitudeDeg(atof( arg.substr(10).c_str() ));
|
||||||
}
|
}
|
||||||
else if ( arg.find("--min-lat=") == 0 )
|
else if ( arg.find("--min-lat=") == 0 )
|
||||||
{
|
{
|
||||||
min_lat = atof( arg.substr(10).c_str() );
|
min.setLatitudeDeg(atof( arg.substr(10).c_str() ));
|
||||||
}
|
}
|
||||||
else if ( arg.find("--max-lat=") == 0 )
|
else if ( arg.find("--max-lat=") == 0 )
|
||||||
{
|
{
|
||||||
max_lat = atof( arg.substr(10).c_str() );
|
max.setLatitudeDeg(atof( arg.substr(10).c_str() ));
|
||||||
}
|
}
|
||||||
else if ( arg.find("--chunk=") == 0 )
|
else if ( arg.find("--chunk=") == 0 )
|
||||||
{
|
{
|
||||||
tg::Rectangle rectangle = tg::parseChunk(arg.substr(8).c_str(), 10.0);
|
tg::Rectangle rectangle = tg::parseChunk(arg.substr(8).c_str(), 10.0);
|
||||||
min_lon = rectangle.getMin().getLongitudeDeg();
|
min = rectangle.getMin();
|
||||||
min_lat = rectangle.getMin().getLatitudeDeg();
|
max = rectangle.getMax();
|
||||||
max_lon = rectangle.getMax().getLongitudeDeg();
|
|
||||||
max_lat = rectangle.getMax().getLatitudeDeg();
|
|
||||||
}
|
}
|
||||||
else if ( arg.find("--tile=") == 0 )
|
else if ( arg.find("--tile=") == 0 )
|
||||||
{
|
{
|
||||||
tg::Rectangle rectangle = tg::parseTile(arg.substr(7).c_str());
|
tg::Rectangle rectangle = tg::parseTile(arg.substr(7).c_str());
|
||||||
min_lon = rectangle.getMin().getLongitudeDeg();
|
min = rectangle.getMin();
|
||||||
min_lat = rectangle.getMin().getLatitudeDeg();
|
max = rectangle.getMax();
|
||||||
max_lon = rectangle.getMax().getLongitudeDeg();
|
|
||||||
max_lat = rectangle.getMax().getLatitudeDeg();
|
|
||||||
}
|
}
|
||||||
else if ( arg.find("--airport=") == 0 )
|
else if ( arg.find("--airport=") == 0 )
|
||||||
{
|
{
|
||||||
|
@ -299,17 +296,18 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "Work directory = " << work_dir);
|
SG_LOG(SG_GENERAL, SG_INFO, "Work directory = " << work_dir);
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "Nudge = " << nudge);
|
SG_LOG(SG_GENERAL, SG_INFO, "Nudge = " << nudge);
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "Longitude = " << min_lon << ':' << max_lon);
|
SG_LOG(SG_GENERAL, SG_INFO, "Longitude = " << min.getLongitudeDeg() << ':' << max.getLongitudeDeg());
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "Latitude = " << min_lat << ':' << max_lat);
|
SG_LOG(SG_GENERAL, SG_INFO, "Latitude = " << min.getLatitudeDeg() << ':' << max.getLatitudeDeg());
|
||||||
|
|
||||||
if (max_lon < min_lon || max_lat < min_lat ||
|
if (!max.isValid() || !min.isValid())
|
||||||
min_lat < -90 || max_lat > 90 ||
|
|
||||||
min_lon < -180 || max_lon > 180)
|
|
||||||
{
|
{
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "Bad longitude or latitude");
|
SG_LOG(SG_GENERAL, SG_ALERT, "Bad longitude or latitude");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tg::Rectangle boundingBox(min, max);
|
||||||
|
boundingBox.sanify();
|
||||||
|
|
||||||
if ( work_dir == "" )
|
if ( work_dir == "" )
|
||||||
{
|
{
|
||||||
SG_LOG( SG_GENERAL, SG_ALERT, "Error: no work directory specified." );
|
SG_LOG( SG_GENERAL, SG_ALERT, "Error: no work directory specified." );
|
||||||
|
@ -397,7 +395,7 @@ int main(int argc, char **argv)
|
||||||
position = scheduler->FindAirport( start_id );
|
position = scheduler->FindAirport( start_id );
|
||||||
|
|
||||||
// add remaining airports within boundary
|
// add remaining airports within boundary
|
||||||
if ( scheduler->AddAirports( position, min_lat, min_lon, max_lat, max_lon ) )
|
if ( scheduler->AddAirports( position, &boundingBox ) )
|
||||||
{
|
{
|
||||||
// parse all the airports that were found
|
// parse all the airports that were found
|
||||||
scheduler->Schedule( num_threads, summary_file );
|
scheduler->Schedule( num_threads, summary_file );
|
||||||
|
@ -406,7 +404,7 @@ int main(int argc, char **argv)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// find all airports within given boundary
|
// find all airports within given boundary
|
||||||
if ( scheduler->AddAirports( 0, min_lat, min_lon, max_lat, max_lon ) )
|
if ( scheduler->AddAirports( 0, &boundingBox ) )
|
||||||
{
|
{
|
||||||
// and parse them
|
// and parse them
|
||||||
scheduler->Schedule( num_threads, summary_file );
|
scheduler->Schedule( num_threads, summary_file );
|
||||||
|
|
|
@ -68,11 +68,11 @@ point_list WaterRunway::GetNodes()
|
||||||
if (buoys){
|
if (buoys){
|
||||||
double heading, az2, length;
|
double heading, az2, length;
|
||||||
// calculate runway heading and length
|
// calculate runway heading and length
|
||||||
SGGeodesy::inverse(GetStart().toSGGeod(), GetEnd().toSGGeod(), heading, az2, length);
|
SGGeodesy::inverse(GetStart(), GetEnd(), heading, az2, length);
|
||||||
|
|
||||||
// create a polygon for the outline and use it to calculate the point list
|
// create a polygon for the outline and use it to calculate the point list
|
||||||
int divs = (int)(length / 100.0);
|
int divs = (int)(length / 100.0);
|
||||||
TGPolygon area = gen_wgs84_area(GetStart().toSGGeod(), GetEnd().toSGGeod(),
|
TGPolygon area = gen_wgs84_area(GetStart(), GetEnd(),
|
||||||
length, 0, 0, width, heading, false);
|
length, 0, 0, width, heading, false);
|
||||||
Point3D pt, inc;
|
Point3D pt, inc;
|
||||||
|
|
||||||
|
|
|
@ -185,14 +185,14 @@ public:
|
||||||
|
|
||||||
point_list GetNodes();
|
point_list GetNodes();
|
||||||
|
|
||||||
Point3D GetStart(void)
|
SGGeod GetStart(void)
|
||||||
{
|
{
|
||||||
return ( Point3D( lon[0], lat[0], 0.0f ));
|
return SGGeod::fromDeg( lon[0], lat[0] );
|
||||||
}
|
}
|
||||||
|
|
||||||
Point3D GetEnd(void)
|
SGGeod GetEnd(void)
|
||||||
{
|
{
|
||||||
return ( Point3D( lon[1], lat[1], 0.0f ));
|
return SGGeod::fromDeg( lon[1], lat[1] );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -590,7 +590,7 @@ void Scheduler::RetryAirport( AirportInfo* pai )
|
||||||
retryList.push_back( *pai );
|
retryList.push_back( *pai );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Scheduler::AddAirports( long start_pos, float min_lat, float min_lon, float max_lat, float max_lon )
|
bool Scheduler::AddAirports( long start_pos, tg::Rectangle* boundingBox )
|
||||||
{
|
{
|
||||||
char line[2048];
|
char line[2048];
|
||||||
char* def;
|
char* def;
|
||||||
|
@ -676,18 +676,10 @@ bool Scheduler::AddAirports( long start_pos, float min_lat, float min_lon, float
|
||||||
// we have a winner
|
// we have a winner
|
||||||
{
|
{
|
||||||
Runway* runway = new Runway(def);
|
Runway* runway = new Runway(def);
|
||||||
Point3D start = Point3D::fromSGGeod(runway->GetStart());
|
if ( boundingBox->isInside(runway->GetStart()) ) {
|
||||||
Point3D end = Point3D::fromSGGeod(runway->GetEnd());
|
|
||||||
if ( (start.x() >= min_lon ) &&
|
|
||||||
(start.y() >= min_lat ) &&
|
|
||||||
(start.x() <= max_lon ) &&
|
|
||||||
(start.y() <= max_lat ) ) {
|
|
||||||
match = true;
|
match = true;
|
||||||
}
|
}
|
||||||
else if ( (end.x() >= min_lon ) &&
|
else if ( boundingBox->isInside(runway->GetEnd()) ) {
|
||||||
(end.y() >= min_lat ) &&
|
|
||||||
(end.x() <= max_lon ) &&
|
|
||||||
(end.y() <= max_lat ) ) {
|
|
||||||
match = true;
|
match = true;
|
||||||
}
|
}
|
||||||
delete runway;
|
delete runway;
|
||||||
|
@ -699,18 +691,10 @@ bool Scheduler::AddAirports( long start_pos, float min_lat, float min_lon, float
|
||||||
// we have a winner
|
// we have a winner
|
||||||
{
|
{
|
||||||
WaterRunway* runway = new WaterRunway(def);
|
WaterRunway* runway = new WaterRunway(def);
|
||||||
Point3D start = runway->GetStart();
|
if ( boundingBox->isInside(runway->GetStart()) ) {
|
||||||
Point3D end = runway->GetEnd();
|
|
||||||
if ( (start.x() >= min_lon ) &&
|
|
||||||
(start.y() >= min_lat ) &&
|
|
||||||
(start.x() <= max_lon ) &&
|
|
||||||
(start.y() <= max_lat ) ) {
|
|
||||||
match = true;
|
match = true;
|
||||||
}
|
}
|
||||||
else if ( (end.x() >= min_lon ) &&
|
else if ( boundingBox->isInside(runway->GetEnd()) ) {
|
||||||
(end.y() >= min_lat ) &&
|
|
||||||
(end.x() <= max_lon ) &&
|
|
||||||
(end.y() <= max_lat ) ) {
|
|
||||||
match = true;
|
match = true;
|
||||||
}
|
}
|
||||||
delete runway;
|
delete runway;
|
||||||
|
@ -722,11 +706,7 @@ bool Scheduler::AddAirports( long start_pos, float min_lat, float min_lon, float
|
||||||
// a winner
|
// a winner
|
||||||
{
|
{
|
||||||
Helipad* helipad = new Helipad(def);
|
Helipad* helipad = new Helipad(def);
|
||||||
Point3D loc = Point3D::fromSGGeod(helipad->GetLoc()) ;
|
if ( boundingBox->isInside(helipad->GetLoc()) ) {
|
||||||
if ( (loc.x() >= min_lon ) &&
|
|
||||||
(loc.y() >= min_lat ) &&
|
|
||||||
(loc.x() <= max_lon ) &&
|
|
||||||
(loc.y() <= max_lat ) ) {
|
|
||||||
match = true;
|
match = true;
|
||||||
}
|
}
|
||||||
delete helipad;
|
delete helipad;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
#include <simgear/math/sg_types.hxx>
|
#include <simgear/math/sg_types.hxx>
|
||||||
#include <simgear/timing/timestamp.hxx>
|
#include <simgear/timing/timestamp.hxx>
|
||||||
|
#include <Geometry/rectangle.hxx>
|
||||||
|
|
||||||
#define P_STATE_INIT (0)
|
#define P_STATE_INIT (0)
|
||||||
#define P_STATE_PARSE (1)
|
#define P_STATE_PARSE (1)
|
||||||
|
@ -176,7 +177,7 @@ public:
|
||||||
|
|
||||||
long FindAirport( string icao );
|
long FindAirport( string icao );
|
||||||
void AddAirport( string icao );
|
void AddAirport( string icao );
|
||||||
bool AddAirports( long start_pos, float min_lat, float min_lon, float max_lat, float max_lon );
|
bool AddAirports( long start_pos, tg::Rectangle* boundingBox );
|
||||||
void RetryAirport( AirportInfo* pInfo );
|
void RetryAirport( AirportInfo* pInfo );
|
||||||
|
|
||||||
void Schedule( int num_threads, string& summaryfile );
|
void Schedule( int num_threads, string& summaryfile );
|
||||||
|
|
Loading…
Reference in a new issue