]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/mk_viii.cxx
warning fixes
[flightgear.git] / src / Instrumentation / mk_viii.cxx
index 6990d38a33ac6b9ff185697c3d3aee4ffa8bd393..4645ceef5d51d9881ea6174f4f825beeab13424b 100755 (executable)
 
 using std::string;
 
-#include "Airports/runways.hxx"
-#include "Airports/simple.hxx"
+#include <Airports/runways.hxx>
+#include <Airports/simple.hxx>
 #ifndef _MSC_VER
-#  include "Include/version.h"
+#  include <Include/version.h>
 #endif
-#include "Main/fg_props.hxx"
-#include "Main/globals.hxx"
+#include <Main/fg_props.hxx>
+#include <Main/globals.hxx>
 #include "instrument_mgr.hxx"
 #include "mk_viii.hxx"
 
@@ -4230,7 +4230,7 @@ MK_VIII::Mode6Handler::update_altitude_callouts ()
 bool
 MK_VIII::Mode6Handler::test_runway (const FGRunway *_runway)
 {
-  if (_runway->_length < mk->conf.runway_database)
+  if (_runway->lengthFt() < mk->conf.runway_database)
     return false;
 
   SGGeod pos(
@@ -4254,9 +4254,10 @@ MK_VIII::Mode6Handler::test_airport (const FGAirport *airport)
   return false;
 }
 
-bool MK_VIII::Mode6Handler::AirportFilter::pass(FGAirport* a)
+bool MK_VIII::Mode6Handler::AirportFilter::passAirport(FGAirport* a) const
 {
-  return self->test_airport(a);
+  bool ok = self->test_airport(a);
+  return ok;
 }
 
 void
@@ -4269,20 +4270,19 @@ MK_VIII::Mode6Handler::update_runway ()
   }
 
   // Search for the closest runway threshold in range 5
-  // nm. Passing 0.5 degrees (approximatively 30 nm) to
+  // nm. Passing 30nm to
   // get_closest_airport() provides enough margin for large
   // airports, which may have a runway located far away from the
   // airport's reference point.
   AirportFilter filter(this);
-  const FGAirport *airport = globals->get_airports()->search(
-    mk_data(gps_latitude).get(), mk_data(gps_longitude).get(),
-                       0.5, filter);
-
-  if (airport) {
-    runway.elevation = airport->getElevation();
+  FGPositionedRef apt = FGPositioned::findClosest(
+    SGGeod::fromDeg(mk_data(gps_longitude).get(), mk_data(gps_latitude).get()),
+    30.0, &filter);
+  if (apt) {
+    runway.elevation = apt->elevation();
   }
   
-  has_runway.set(airport != NULL);
+  has_runway.set(apt != NULL);
 }
 
 void
@@ -4493,17 +4493,11 @@ MK_VIII::TCFHandler::select_runway (const FGAirport *airport)
   return _runway;
 }
 
-bool MK_VIII::TCFHandler::AirportFilter::pass(FGAirport *a)
+bool MK_VIII::TCFHandler::AirportFilter::passAirport(FGAirport* aApt) const
 {
-  for (unsigned int r=0; r<a->numRunways(); ++r) {
-    if (a->getRunwayByIndex(r)->lengthFt() >= mk->conf.runway_database) {
-      return true;
-    }
-  }
-    
-  return false;
+  return aApt->hasHardRunwayOfLengthFt(mk->conf.runway_database);
 }
-
+   
 void
 MK_VIII::TCFHandler::update_runway ()
 {
@@ -4513,25 +4507,25 @@ MK_VIII::TCFHandler::update_runway ()
   }
 
   // Search for the intended destination runway of the closest
-  // airport in range 15 nm. Passing 0.5 degrees (approximatively
-  // 30 nm) to get_closest_airport() provides enough margin for
+  // airport in range 15 nm. Passing 30nm to get_closest_airport() 
+  // provides enough margin for
   // large airports, which may have a runway located far away from
   // the airport's reference point.
   AirportFilter filter(mk);
-  const FGAirport *airport = globals->get_airports()->search(
-      mk_data(gps_longitude).get(), mk_data(gps_latitude).get(),
-                       0.5, filter);
-
-  if (!airport) return;
+  FGAirport* apt = FGAirport::findClosest(
+    SGGeod::fromDeg(mk_data(gps_longitude).get(), mk_data(gps_latitude).get()),
+    30.0, &filter);
+      
+  if (!apt) return;
   
          has_runway = true;
 
-         FGRunway* _runway = select_runway(airport);
-
+         FGRunway* _runway = select_runway(apt);
+    
          runway.center.latitude = _runway->latitude();
          runway.center.longitude = _runway->longitude();
 
-         runway.elevation = airport->getElevation();
+         runway.elevation = apt->elevation();
 
          double half_length_m = _runway->lengthM() * 0.5;
          runway.half_length = half_length_m * SG_METER_TO_NM;