using std::cerr;
FGAIWaypoint::FGAIWaypoint() {
- latitude = 0;
- longitude = 0;
- altitude = 0;
speed = 0;
crossat = 0;
finished = 0;
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;
// 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
}
-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()
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() );
#include <simgear/compiler.h>
#include <vector>
#include <string>
-
+#include <simgear/math/SGMath.hxx>
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;
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; };
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; };