]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATCDCL/approach.cxx
Merge branch 'tbm/graphics-bug' into next
[flightgear.git] / src / ATCDCL / approach.cxx
index 296e3446b102337ac349cd4c060b43bfe566cf35..6e75de47cd28c0b70beac0c901ccd8f974f5a00f 100644 (file)
@@ -30,6 +30,8 @@
 #include "ATCDialog.hxx"
 
 #include <Airports/runways.hxx>
+#include <Airports/simple.hxx>
+
 #include <simgear/constants.h>
 #include <simgear/math/polar3d.hxx>
 #include <simgear/misc/sg_path.hxx>
@@ -559,26 +561,15 @@ double FGApproach::round_alt( const bool hl, double alt ) {
 void FGApproach::get_active_runway() {
        //cout << "Entering FGApproach::get_active_runway()\n";
 
-  FGEnvironment stationweather =
-      ((FGEnvironmentMgr *)globals->get_subsystem("environment"))
-        ->getEnvironment(lat, lon, elev);
-
-  double hdg = stationweather.get_wind_from_heading_deg();
-  
-  FGRunway runway;
-  if ( globals->get_runways()->search( ident, int(hdg), &runway) ) {
-    active_runway = runway._rwy_no;
-    active_rw_hdg = runway._heading;
-    active_rw_lon = runway._lon;
-    active_rw_lat = runway._lat;
-    active_rw_len = runway._length;
-    //cout << "Active runway is: " << active_runway << "  heading = " 
-    // << active_rw_hdg 
-    // << " lon = " << active_rw_lon 
-    // << " lat = " << active_rw_lat <<endl;
-  }
-  else cout << "FGRunways search failed\n";
+  const FGAirport* apt = fgFindAirportID(ident);
+  assert(apt);
+  FGRunway* runway = apt->getActiveRunwayForUsage();
 
+  active_runway = runway->ident();
+  active_rw_hdg = runway->headingDeg();
+  active_rw_lon = runway->longitude();
+  active_rw_lat = runway->latitude();
+  active_rw_len = runway->lengthFt();
 }
 
 // ========================================================================