]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/approach.cxx
Default to glider again when model is not present.
[flightgear.git] / src / ATC / approach.cxx
index 5d9670687398c047b15a87c57f5aebe88a2e30be..d5faedd130053ae40da5ed2f3cf4b0c6b629a39e 100644 (file)
 #include <Airports/runways.hxx>
 
 #include <simgear/misc/sg_path.hxx>
-#include <WeatherCM/FGLocalWeatherDatabase.h>
 
+#ifdef FG_WEATHERCM
+# include <WeatherCM/FGLocalWeatherDatabase.h>
+#else
+# include <Environment/environment_mgr.hxx>
+# include <Environment/environment.hxx>
+#endif
 
 //Constructor
 FGApproach::FGApproach(){
@@ -184,8 +189,13 @@ void FGApproach::Update() {
 // ============================================================================
 void FGApproach::get_active_runway() {
 
+#ifdef FG_WEATHERCM
   sgVec3 position = { lat, lon, elev };
   FGPhysicalProperty stationweather = WeatherDatabase->get(position);
+#else
+  FGEnvironment stationweather =
+    globals->get_environment_mgr()->getEnvironment(lat, lon, elev);
+#endif
 
   SGPath path( globals->get_fg_root() );
   path.append( "Airports" );
@@ -193,6 +203,7 @@ void FGApproach::get_active_runway() {
   FGRunways runways( path.c_str() );
   
   //Set the heading to into the wind
+#ifdef FG_WEATHERCM
   double wind_x = stationweather.Wind[0];
   double wind_y = stationweather.Wind[1];
   
@@ -210,6 +221,9 @@ void FGApproach::get_active_runway() {
     if (hdg < 0.0)
       hdg += 360.0;
   }
+#else
+  double hdg = stationweather.get_wind_from_heading_deg();
+#endif
   
   FGRunway runway;
   if ( runways.search( ident, int(hdg), &runway) ) {
@@ -338,8 +352,9 @@ void FGApproach::calc_hd_course_dist(const double &h1, const double &d1,
 int FGApproach::RemovePlane() {
 
   // first check if anything has to be done
+  int i;
   bool rmplane = false;
-  for (int i=0; i<num_planes; i++) {
+  for (i=0; i<num_planes; i++) {
     if (planes[i].dist > range*SG_NM_TO_METER) {
       rmplane = true;
       break;
@@ -349,13 +364,13 @@ int FGApproach::RemovePlane() {
 
   // now make a copy of the plane list
   PlaneApp tmp[max_planes];
-  for (int i=0; i<num_planes; i++) {
+  for (i=0; i<num_planes; i++) {
     tmp[i] = planes[i];
   }
   
   int np = 0;
   // now check which planes are still in range
-  for (int i=0; i<num_planes; i++) {
+  for (i=0; i<num_planes; i++) {
     if (tmp[i].dist <= range*SG_NM_TO_METER) {
       planes[np] = tmp[i];
       np += 1;
@@ -363,4 +378,4 @@ int FGApproach::RemovePlane() {
   }
   num_planes = np;
   return num_planes;
-}
\ No newline at end of file
+}