#include "gnnode.hxx"
+
+#include <boost/foreach.hpp>
+
#include "groundnetwork.hxx"
-#include <algorithm>
-using std::sort;
+#include <Navaids/NavDataCache.hxx>
+#include <Main/globals.hxx>
+#include <Scenery/scenery.hxx>
+
+using namespace flightgear;
+
+/**************************************************************************
+ * FGTaxiNode
+ *************************************************************************/
-/*****************************************************************************
- * Helper function for parsing position string
- ****************************************************************************/
-double processPosition(const string &pos)
+FGTaxiNode::FGTaxiNode(PositionedID aGuid, const SGGeod& pos, bool aOnRunway, int aHoldType) :
+ FGPositioned(aGuid, FGPositioned::PARKING, "", pos),
+ isOnRunway(aOnRunway),
+ holdType(aHoldType)
{
- 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);
+FGTaxiNode::~FGTaxiNode()
+{
}
-bool sortByLength(FGTaxiSegment *a, FGTaxiSegment *b) {
- return a->getLength() > b->getLength();
+void FGTaxiNode::setElevation(double val)
+{
+ // ignored for the moment
}
-/**************************************************************************
- * FGTaxiNode
- *************************************************************************/
-
+double FGTaxiNode::getElevationFt()
+{
+ if (mPosition.getElevationFt() == 0.0) {
+ SGGeod center2 = mPosition;
+ FGScenery* local_scenery = globals->get_scenery();
+ center2.setElevationM(SG_MAX_ELEVATION_M);
+ double elevationEnd = -100;
+ if (local_scenery->get_elevation_m( center2, elevationEnd, NULL )) {
+
+ SGGeod newPos = mPosition;
+ newPos.setElevationM(elevationEnd);
+ // this will call modifyPosition to update mPosition
+ NavDataCache::instance()->updatePosition(guid(), newPos);
+ }
+ }
+
+ return mPosition.getElevationFt();
+}
-void FGTaxiNode::sortEndSegments(bool byLength)
+double FGTaxiNode::getElevationM()
{
- if (byLength)
- sort(next.begin(), next.end(), sortByLength);
- else
- sort(next.begin(), next.end(), sortByHeadingDiff);
+ return getElevationFt() * SG_FEET_TO_METER;
}