]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATCDCL/approach.cxx
Suppress warnings
[flightgear.git] / src / ATCDCL / approach.cxx
index 44784abf1e5b45c52db3bf70cea496b4fdbb661a..ed396b0d986966e0c8886138c1e5882fd6818441 100644 (file)
 #  include <config.h>
 #endif
 
+#include <iostream>
+
 #include "approach.hxx"
 #include "transmission.hxx"
 #include "transmissionlist.hxx"
 #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>
 
 #include <Environment/environment_mgr.hxx>
@@ -38,6 +41,9 @@
 
 #include <GUI/gui.h>
 
+using std::cout;
+using std::endl;
+
 //Constructor
 FGApproach::FGApproach(){
   comm1_node = fgGetNode("/instrumentation/comm[0]/frequencies/selected-mhz", true);
@@ -406,9 +412,8 @@ void FGApproach::calc_wp( const int &i ) {
        
        int wpn = planes[i].wpn;
        // waypoint 0: Threshold of active runway
-       calc_gc_course_dist(Point3D(lon*SGD_DEGREES_TO_RADIANS, lat*SGD_DEGREES_TO_RADIANS, 0.0),
-                           Point3D(active_rw_lon*SGD_DEGREES_TO_RADIANS,active_rw_lat*SGD_DEGREES_TO_RADIANS, 0.0 ),
-                           &course, &d);
+        course = SGGeoc::courseRad(SGGeoc::fromDegM(lon, lat, 6e6), SGGeoc::fromDegM(active_rw_lon, active_rw_lat, 6e6));
+        d = SGGeoc::distanceM(SGGeoc::fromDegM(lon, lat, 6e6), SGGeoc::fromDegM(active_rw_lon, active_rw_lat, 6e6));
        double d1 = active_rw_hdg+180.0;
        if ( d1 > 360.0 ) d1 -=360.0;
        calc_cd_head_dist(360.0-course*SGD_RADIANS_TO_DEGREES, d/SG_NM_TO_METER, 
@@ -554,26 +559,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();
 }
 
 // ========================================================================
@@ -591,13 +585,9 @@ void FGApproach::update_plane_dat() {
     planes[i].hdg = hdg_node->getDoubleValue();
     planes[i].spd = speed_node->getDoubleValue();
 
-    /*Point3D aircraft = sgGeodToCart( Point3D(planes[i].lon*SGD_DEGREES_TO_RADIANS, 
-                                            planes[i].lat*SGD_DEGREES_TO_RADIANS, 
-                                            planes[i].alt*SG_FEET_TO_METER) );*/
     double course, distance;
-    calc_gc_course_dist(Point3D(lon*SGD_DEGREES_TO_RADIANS, lat*SGD_DEGREES_TO_RADIANS, 0.0),
-                       Point3D(planes[i].lon*SGD_DEGREES_TO_RADIANS,planes[i].lat*SGD_DEGREES_TO_RADIANS, 0.0 ),
-                       &course, &distance);
+    course = SGGeoc::courseRad(SGGeoc::fromDegM(lon, lat, 6e6), SGGeoc::fromDegM(planes[i].lon, active_rw_lat, 6e6));
+    distance = SGGeoc::distanceM(SGGeoc::fromDegM(lon, lat, 6e6), SGGeoc::fromDegM(planes[i].lon, active_rw_lat, 6e6));
     planes[i].dist = distance/SG_NM_TO_METER;
     planes[i].brg  = 360.0-course*SGD_RADIANS_TO_DEGREES;