1
0
Fork 0

James Turner: Cleanup of AI traffic route generation code.

This commit is contained in:
durk 2008-12-30 07:41:15 +00:00 committed by Tim Moore
parent c604514754
commit 632d89d6e7
6 changed files with 304 additions and 772 deletions

View file

@ -126,7 +126,6 @@ private:
void createPushBack(bool, FGAirport*, double, double, double, const string&, const string&, const string&);
void createPushBackFallBack(bool, FGAirport*, double, double, double, const string&, const string&, const string&);
void createTaxi(bool, int, FGAirport *, double, double, double, const string&, const string&, const string&);
void createTakeOff(bool, FGAirport *, double, const string&);
void createClimb(bool, FGAirport *, double, double, const string&);
void createCruise(bool, FGAirport*, FGAirport*, double, double, double, double, const string&);
@ -136,6 +135,15 @@ private:
void deleteWaypoints();
void resetWaypoints();
void createLandingTaxi(FGAirport *apt, double radius, const string& fltType, const string& acType, const string& airline);
void createDefaultLandingTaxi(FGAirport* aAirport);
void createDefaultTakeoffTaxi(FGAirport* aAirport, FGRunway* aRunway);
void createTakeoffTaxi(bool firstFlight, FGAirport *apt, double radius, const string& fltType, const string& acType, const string& airline);
waypoint* createOnGround(const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed);
waypoint* createInAir(const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed);
waypoint* cloneWithPos(waypoint* aWpt, const std::string& aName, const SGGeod& aPos);
string getRunwayClassFromTrafficType(string fltType);
//void createCruiseFallback(bool, FGAirport*, FGAirport*, double, double, double, double);

File diff suppressed because it is too large Load diff

View file

@ -276,7 +276,7 @@ void FGAIFlightPlan::createCruise(bool firstFlight, FGAirport *dep,
// {
// cerr << "Creating cruise to EHAM " << latitude << " " << longitude << endl;
// }
heading = rwy->headingDeg();
heading = rwy._heading;
azimuth = heading + 180.0;
while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
@ -315,52 +315,16 @@ void FGAIFlightPlan::createCruise(bool firstFlight, FGAirport *dep,
double longitude, double speed,
double alt, const string& fltType)
{
double wind_speed;
double wind_heading;
double heading;
double lat, lon, az;
double lat2, lon2, az2;
double azimuth;
waypoint *wpt;
wpt = new waypoint;
wpt->name = "Cruise"; //wpt_node->getStringValue("name", "END");
wpt->latitude = latitude;
wpt->longitude = longitude;
wpt->altitude = alt;
wpt->speed = speed;
wpt->crossat = -10000;
wpt->gear_down = false;
wpt->flaps_down= false;
wpt->finished = false;
wpt->on_ground = false;
wpt->routeIndex = 0;
wpt = createInAir("Cruise", SGGeod::fromDeg(longitude, latitude), alt, speed);
waypoints.push_back(wpt);
string rwyClass = getRunwayClassFromTrafficType(fltType);
arr->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway);
rwy = arr->getRunwayByIdent(activeRunway);
// begin descent 110km out
SGGeod beginDescentPoint = rwy->pointOnCenterline(-110000);
heading = rwy->headingDeg();
azimuth = heading + 180.0;
while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
geo_direct_wgs_84 ( 0, rwy->latitude(), rwy->longitude(), azimuth,
110000,
&lat2, &lon2, &az2 );
wpt = new waypoint;
wpt->name = "BOD";
wpt->latitude = lat2;
wpt->longitude = lon2;
wpt->altitude = alt;
wpt->speed = speed;
wpt->crossat = alt;
wpt->gear_down = false;
wpt->flaps_down= false;
wpt->finished = false;
wpt->on_ground = false;
wpt->routeIndex = 0;
wpt = createInAir("BOD", beginDescentPoint, alt, speed);
waypoints.push_back(wpt);
}

View file

@ -18,7 +18,9 @@
#include <vector>
#include <string>
#include <simgear/compiler.h>
#include <simgear/math/sg_geodesy.hxx>
using std::string;
using std::vector;
@ -107,6 +109,8 @@ FGTaxiNode &operator =(const FGTaxiNode &other)
double getLatitude() { return lat;};
double getLongitude(){ return lon;};
SGGeod geod() const { return SGGeod::fromDeg(lon, lat); }
int getIndex() { return index; };
int getHoldPointType() { return holdType; };
bool getIsOnRunway() { return isOnRunway; };

View file

@ -312,7 +312,10 @@ void FGGroundNetwork::init()
//exit(1);
}
int FGGroundNetwork::findNearestNode(const SGGeod& aGeod)
{
return findNearestNode(aGeod.getLatitudeDeg(), aGeod.getLongitudeDeg());
}
int FGGroundNetwork::findNearestNode(double lat, double lon)
{

View file

@ -253,7 +253,10 @@ public:
void init();
bool exists() { return hasNetwork; };
void setTowerController(FGTowerController *twrCtrlr) { towerController = twrCtrlr; };
int findNearestNode(double lat, double lon);
int findNearestNode(const SGGeod& aGeod);
FGTaxiNode *findNode(int idx);
FGTaxiSegment *findSegment(int idx);
FGTaxiRoute findShortestRoute(int start, int end, bool fullSearch=true);