diff --git a/src/AIModel/AIFlightPlan.cxx b/src/AIModel/AIFlightPlan.cxx index f8f7c5763..1ec20e188 100644 --- a/src/AIModel/AIFlightPlan.cxx +++ b/src/AIModel/AIFlightPlan.cxx @@ -46,9 +46,6 @@ using std::cerr; FGAIWaypoint::FGAIWaypoint() { - latitude = 0; - longitude = 0; - altitude = 0; speed = 0; crossat = 0; finished = 0; @@ -68,7 +65,37 @@ bool FGAIWaypoint::contains(string target) { return true; } -FGAIFlightPlan::FGAIFlightPlan() +double FGAIWaypoint::getLatitude() +{ + return pos.getLatitudeDeg(); +} + +double FGAIWaypoint::getLongitude() +{ + return pos.getLongitudeDeg(); +} + +double FGAIWaypoint::getAltitude() +{ + return pos.getElevationFt(); +} + +void FGAIWaypoint::setLatitude(double lat) +{ + pos.setLatitudeDeg(lat); +} + +void FGAIWaypoint::setLongitude(double lon) +{ + pos.setLongitudeDeg(lon); +} + +void FGAIWaypoint::setAltitude(double alt) +{ + pos.setElevationFt(alt); +} + +FGAIFlightPlan::FGAIFlightPlan() { sid = 0; repeat = false; @@ -345,8 +372,7 @@ void FGAIFlightPlan::eraseLastWaypoint() // gives distance in feet from a position to a waypoint double FGAIFlightPlan::getDistanceToGo(double lat, double lon, FGAIWaypoint* wp) const{ - return SGGeodesy::distanceM(SGGeod::fromDeg(lon, lat), - SGGeod::fromDeg(wp->getLongitude(), wp->getLatitude())); + return SGGeodesy::distanceM(SGGeod::fromDeg(lon, lat), wp->getPos()); } // sets distance in feet from a lead point to the current waypoint @@ -394,14 +420,15 @@ void FGAIFlightPlan::setLeadDistance(double distance_ft){ } -double FGAIFlightPlan::getBearing(FGAIWaypoint* first, FGAIWaypoint* second) const{ - return getBearing(first->getLatitude(), first->getLongitude(), second); +double FGAIFlightPlan::getBearing(FGAIWaypoint* first, FGAIWaypoint* second) const +{ + return SGGeodesy::courseDeg(first->getPos(), second->getPos()); } -double FGAIFlightPlan::getBearing(double lat, double lon, FGAIWaypoint* wp) const{ - return SGGeodesy::courseDeg(SGGeod::fromDeg(lon, lat), - SGGeod::fromDeg(wp->getLongitude(), wp->getLatitude())); +double FGAIFlightPlan::getBearing(double lat, double lon, FGAIWaypoint* wp) const +{ + return SGGeodesy::courseDeg(SGGeod::fromDeg(lon, lat), wp->getPos()); } void FGAIFlightPlan::deleteWaypoints() @@ -423,10 +450,7 @@ void FGAIFlightPlan::resetWaypoints() wpt_vector_iterator i = waypoints.end(); i--; wpt->setName ( (*i)->getName() ); - wpt->setLatitude ( (*i)->getLatitude() ); - wpt->setLongitude ( (*i)->getLongitude() ); - wpt->setAltitude ( (*i)->getAltitude() ); - wpt->setSpeed ( (*i)->getSpeed() ); + wpt->setPos ( (*i)->getPos() ); wpt->setCrossat ( (*i)->getCrossat() ); wpt->setGear_down ( (*i)->getGear_down() ); wpt->setFlaps_down ( (*i)->getFlaps_down() ); diff --git a/src/AIModel/AIFlightPlan.hxx b/src/AIModel/AIFlightPlan.hxx index e5e4bb10d..c32d88345 100644 --- a/src/AIModel/AIFlightPlan.hxx +++ b/src/AIModel/AIFlightPlan.hxx @@ -22,20 +22,17 @@ #include #include #include - +#include class FGTaxiRoute; class FGRunway; class FGAIAircraft; class FGAirport; -class SGGeod; class FGAIWaypoint { private: std::string name; - double latitude; - double longitude; - double altitude; + SGGeod pos; double speed; double crossat; bool finished; @@ -51,9 +48,10 @@ public: FGAIWaypoint(); ~FGAIWaypoint() {}; void setName (std::string nam) { name = nam; }; - void setLatitude (double lat) { latitude = lat; }; - void setLongitude (double lon) { longitude = lon; }; - void setAltitude (double alt) { altitude = alt; }; + void setLatitude (double lat); + void setLongitude (double lon); + void setAltitude (double alt); + void setPos (const SGGeod& aPos) { pos = aPos; } void setSpeed (double spd) { speed = spd; }; void setCrossat (double val) { crossat = val; }; void setFinished (bool fin) { finished = fin; }; @@ -68,9 +66,10 @@ public: bool contains(std::string name); std::string getName () { return name; }; - double getLatitude () { return latitude; }; - double getLongitude () { return longitude; }; - double getAltitude () { return altitude; }; + const SGGeod& getPos () { return pos; }; + double getLatitude (); + double getLongitude (); + double getAltitude (); double getSpeed () { return speed; }; double getCrossat () { return crossat; };