props->tie("controls/gear/gear-down",
SGRawValueMethods<FGAIAircraft,bool>(*this,
&FGAIAircraft::_getGearDown));
- props->tie("callsign",
- SGRawValueMethods<FGAIAircraft,const char *>(*this,
- &FGAIAircraft::_getCallSign));
- //props->setStringValue("callsign", callsign.c_str());
}
FGAIBase::unbind();
props->untie("controls/gear/gear-down");
- props->untie("callsign");
}
return _performance->gearExtensible(this);
}
-const char * FGAIAircraft::_getCallSign() const {
- return callsign.c_str();
-}
-
void FGAIAircraft::loadNextLeg() {
}
-void FGAIAircraft::setCallSign(const string& s) {
- callsign = s;
-}
-
-
void FGAIAircraft::doGroundAltitude() {
if (fabs(altitude_ft - (tgt_altitude_ft+groundOffset)) > 1000.0)
altitude_ft = (tgt_altitude_ft + groundOffset);
void ClimbTo(double altitude);
void TurnTo(double heading);
- void setCallSign(const string& );
-
void getGroundElev(double dt); //TODO these 3 really need to be public?
void doGroundAltitude();
void loadNextLeg ();
bool holdPos;
bool _getGearDown() const;
- const char *_getCallSign() const;
+
bool reachedWaypoint;
- string callsign; // The callsign of this tanker.
PerformanceData* _performance; // the performance data for this aircraft
};
SGRawValueMethods<FGAIBase,double>(*this,
&FGAIBase::_getCartPosZ,
0));
+ props->tie("callsign",
+ SGRawValueMethods<FGAIBase,const char*>(*this,
+ &FGAIBase::_getCallsign,
+ 0));
props->tie("orientation/pitch-deg", SGRawValuePointer<double>(&pitch));
props->tie("orientation/roll-deg", SGRawValuePointer<double>(&roll));
props->untie("position/global-x");
props->untie("position/global-y");
props->untie("position/global-z");
+ props->untie("callsign");
props->untie("orientation/pitch-deg");
props->untie("orientation/roll-deg");
return hdg;
}
-const char* FGAIBase::_getPath() {
+const char* FGAIBase::_getPath() const {
+ return model_path.c_str();
+}
+
+const char* FGAIBase::_getSMPath() const {
return _path.c_str();
}
-const char* FGAIBase::_getName() {
+const char* FGAIBase::_getName() const {
return _name.c_str();
}
-const char* FGAIBase::_getCallsign() {
+const char* FGAIBase::_getCallsign() const {
return _callsign.c_str();
}
-const char* FGAIBase::_getSubmodel() {
+const char* FGAIBase::_getSubmodel() const {
return _submodel.c_str();
}
// where:
// a = speed of sound [ft/s]
// g = specific heat ratio, which is usually equal to 1.4
- // R = specific gas constant, which equals 1716 ft-lb/slug/°R
+ // R = specific gas constant, which equals 1716 ft-lb/slug/R
a = sqrt ( 1.4 * 1716 * (T + 459.7));
// calculate Mach number
void setManager(FGAIManager* mgr, SGPropertyNode* p);
void setPath( const char* model );
void setSMPath( const string& p );
+ void setCallSign(const string& );
void setSpeed( double speed_KTAS );
void setAltitude( double altitude_ft );
void setHeading( double heading );
SGPropertyNode* _getProps() const;
- const char* _getPath();
- const char* _getCallsign();
- const char* _getTriggerNode();
- const char* _getName();
- const char* _getSubmodel();
+ const char* _getPath() const;
+ const char* _getSMPath() const;
+ const char* _getCallsign() const;
+ const char* _getTriggerNode() const;
+ const char* _getName() const;
+ const char* _getSubmodel() const;
// These are used in the Mach number calculations
pos.setLatitudeDeg( latitude );
}
+inline void FGAIBase::setCallSign(const string& s) {
+ _callsign = s;
+}
+
+
inline void FGAIBase::setDie( bool die ) { delete_me = die; }
inline bool FGAIBase::getDie() { return delete_me; }
leg = 4;
else if (timeDiff >= 2000)
leg = 5;
-
- //cerr << "Set leg to : " << leg << endl;
+
+ SG_LOG(SG_GENERAL, SG_INFO, "Route from " << dep->getId() << " to " << arr->getId() << ". Set leg to : " << leg);
wpt_iterator = waypoints.begin();
create(dep,arr, leg, alt, speed, lat, lon,
firstLeg, radius, fltType, acType, airline);
}
}
//cerr << "1"<< endl;
- SGGeoc geoc = SGGeoc::fromCart(SGVec3d(newPos[0], newPos[1], newPos[2]));
- double midlat = geoc.getLatitudeDeg();
- double midlon = geoc.getLongitudeDeg();
+ //SGGeoc geoc = SGGeoc::fromCart(SGVec3d(newPos[0], newPos[1], newPos[2]));
+
+ //double midlat = geoc.getLatitudeDeg();
+ //double midlon = geoc.getLongitudeDeg();
+
+ Point3D temp = sgCartToPolar3d(Point3D(newPos[0], newPos[1],newPos[2]));
+ double midlat = temp.lat() * SG_RADIANS_TO_DEGREES;
+ double midlon = temp.lon() * SG_RADIANS_TO_DEGREES;
+
prevNode = tmpNode;
tmpNode = globals->get_airwaynet()->findNearestNode(midlat, midlon);
isTanker = false; // do this until this property is
// passed over the net
- string str1 = mCallSign;
+ string str1 = _getCallsign();
string str2 = "MOBIL";
string::size_type loc1= str1.find( str2, 0 );
SGRawValueMethods<FGAIMultiplayer, type>(*this, \
&FGAIMultiplayer::get##name, &FGAIMultiplayer::set##name)
- props->tie("callsign", AIMPROProp(const char *, CallSign));
+ //props->tie("callsign", AIMPROProp(const char *, CallSign));
props->tie("controls/allow-extrapolation",
AIMPRWProp(bool, AllowExtrapolation));
void FGAIMultiplayer::unbind() {
FGAIBase::unbind();
- props->untie("callsign");
+ //props->untie("callsign");
props->untie("controls/allow-extrapolation");
props->untie("controls/lag-adjust-system-speed");
props->untie("refuel/contact");
void addMotionInfo(const FGExternalMotionData& motionInfo, long stamp);
void setDoubleProperty(const std::string& prop, double val);
- void setCallSign(const string& callSign)
- { mCallSign = callSign; }
- const char* getCallSign(void) const
- { return mCallSign.c_str(); }
-
long getLastTimestamp(void) const
{ return mLastTimestamp; }
typedef std::map<unsigned, SGSharedPtr<SGPropertyNode> > PropertyMap;
PropertyMap mPropertyMap;
- std::string mCallSign;
-
double mTimeOffset;
bool mTimeOffsetSet;
sm_list_iterator end = sm_list.end();
while (sm_list_itr != end) {
- string path = (*sm_list_itr)->_getPath();
+ string path = (*sm_list_itr)->_getSMPath();
if (path.empty()) {
++sm_list_itr;
simple.cxx simple.hxx \
runwayprefs.cxx runwayprefs.hxx \
parking.cxx parking.hxx \
+ gnnode.cxx gnnode.hxx \
groundnetwork.cxx groundnetwork.hxx \
dynamics.cxx dynamics.hxx \
trafficcontrol.cxx trafficcontrol.hxx \
dynamicloader.cxx dynamicloader.hxx \
runwayprefloader.cxx runwayprefloader.hxx \
- xmlloader.cxx xmlloader.hxx \
- gnnode.hxx
+ xmlloader.cxx xmlloader.hxx
calc_loc_SOURCES = calc_loc.cxx
calc_loc_LDADD = -lsgmath -lsgdebug -lsgmisc -lz $(base_LIBS)
--- /dev/null
+#include "gnnode.hxx"
+#include "groundnetwork.hxx"
+
+#include <algorithm>
+SG_USING_STD(sort);
+
+/*****************************************************************************
+ * Helper function for parsing position string
+ ****************************************************************************/
+double processPosition(const string &pos)
+{
+ string prefix;
+ string subs;
+ string degree;
+ string decimal;
+ int sign = 1;
+ double value;
+ subs = pos;
+ prefix= subs.substr(0,1);
+ if (prefix == string("S") || (prefix == string("W")))
+ sign = -1;
+ subs = subs.substr(1, subs.length());
+ degree = subs.substr(0, subs.find(" ",0));
+ decimal = subs.substr(subs.find(" ",0), subs.length());
+
+
+ //cerr << sign << " "<< degree << " " << decimal << endl;
+ value = sign * (atof(degree.c_str()) + atof(decimal.c_str())/60.0);
+ //cerr << value <<endl;
+ //exit(1);
+ return value;
+}
+
+bool sortByHeadingDiff(FGTaxiSegment *a, FGTaxiSegment *b) {
+ return a->hasSmallerHeadingDiff(*b);
+}
+
+bool sortByLength(FGTaxiSegment *a, FGTaxiSegment *b) {
+ return a->getLength() > b->getLength();
+}
+
+/**************************************************************************
+ * FGTaxiNode
+ *************************************************************************/
+FGTaxiNode::FGTaxiNode()
+{
+}
+
+void FGTaxiNode::sortEndSegments(bool byLength)
+{
+ if (byLength)
+ sort(next.begin(), next.end(), sortByLength);
+ else
+ sort(next.begin(), next.end(), sortByHeadingDiff);
+}
typedef vector<FGTaxiSegment*> FGTaxiSegmentVector;
typedef FGTaxiSegmentVector::iterator FGTaxiSegmentVectorIterator;
+bool sortByHeadingDiff(FGTaxiSegment *a, FGTaxiSegment *b);
+bool sortByLength (FGTaxiSegment *a, FGTaxiSegment *b);
double processPosition(const string& pos);
class FGTaxiNode
#include "groundnetwork.hxx"
-SG_USING_STD(sort);
-
-/*****************************************************************************
- * Helper function for parsing position string
- ****************************************************************************/
-double processPosition(const string &pos)
-{
- string prefix;
- string subs;
- string degree;
- string decimal;
- int sign = 1;
- double value;
- subs = pos;
- prefix= subs.substr(0,1);
- if (prefix == string("S") || (prefix == string("W")))
- sign = -1;
- subs = subs.substr(1, subs.length());
- degree = subs.substr(0, subs.find(" ",0));
- decimal = subs.substr(subs.find(" ",0), subs.length());
-
-
- //cerr << sign << " "<< degree << " " << decimal << endl;
- value = sign * (atof(degree.c_str()) + atof(decimal.c_str())/60.0);
- //cerr << value <<endl;
- //exit(1);
- return value;
-}
-
-/**************************************************************************
- * FGTaxiNode
- *************************************************************************/
-FGTaxiNode::FGTaxiNode()
-{
-}
-
-void FGTaxiNode::sortEndSegments(bool byLength)
-{
- if (byLength)
- sort(next.begin(), next.end(), sortByLength);
- else
- sort(next.begin(), next.end(), sortByHeadingDiff);
-}
-
-
-bool compare_nodes(FGTaxiNode *a, FGTaxiNode *b) {
-return (*a) < (*b);
-}
-
/***************************************************************************
* FGTaxiSegment
**************************************************************************/
headingDiff = fabs(headingDiff - 360);
}
-bool compare_segments(FGTaxiSegment *a, FGTaxiSegment *b) {
-return (*a) < (*b);
-}
-
-bool sortByHeadingDiff(FGTaxiSegment *a, FGTaxiSegment *b) {
- return a->hasSmallerHeadingDiff(*b);
-}
-bool sortByLength(FGTaxiSegment *a, FGTaxiSegment *b) {
- return a->getLength() > b->getLength();
-}
/***************************************************************************
* FGTaxiRoute
**************************************************************************/
/***************************************************************************
* FGGroundNetwork()
**************************************************************************/
+bool compare_nodes(FGTaxiNode *a, FGTaxiNode *b) {
+return (*a) < (*b);
+}
+
+bool compare_segments(FGTaxiSegment *a, FGTaxiSegment *b) {
+return (*a) < (*b);
+}
FGGroundNetwork::FGGroundNetwork()
{
currNode = nodes.begin();
depth = dpth;
};
+
+ FGTaxiRoute& operator= (const FGTaxiRoute &other) {
+ nodes = other.nodes;
+ routes = other.routes;
+ distance = other.distance;
+ depth = other.depth;
+ currNode = nodes.begin();
+ currRoute = routes.begin();
+ return *this;
+ };
+
+ FGTaxiRoute(const FGTaxiRoute& copy) :
+ nodes(copy.nodes),
+ routes(copy.routes),
+ distance(copy.distance),
+ depth(copy.depth),
+ currNode(nodes.begin()),
+ currRoute(routes.begin())
+ {};
+
bool operator< (const FGTaxiRoute &other) const {return distance < other.distance; };
bool empty () { return nodes.begin() == nodes.end(); };
bool next(int *nde);
typedef vector<FGTaxiRoute> TaxiRouteVector;
typedef vector<FGTaxiRoute>::iterator TaxiRouteVectorIterator;
-bool sortByHeadingDiff(FGTaxiSegment *a, FGTaxiSegment *b);
-bool sortByLength (FGTaxiSegment *a, FGTaxiSegment *b);
-
-
/**************************************************************************************
* class FGGroundNetWork
*************************************************************************************/
if (now > (*i)->getDepartureTime())
{
- SGGeoc geoc = SGGeoc::fromCart(newPos);
- lat = geoc.getLatitudeDeg();
- lon = geoc.getLongitudeDeg();
+ //SGGeoc geoc = SGGeoc::fromCart(newPos);
+ //lat = geoc.getLatitudeDeg();
+ //lon = geoc.getLongitudeDeg();
+
+ Point3D temp = sgCartToPolar3d(Point3D(newPos[0], newPos[1],newPos[2]));
+ lat = temp.lat() * SG_RADIANS_TO_DEGREES;
+ lon = temp.lon() * SG_RADIANS_TO_DEGREES;
+
}
else
{