1
0
Fork 0

Use a SGGeod bounding box for the scheduler

This commit is contained in:
Christian Schmitt 2012-10-08 21:24:21 +02:00
parent 8a12f010f5
commit 306b125044
5 changed files with 185 additions and 206 deletions

View file

@ -127,11 +127,12 @@ ostream os(&ssb);
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;
SGGeod max, min;
max.setLongitudeDeg(180);
max.setLatitudeDeg(90);
min.setLongitudeDeg(-180);
min.setLatitudeDeg(-90);
// Setup elevation directories
string_list elev_src;
@ -196,35 +197,31 @@ int main(int argc, char **argv)
}
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 )
{
max_lon = atof( arg.substr(10).c_str() );
max.setLongitudeDeg(atof( arg.substr(10).c_str() ));
}
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 )
{
max_lat = atof( arg.substr(10).c_str() );
max.setLatitudeDeg(atof( arg.substr(10).c_str() ));
}
else if ( arg.find("--chunk=") == 0 )
{
tg::Rectangle rectangle = tg::parseChunk(arg.substr(8).c_str(), 10.0);
min_lon = rectangle.getMin().getLongitudeDeg();
min_lat = rectangle.getMin().getLatitudeDeg();
max_lon = rectangle.getMax().getLongitudeDeg();
max_lat = rectangle.getMax().getLatitudeDeg();
min = rectangle.getMin();
max = rectangle.getMax();
}
else if ( arg.find("--tile=") == 0 )
{
tg::Rectangle rectangle = tg::parseTile(arg.substr(7).c_str());
min_lon = rectangle.getMin().getLongitudeDeg();
min_lat = rectangle.getMin().getLatitudeDeg();
max_lon = rectangle.getMax().getLongitudeDeg();
max_lat = rectangle.getMax().getLatitudeDeg();
min = rectangle.getMin();
max = rectangle.getMax();
}
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, "Nudge = " << nudge);
SG_LOG(SG_GENERAL, SG_INFO, "Longitude = " << min_lon << ':' << max_lon);
SG_LOG(SG_GENERAL, SG_INFO, "Latitude = " << min_lat << ':' << max_lat);
SG_LOG(SG_GENERAL, SG_INFO, "Longitude = " << min.getLongitudeDeg() << ':' << max.getLongitudeDeg());
SG_LOG(SG_GENERAL, SG_INFO, "Latitude = " << min.getLatitudeDeg() << ':' << max.getLatitudeDeg());
if (max_lon < min_lon || max_lat < min_lat ||
min_lat < -90 || max_lat > 90 ||
min_lon < -180 || max_lon > 180)
if (!max.isValid() || !min.isValid())
{
SG_LOG(SG_GENERAL, SG_ALERT, "Bad longitude or latitude");
exit(1);
}
tg::Rectangle boundingBox(min, max);
boundingBox.sanify();
if ( work_dir == "" )
{
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 );
// 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
scheduler->Schedule( num_threads, summary_file );
@ -406,7 +404,7 @@ int main(int argc, char **argv)
else
{
// 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
scheduler->Schedule( num_threads, summary_file );

View file

@ -68,11 +68,11 @@ point_list WaterRunway::GetNodes()
if (buoys){
double heading, az2, 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
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);
Point3D pt, inc;

View file

@ -185,14 +185,14 @@ public:
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:

View file

@ -590,7 +590,7 @@ void Scheduler::RetryAirport( AirportInfo* 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* def;
@ -676,18 +676,10 @@ bool Scheduler::AddAirports( long start_pos, float min_lat, float min_lon, float
// we have a winner
{
Runway* runway = new Runway(def);
Point3D start = Point3D::fromSGGeod(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 ) ) {
if ( boundingBox->isInside(runway->GetStart()) ) {
match = true;
}
else if ( (end.x() >= min_lon ) &&
(end.y() >= min_lat ) &&
(end.x() <= max_lon ) &&
(end.y() <= max_lat ) ) {
else if ( boundingBox->isInside(runway->GetEnd()) ) {
match = true;
}
delete runway;
@ -699,18 +691,10 @@ bool Scheduler::AddAirports( long start_pos, float min_lat, float min_lon, float
// we have a winner
{
WaterRunway* runway = new WaterRunway(def);
Point3D start = runway->GetStart();
Point3D end = runway->GetEnd();
if ( (start.x() >= min_lon ) &&
(start.y() >= min_lat ) &&
(start.x() <= max_lon ) &&
(start.y() <= max_lat ) ) {
if ( boundingBox->isInside(runway->GetStart()) ) {
match = true;
}
else if ( (end.x() >= min_lon ) &&
(end.y() >= min_lat ) &&
(end.x() <= max_lon ) &&
(end.y() <= max_lat ) ) {
else if ( boundingBox->isInside(runway->GetEnd()) ) {
match = true;
}
delete runway;
@ -722,11 +706,7 @@ bool Scheduler::AddAirports( long start_pos, float min_lat, float min_lon, float
// a winner
{
Helipad* helipad = new Helipad(def);
Point3D loc = Point3D::fromSGGeod(helipad->GetLoc()) ;
if ( (loc.x() >= min_lon ) &&
(loc.y() >= min_lat ) &&
(loc.x() <= max_lon ) &&
(loc.y() <= max_lat ) ) {
if ( boundingBox->isInside(helipad->GetLoc()) ) {
match = true;
}
delete helipad;

View file

@ -19,6 +19,7 @@
#include <simgear/compiler.h>
#include <simgear/math/sg_types.hxx>
#include <simgear/timing/timestamp.hxx>
#include <Geometry/rectangle.hxx>
#define P_STATE_INIT (0)
#define P_STATE_PARSE (1)
@ -176,7 +177,7 @@ public:
long FindAirport( 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 Schedule( int num_threads, string& summaryfile );