]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/gnnode.cxx
Interim windows build fix
[flightgear.git] / src / Airports / gnnode.cxx
index ae37d59594a03b65fc86847563820028659507ba..84f3aac541ed6564644dad374182390e657e0b1e 100644 (file)
@@ -1,76 +1,70 @@
 #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(int index, const SGGeod& pos, bool aOnRunway, int aHoldType) :
+  FGPositioned(TRANSIENT_ID, FGPositioned::PARKING, "", pos),
+  m_index(index),
+  isOnRunway(aOnRunway),
+  holdType(aHoldType),
+  m_isPushback(false)
 {
-  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::setElevation(double val)
 {
-    geod.setElevationM(val);
+  // ignored for the moment
 }
 
-void FGTaxiNode::setLatitude (double val)
+double FGTaxiNode::getElevationFt()
 {
-  geod.setLatitudeDeg(val);
+  const SGGeod& pos = geod();
+  if( pos.getElevationFt() == 0.0)
+  {
+    SGGeod center2 = pos;
+    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 = pos;
+      newPos.setElevationM(elevationEnd);
+      // this will call modifyPosition to update mPosition
+      modifyPosition(newPos);
+    }
+  }
+  
+  return pos.getElevationFt();
 }
 
-void FGTaxiNode::setLongitude(double val)
+int FGTaxiNode::getIndex() const
 {
-  geod.setLongitudeDeg(val);
+    return m_index;
 }
 
-void FGTaxiNode::setLatitude (const string& val)
+void FGTaxiNode::setIsPushback()
 {
-  geod.setLatitudeDeg(processPosition(val));
+    m_isPushback = true;
 }
 
-void FGTaxiNode::setLongitude(const string& val)
+double FGTaxiNode::getElevationM()
 {
-  geod.setLongitudeDeg(processPosition(val));
+  return getElevationFt() * SG_FEET_TO_METER;
 }
-  
-//void FGTaxiNode::sortEndSegments(bool byLength)
-//{
-//  if (byLength)
-//    sort(next.begin(), next.end(), sortByLength);
-//  else
-//    sort(next.begin(), next.end(), sortByHeadingDiff);
-//}