]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/gnnode.cxx
Prepare and implement reinit methods for instruments
[flightgear.git] / src / Airports / gnnode.cxx
index b7b21b04012c986dc46c87956f587c051b377f20..0dc0e8ff0a5cf5fba1038d73bdd6d30d943a61e2 100644 (file)
@@ -1,7 +1,13 @@
 #include "gnnode.hxx"
 #include "groundnetwork.hxx"
 
+#include <iostream>
 #include <algorithm>
+
+#include <osg/Geode>
+#include <Main/globals.hxx>
+#include <Scenery/scenery.hxx>
+
 using std::sort;
 
 /*****************************************************************************
@@ -31,9 +37,9 @@ double processPosition(const string &pos)
   return value;
 }
 
-bool sortByHeadingDiff(FGTaxiSegment *a, FGTaxiSegment *b) {
-  return a->hasSmallerHeadingDiff(*b);
-}
+//bool sortByHeadingDiff(FGTaxiSegment *a, FGTaxiSegment *b) {
+//  return a->hasSmallerHeadingDiff(*b);
+//}
 
 bool sortByLength(FGTaxiSegment *a, FGTaxiSegment *b) {
   return a->getLength() > b->getLength();
@@ -42,12 +48,51 @@ bool sortByLength(FGTaxiSegment *a, FGTaxiSegment *b) {
 /**************************************************************************
  * FGTaxiNode
  *************************************************************************/
+void FGTaxiNode::setElevation(double val)
+{
+    geod.setElevationM(val);
+}
 
+void FGTaxiNode::setLatitude (double val)
+{
+  geod.setLatitudeDeg(val);
+}
+
+void FGTaxiNode::setLongitude(double val)
+{
+  geod.setLongitudeDeg(val);
+}
+
+void FGTaxiNode::setLatitude (const string& val)
+{
+  geod.setLatitudeDeg(processPosition(val));
+}
+
+void FGTaxiNode::setLongitude(const string& val)
+{
+  geod.setLongitudeDeg(processPosition(val));
+}
+  
+double FGTaxiNode::getElevationFt(double refelev)
+{
+    double elevF = geod.getElevationFt();
+    double elevationEnd = 0;
+    if ((elevF == 0) || (elevF == refelev)) {
+        SGGeod center2 = geod;
+        FGScenery * local_scenery = globals->get_scenery();
+        center2.setElevationM(SG_MAX_ELEVATION_M);
+        if (local_scenery->get_elevation_m( center2, elevationEnd, NULL )) {
+            geod.setElevationM(elevationEnd);
+        }
+    }
+    //cerr << "Returning elevation : " << geod.getElevationM() << ". Ref elev (feet) = " << refelev << endl;
+    return geod.getElevationFt();
+}
 
-void FGTaxiNode::sortEndSegments(bool byLength)
+double FGTaxiNode::getElevationM(double refelev)
 {
-  if (byLength)
-    sort(next.begin(), next.end(), sortByLength);
-  else
-    sort(next.begin(), next.end(), sortByHeadingDiff);
+    //double refelevFt = refelev * SG_METER_TO_FEET;
+    //double retval = getElevationFt(refelevFt);
+    //cerr << "Returning elevation : " << geod.getElevationM() << ". Ref elev (meters) = " << refelev << endl;
+    return geod.getElevationM();
 }