]> git.mxchange.org Git - flightgear.git/commitdiff
Give the FGAirport class a sane filename.
authorJames Turner <zakalawe@mac.com>
Thu, 21 Feb 2013 11:32:02 +0000 (11:32 +0000)
committerJames Turner <zakalawe@mac.com>
Thu, 21 Feb 2013 11:32:02 +0000 (11:32 +0000)
simple.[cxx|hxx] -> airport.[cxx|hxx]

52 files changed:
src/AIModel/AIAircraft.cxx
src/AIModel/AIFlightPlan.cxx
src/AIModel/AIFlightPlanCreate.cxx
src/AIModel/AIFlightPlanCreateCruise.cxx
src/AIModel/AIFlightPlanCreatePushBack.cxx
src/AIModel/AIManager.cxx
src/ATC/atc_mgr.cxx
src/ATC/atcdialog.cxx
src/ATC/trafficcontrol.cxx
src/ATCDCL/ATC.cxx
src/ATCDCL/ATCutils.hxx
src/Airports/CMakeLists.txt
src/Airports/airport.cxx [new file with mode: 0644]
src/Airports/airport.hxx [new file with mode: 0644]
src/Airports/apt_loader.cxx
src/Airports/dynamicloader.cxx
src/Airports/dynamics.cxx
src/Airports/groundnetwork.cxx
src/Airports/runwayprefs.cxx
src/Airports/runways.cxx
src/Airports/sidstar.cxx
src/Airports/simple.cxx [deleted file]
src/Airports/simple.hxx [deleted file]
src/Airports/xmlloader.cxx
src/Autopilot/route_mgr.cxx
src/Cockpit/NavDisplay.cxx
src/Cockpit/groundradar.cxx
src/Environment/environment_mgr.cxx
src/Environment/fgclouds.cxx
src/Environment/metarairportfilter.hxx
src/Environment/metarproperties.hxx
src/GUI/AirportList.cxx
src/GUI/MapWidget.cxx
src/Instrumentation/KLN89/kln89.cxx
src/Instrumentation/KLN89/kln89_page_apt.cxx
src/Instrumentation/dclgps.cxx
src/Instrumentation/gps.cxx
src/Instrumentation/mk_viii.cxx
src/Instrumentation/mk_viii.hxx
src/Main/fg_init.cxx
src/Main/positioninit.cxx
src/Navaids/FlightPlan.hxx
src/Navaids/LevelDXML.cxx
src/Navaids/NavDataCache.cxx
src/Navaids/navdb.cxx
src/Navaids/navrecord.cxx
src/Navaids/route.cxx
src/Navaids/waypoint.cxx
src/Scripting/NasalPositioned.cxx
src/Traffic/SchedFlight.cxx
src/Traffic/Schedule.cxx
src/Traffic/TrafficMgr.cxx

index b5ef2418798fd70e0299ec144d9e0c18c55fd7ac..d8f07ba7f66b3804269fc0aa9721a894db4008cb 100644 (file)
@@ -27,7 +27,7 @@
 #include <Scenery/scenery.hxx>
 #include <Scenery/tilemgr.hxx>
 #include <Airports/dynamics.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Main/util.hxx>
 
 #include <string>
index 5699a620c62bcf8520fa9bbb0f60d5ac928ef1dd..ce20ea2b30f44dfcd336bffe821f80695f66cd86 100644 (file)
@@ -33,7 +33,7 @@
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 #include <Main/fg_init.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/dynamics.hxx>
 #include <Airports/runways.hxx>
 #include <Airports/groundnetwork.hxx>
index e9851862a4d4926ab174105f32ab27ed596316b7..caad321e2ad3e6ec1022e7a3a428f44c8bf4fb96 100644 (file)
@@ -30,7 +30,7 @@
 #include <simgear/props/props.hxx>
 #include <simgear/props/props_io.hxx>
 
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/runways.hxx>
 #include <Airports/dynamics.hxx>
 #include "AIAircraft.hxx"
index 15c3d643f72989a61bf780f198a7388d0cdf4ce1..beecef8eb23946941a24563c0731f64234d522e6 100644 (file)
@@ -26,7 +26,7 @@
 #include <fstream>
 #include <iostream>
 
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/runways.hxx>
 #include <Airports/dynamics.hxx>
 
index d774f3b51494ef894cf3833d05f939229ee3e71f..cb5ade5cc79bbe3452490b08ed9ec80a192073c5 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <simgear/math/sg_geodesy.hxx>
 
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/runways.hxx>
 #include <Airports/dynamics.hxx>
 
index 3c5617247001250810cd6980ae2cf8cc9f94bddb..3e28cd0bef4205f1b5971f9fcf30f4c137e1a979 100644 (file)
@@ -29,7 +29,7 @@
 #include <boost/foreach.hpp>
 
 #include <Main/globals.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 
 #include "AIManager.hxx"
 #include "AIAircraft.hxx"
index 67d53c9fc05fdcd72336badf2db3f548ca6e462c..980e9df802e30c654b992b4db1480799a23387c6 100644 (file)
@@ -27,7 +27,7 @@
 #include <iostream>
 
 #include <Airports/dynamics.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Scenery/scenery.hxx>
 #include "atc_mgr.hxx"
 
index 1bf0c9cddaf04089f98bee2a290760b314f4e073..ad75f300164c5f0424b0fe89b0ae6ed3a5d8edc5 100644 (file)
@@ -41,7 +41,7 @@
 #include <Main/fg_props.hxx>
 #include <GUI/gui.h>           // mkDialog
 #include <GUI/new_gui.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <ATC/CommStation.hxx>
 
 using std::string;
index f35a02e88c6a2c7246b0183942aaf3fd0a52ccdf..137c68aebf9ef899eb6b0113a03c2c5032384de4 100644 (file)
@@ -48,7 +48,7 @@
 #include <Traffic/TrafficMgr.hxx>
 #include <Airports/groundnetwork.hxx>
 #include <Airports/dynamics.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Radio/radio.hxx>
 #include <signal.h>
 
index 9e868017b19111ccefb25fba399bc1aad156e36e..2236619749b4096a3f8e66f639fed72d0dc29d9e 100644 (file)
@@ -33,7 +33,7 @@
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 #include <ATC/CommStation.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 
 FGATC::FGATC() :
     freq(0),
index 38f0bda595899f82f39aaed8239424b3789a7f35..478ba7e9dc02534506285bfecae10c3550395192 100644 (file)
@@ -18,7 +18,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/runways.hxx>
 
 #include <math.h>
index 43f2a999f7ea28ac0b8f8b55ae63d9143fddf39e..f0cde69e7aff73041a27024142bcd50c72430074 100644 (file)
@@ -13,7 +13,7 @@ set(SOURCES
        runwayprefs.cxx
        runways.cxx
        sidstar.cxx
-       simple.cxx
+       airport.cxx
        xmlloader.cxx
        )
 
@@ -30,7 +30,7 @@ set(HEADERS
        runwayprefs.hxx
        runways.hxx
        sidstar.hxx
-       simple.hxx
+       airport.hxx
        xmlloader.hxx
        )
                
diff --git a/src/Airports/airport.cxx b/src/Airports/airport.cxx
new file mode 100644 (file)
index 0000000..ba85516
--- /dev/null
@@ -0,0 +1,732 @@
+//
+// simple.cxx -- a really simplistic class to manage airport ID,
+//               lat, lon of the center of one of it's runways, and
+//               elevation in feet.
+//
+// Written by Curtis Olson, started April 1998.
+// Updated by Durk Talsma, started December, 2004.
+//
+// Copyright (C) 1998  Curtis L. Olson  - http://www.flightgear.org/~curt
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+//
+// $Id$
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include "airport.hxx"
+
+#include <cassert>
+#include <boost/foreach.hpp>
+
+#include <simgear/misc/sg_path.hxx>
+#include <simgear/props/props.hxx>
+#include <simgear/props/props_io.hxx>
+#include <simgear/debug/logstream.hxx>
+#include <simgear/sg_inlines.h>
+#include <simgear/structure/exception.hxx>
+
+#include <Environment/environment_mgr.hxx>
+#include <Environment/environment.hxx>
+#include <Main/fg_props.hxx>
+#include <Airports/runways.hxx>
+#include <Airports/pavement.hxx>
+#include <Airports/dynamics.hxx>
+#include <Airports/xmlloader.hxx>
+#include <Navaids/procedure.hxx>
+#include <Navaids/waypoint.hxx>
+#include <ATC/CommStation.hxx>
+#include <Navaids/NavDataCache.hxx>
+
+using std::vector;
+using std::pair;
+
+using namespace flightgear;
+
+
+/***************************************************************************
+ * FGAirport
+ ***************************************************************************/
+
+AirportCache FGAirport::airportCache;
+
+FGAirport::FGAirport(PositionedID aGuid, const string &id, const SGGeod& location,
+        const string &name, bool has_metar, Type aType) :
+    FGPositioned(aGuid, aType, id, location),
+    _name(name),
+    _has_metar(has_metar),
+    _dynamics(0),
+    mTowerDataLoaded(false),
+    mRunwaysLoaded(false),
+    mTaxiwaysLoaded(false),
+    mProceduresLoaded(false),
+    mILSDataLoaded(false)
+{
+}
+
+
+FGAirport::~FGAirport()
+{
+    delete _dynamics;
+}
+
+bool FGAirport::isAirport() const
+{
+  return type() == AIRPORT;
+}
+
+bool FGAirport::isSeaport() const
+{
+  return type() == SEAPORT;
+}
+
+bool FGAirport::isHeliport() const
+{
+  return type() == HELIPORT;
+}
+
+bool FGAirport::isAirportType(FGPositioned* pos)
+{
+    if (!pos) {
+        return false;
+    }
+    
+    return (pos->type() >= AIRPORT) && (pos->type() <= SEAPORT);
+}
+
+FGAirportDynamics * FGAirport::getDynamics()
+{
+    if (_dynamics) {
+        return _dynamics;
+    }
+    
+    _dynamics = new FGAirportDynamics(this);
+    XMLLoader::load(_dynamics);
+    _dynamics->init();
+  
+    FGRunwayPreference rwyPrefs(this);
+    XMLLoader::load(&rwyPrefs);
+    _dynamics->setRwyUse(rwyPrefs);
+    
+    return _dynamics;
+}
+
+unsigned int FGAirport::numRunways() const
+{
+  loadRunways();
+  return mRunways.size();
+}
+
+unsigned int FGAirport::numHelipads() const
+{
+  loadHelipads();
+  return mHelipads.size();
+}
+
+FGRunway* FGAirport::getRunwayByIndex(unsigned int aIndex) const
+{
+  loadRunways();
+  
+  assert(aIndex >= 0 && aIndex < mRunways.size());
+  return (FGRunway*) flightgear::NavDataCache::instance()->loadById(mRunways[aIndex]);
+}
+
+FGHelipad* FGAirport::getHelipadByIndex(unsigned int aIndex) const
+{
+  loadHelipads();
+
+  assert(aIndex >= 0 && aIndex < mHelipads.size());
+  return (FGHelipad*) flightgear::NavDataCache::instance()->loadById(mHelipads[aIndex]);
+}
+
+bool FGAirport::hasRunwayWithIdent(const string& aIdent) const
+{
+  return flightgear::NavDataCache::instance()->airportItemWithIdent(guid(), FGPositioned::RUNWAY, aIdent) != 0;
+}
+
+FGRunway* FGAirport::getRunwayByIdent(const string& aIdent) const
+{
+  PositionedID id = flightgear::NavDataCache::instance()->airportItemWithIdent(guid(), FGPositioned::RUNWAY, aIdent);  
+  if (id == 0) {
+    SG_LOG(SG_GENERAL, SG_ALERT, "no such runway '" << aIdent << "' at airport " << ident());
+    throw sg_range_exception("unknown runway " + aIdent + " at airport:" + ident(), "FGAirport::getRunwayByIdent");
+  }
+  
+  return (FGRunway*) flightgear::NavDataCache::instance()->loadById(id);
+}
+
+
+FGRunway* FGAirport::findBestRunwayForHeading(double aHeading) const
+{
+  loadRunways();
+  
+  FGRunway* result = NULL;
+  double currentBestQuality = 0.0;
+  
+  SGPropertyNode *param = fgGetNode("/sim/airport/runways/search", true);
+  double lengthWeight = param->getDoubleValue("length-weight", 0.01);
+  double widthWeight = param->getDoubleValue("width-weight", 0.01);
+  double surfaceWeight = param->getDoubleValue("surface-weight", 10);
+  double deviationWeight = param->getDoubleValue("deviation-weight", 1);
+    
+  BOOST_FOREACH(PositionedID id, mRunways) {
+    FGRunway* rwy = (FGRunway*) flightgear::NavDataCache::instance()->loadById(id);
+    double good = rwy->score(lengthWeight, widthWeight, surfaceWeight);
+    double dev = aHeading - rwy->headingDeg();
+    SG_NORMALIZE_RANGE(dev, -180.0, 180.0);
+    double bad = fabs(deviationWeight * dev) + 1e-20;
+    double quality = good / bad;
+    
+    if (quality > currentBestQuality) {
+      currentBestQuality = quality;
+      result = rwy;
+    }
+  }
+
+  return result;
+}
+
+FGRunway* FGAirport::findBestRunwayForPos(const SGGeod& aPos) const
+{
+  loadRunways();
+  
+  FGRunway* result = NULL;
+  double currentLowestDev = 180.0;
+  
+  BOOST_FOREACH(PositionedID id, mRunways) {
+    FGRunway* rwy = (FGRunway*) flightgear::NavDataCache::instance()->loadById(id);
+
+    double inboundCourse = SGGeodesy::courseDeg(aPos, rwy->end());
+    double dev = inboundCourse - rwy->headingDeg();
+    SG_NORMALIZE_RANGE(dev, -180.0, 180.0);
+
+    dev = fabs(dev);
+    if (dev < currentLowestDev) { // new best match
+      currentLowestDev = dev;
+      result = rwy;
+    }
+  } // of runway iteration
+  
+  return result;
+
+}
+
+bool FGAirport::hasHardRunwayOfLengthFt(double aLengthFt) const
+{
+  loadRunways();
+  
+  BOOST_FOREACH(PositionedID id, mRunways) {
+    FGRunway* rwy = (FGRunway*) flightgear::NavDataCache::instance()->loadById(id);
+
+    if (rwy->isReciprocal()) {
+      continue; // we only care about lengths, so don't do work twice
+    }
+
+    if (rwy->isHardSurface() && (rwy->lengthFt() >= aLengthFt)) {
+      return true; // we're done!
+    }
+  } // of runways iteration
+
+  return false;
+}
+
+unsigned int FGAirport::numTaxiways() const
+{
+  loadTaxiways();
+  return mTaxiways.size();
+}
+
+FGTaxiway* FGAirport::getTaxiwayByIndex(unsigned int aIndex) const
+{
+  loadTaxiways();
+  
+  assert(aIndex >= 0 && aIndex < mTaxiways.size());
+  return (FGTaxiway*) flightgear::NavDataCache::instance()->loadById(mTaxiways[aIndex]);
+}
+
+unsigned int FGAirport::numPavements() const
+{
+  loadTaxiways();
+  return mPavements.size();
+}
+
+FGPavement* FGAirport::getPavementByIndex(unsigned int aIndex) const
+{
+  loadTaxiways();
+  assert(aIndex >= 0 && aIndex < mPavements.size());
+  return (FGPavement*) flightgear::NavDataCache::instance()->loadById(mPavements[aIndex]);
+}
+
+FGRunway* FGAirport::getActiveRunwayForUsage() const
+{
+  FGEnvironmentMgr* envMgr = (FGEnvironmentMgr *) globals->get_subsystem("environment");
+  
+  // This forces West-facing rwys to be used in no-wind situations
+  // which is consistent with Flightgear's initial setup.
+  double hdg = 270;
+  
+  if (envMgr) {
+    FGEnvironment stationWeather(envMgr->getEnvironment(mPosition));
+  
+    double windSpeed = stationWeather.get_wind_speed_kt();
+    if (windSpeed > 0.0) {
+      hdg = stationWeather.get_wind_from_heading_deg();
+    }
+  }
+  
+  return findBestRunwayForHeading(hdg);
+}
+
+FGAirport* FGAirport::findClosest(const SGGeod& aPos, double aCuttofNm, Filter* filter)
+{
+  AirportFilter aptFilter;
+  if (filter == NULL) {
+    filter = &aptFilter;
+  }
+  
+  FGPositionedRef r = FGPositioned::findClosest(aPos, aCuttofNm, filter);
+  if (!r) {
+    return NULL;
+  }
+  
+  return static_cast<FGAirport*>(r.ptr());
+}
+
+FGAirport::HardSurfaceFilter::HardSurfaceFilter(double minLengthFt) :
+  mMinLengthFt(minLengthFt)
+{
+  if (minLengthFt < 0.0) {
+    mMinLengthFt = fgGetDouble("/sim/navdb/min-runway-length-ft", 0.0);
+  }
+}
+      
+bool FGAirport::HardSurfaceFilter::passAirport(FGAirport* aApt) const
+{
+  return aApt->hasHardRunwayOfLengthFt(mMinLengthFt);
+}
+
+FGAirport* FGAirport::findByIdent(const std::string& aIdent)
+{
+  AirportCache::iterator it = airportCache.find(aIdent);
+  if (it != airportCache.end())
+   return it->second;
+
+  PortsFilter filter;
+  FGAirport* r = static_cast<FGAirport*> (FGPositioned::findFirstWithIdent(aIdent, &filter).get());
+
+  // add airport to the cache (even when it's NULL, so we don't need to search in vain again)
+  airportCache[aIdent] = r;
+
+  // we don't warn here when r==NULL, let the caller do that
+  return r;
+}
+
+FGAirport* FGAirport::getByIdent(const std::string& aIdent)
+{
+  FGAirport* r = findByIdent(aIdent);
+  if (!r)
+    throw sg_range_exception("No such airport with ident: " + aIdent);
+  return r;
+}
+
+char** FGAirport::searchNamesAndIdents(const std::string& aFilter)
+{
+  return NavDataCache::instance()->searchAirportNamesAndIdents(aFilter);
+}
+
+// find basic airport location info from airport database
+const FGAirport *fgFindAirportID( const string& id)
+{
+    if ( id.empty() ) {
+        return NULL;
+    }
+    
+    return FGAirport::findByIdent(id);
+}
+
+void FGAirport::loadRunways() const
+{
+  if (mRunwaysLoaded) {
+    return; // already loaded, great
+  }
+  
+  loadSceneryDefinitions();
+  
+  mRunwaysLoaded = true;
+  mRunways = flightgear::NavDataCache::instance()->airportItemsOfType(guid(), FGPositioned::RUNWAY);
+}
+
+void FGAirport::loadHelipads() const
+{
+  if (mHelipadsLoaded) {
+    return; // already loaded, great
+  }
+
+  loadSceneryDefinitions();
+
+  mHelipadsLoaded = true;
+  mHelipads = flightgear::NavDataCache::instance()->airportItemsOfType(guid(), FGPositioned::HELIPAD);
+}
+
+void FGAirport::loadTaxiways() const
+{
+  if (mTaxiwaysLoaded) {
+    return; // already loaded, great
+  }
+  
+  mTaxiwaysLoaded =  true;
+  mTaxiways = flightgear::NavDataCache::instance()->airportItemsOfType(guid(), FGPositioned::TAXIWAY);
+}
+
+void FGAirport::loadProcedures() const
+{
+  if (mProceduresLoaded) {
+    return;
+  }
+  
+  mProceduresLoaded = true;
+  SGPath path;
+  if (!XMLLoader::findAirportData(ident(), "procedures", path)) {
+    SG_LOG(SG_GENERAL, SG_INFO, "no procedures data available for " << ident());
+    return;
+  }
+  
+  SG_LOG(SG_GENERAL, SG_INFO, ident() << ": loading procedures from " << path.str());
+  RouteBase::loadAirportProcedures(path, const_cast<FGAirport*>(this));
+}
+
+void FGAirport::loadSceneryDefinitions() const
+{
+  NavDataCache* cache = NavDataCache::instance();
+  SGPath path;
+  if (!XMLLoader::findAirportData(ident(), "threshold", path)) {
+    return; // no XML threshold data
+  }
+  
+  if (!cache->isCachedFileModified(path)) {
+    // cached values are correct, we're all done
+    return;
+  }
+  
+    flightgear::NavDataCache::Transaction txn(cache);
+    SGPropertyNode_ptr rootNode = new SGPropertyNode;
+    readProperties(path.str(), rootNode);
+    const_cast<FGAirport*>(this)->readThresholdData(rootNode);
+    cache->stampCacheFile(path);
+    txn.commit();
+}
+
+void FGAirport::readThresholdData(SGPropertyNode* aRoot)
+{
+  SGPropertyNode* runway;
+  int runwayIndex = 0;
+  for (; (runway = aRoot->getChild("runway", runwayIndex)) != NULL; ++runwayIndex) {
+    SGPropertyNode* t0 = runway->getChild("threshold", 0),
+      *t1 = runway->getChild("threshold", 1);
+    assert(t0);
+    assert(t1); // too strict? maybe we should finally allow single-ended runways
+    
+    processThreshold(t0);
+    processThreshold(t1);
+  } // of runways iteration
+}
+
+void FGAirport::processThreshold(SGPropertyNode* aThreshold)
+{
+  // first, let's identify the current runway
+  string rwyIdent(aThreshold->getStringValue("rwy"));
+  NavDataCache* cache = NavDataCache::instance(); 
+  PositionedID id = cache->airportItemWithIdent(guid(), FGPositioned::RUNWAY, rwyIdent);
+  if (id == 0) {
+    SG_LOG(SG_GENERAL, SG_DEBUG, "FGAirport::processThreshold: "
+           "found runway not defined in the global data:" << ident() << "/" << rwyIdent);
+    return;
+  }
+  
+  double lon = aThreshold->getDoubleValue("lon"),
+  lat = aThreshold->getDoubleValue("lat");
+  SGGeod newThreshold(SGGeod::fromDegM(lon, lat, mPosition.getElevationM()));
+  
+  double newHeading = aThreshold->getDoubleValue("hdg-deg");
+  double newDisplacedThreshold = aThreshold->getDoubleValue("displ-m") * SG_METER_TO_FEET;
+  double newStopway = aThreshold->getDoubleValue("stopw-m") * SG_METER_TO_FEET;
+  
+  cache->updateRunwayThreshold(id, newThreshold,
+                               newHeading, newDisplacedThreshold, newStopway);
+}
+
+SGGeod FGAirport::getTowerLocation() const
+{
+  validateTowerData();
+  
+  NavDataCache* cache = NavDataCache::instance();
+  PositionedIDVec towers = cache->airportItemsOfType(guid(), FGPositioned::TOWER);
+  if (towers.empty()) {
+    SG_LOG(SG_GENERAL, SG_ALERT, "No towers defined for:" <<ident());
+    return SGGeod();
+  }
+  
+  FGPositionedRef tower = cache->loadById(towers.front());
+  return tower->geod();
+}
+
+void FGAirport::validateTowerData() const
+{
+  if (mTowerDataLoaded) {
+    return;
+  }
+
+  mTowerDataLoaded = true;
+  NavDataCache* cache = NavDataCache::instance();
+  SGPath path;
+  if (!XMLLoader::findAirportData(ident(), "twr", path)) {
+    return; // no XML tower data
+  }
+  
+  if (!cache->isCachedFileModified(path)) {
+  // cached values are correct, we're all done
+    return;
+  }
+   
+  flightgear::NavDataCache::Transaction txn(cache);
+  SGPropertyNode_ptr rootNode = new SGPropertyNode;
+  readProperties(path.str(), rootNode);
+  const_cast<FGAirport*>(this)->readTowerData(rootNode);
+  cache->stampCacheFile(path);
+  txn.commit();
+}
+
+void FGAirport::readTowerData(SGPropertyNode* aRoot)
+{
+  SGPropertyNode* twrNode = aRoot->getChild("tower")->getChild("twr");
+  double lat = twrNode->getDoubleValue("lat"), 
+    lon = twrNode->getDoubleValue("lon"), 
+    elevM = twrNode->getDoubleValue("elev-m");  
+// tower elevation is AGL, not AMSL. Since we don't want to depend on the
+// scenery for a precise terrain elevation, we use the field elevation
+// (this is also what the apt.dat code does)
+  double fieldElevationM = geod().getElevationM();
+  SGGeod towerLocation(SGGeod::fromDegM(lon, lat, fieldElevationM + elevM));
+  
+  NavDataCache* cache = NavDataCache::instance();
+  PositionedIDVec towers = cache->airportItemsOfType(guid(), FGPositioned::TOWER);
+  if (towers.empty()) {
+    cache->insertTower(guid(), towerLocation);
+  } else {
+    // update the position
+    cache->updatePosition(towers.front(), towerLocation);
+  }
+}
+
+bool FGAirport::validateILSData()
+{
+  if (mILSDataLoaded) {
+    return false;
+  }
+  
+  mILSDataLoaded = true;
+  NavDataCache* cache = NavDataCache::instance();
+  SGPath path;
+  if (!XMLLoader::findAirportData(ident(), "ils", path)) {
+    return false; // no XML tower data
+  }
+  
+  if (!cache->isCachedFileModified(path)) {
+    // cached values are correct, we're all done
+    return false;
+  }
+  
+  SGPropertyNode_ptr rootNode = new SGPropertyNode;
+  readProperties(path.str(), rootNode);
+
+  flightgear::NavDataCache::Transaction txn(cache);
+  readILSData(rootNode);
+  cache->stampCacheFile(path);
+  txn.commit();
+    
+// we loaded data, tell the caller it might need to reload things
+  return true;
+}
+
+void FGAirport::readILSData(SGPropertyNode* aRoot)
+{
+  NavDataCache* cache = NavDataCache::instance();
+  
+  // find the entry matching the runway
+  SGPropertyNode* runwayNode, *ilsNode;
+  for (int i=0; (runwayNode = aRoot->getChild("runway", i)) != NULL; ++i) {
+    for (int j=0; (ilsNode = runwayNode->getChild("ils", j)) != NULL; ++j) {
+      // must match on both nav-ident and runway ident, to support the following:
+      // - runways with multiple distinct ILS installations (KEWD, for example)
+      // - runways where both ends share the same nav ident (LFAT, for example)
+      PositionedID ils = cache->findILS(guid(), ilsNode->getStringValue("rwy"),
+                                        ilsNode->getStringValue("nav-id"));
+      if (ils == 0) {
+        SG_LOG(SG_GENERAL, SG_INFO, "reading ILS data for " << ident() <<
+               ", couldn;t find runway/navaid for:" <<
+               ilsNode->getStringValue("rwy") << "/" <<
+               ilsNode->getStringValue("nav-id"));
+        continue;
+      }
+      
+      double hdgDeg = ilsNode->getDoubleValue("hdg-deg"),
+        lon = ilsNode->getDoubleValue("lon"),
+        lat = ilsNode->getDoubleValue("lat"),
+        elevM = ilsNode->getDoubleValue("elev-m");
+      cache->updateILS(ils, SGGeod::fromDegM(lon, lat, elevM), hdgDeg);
+    } // of ILS iteration
+  } // of runway iteration
+}
+
+void FGAirport::addSID(flightgear::SID* aSid)
+{
+  mSIDs.push_back(aSid);
+}
+
+void FGAirport::addSTAR(STAR* aStar)
+{
+  mSTARs.push_back(aStar);
+}
+
+void FGAirport::addApproach(Approach* aApp)
+{
+  mApproaches.push_back(aApp);
+}
+
+unsigned int FGAirport::numSIDs() const
+{
+  loadProcedures();
+  return mSIDs.size();
+}
+
+flightgear::SID* FGAirport::getSIDByIndex(unsigned int aIndex) const
+{
+  loadProcedures();
+  return mSIDs[aIndex];
+}
+
+flightgear::SID* FGAirport::findSIDWithIdent(const std::string& aIdent) const
+{
+  loadProcedures();
+  for (unsigned int i=0; i<mSIDs.size(); ++i) {
+    if (mSIDs[i]->ident() == aIdent) {
+      return mSIDs[i];
+    }
+  }
+  
+  return NULL;
+}
+
+unsigned int FGAirport::numSTARs() const
+{
+  loadProcedures();
+  return mSTARs.size();
+}
+
+STAR* FGAirport::getSTARByIndex(unsigned int aIndex) const
+{
+  loadProcedures();
+  return mSTARs[aIndex];
+}
+
+STAR* FGAirport::findSTARWithIdent(const std::string& aIdent) const
+{
+  loadProcedures();
+  for (unsigned int i=0; i<mSTARs.size(); ++i) {
+    if (mSTARs[i]->ident() == aIdent) {
+      return mSTARs[i];
+    }
+  }
+  
+  return NULL;
+}
+
+unsigned int FGAirport::numApproaches() const
+{
+  loadProcedures();
+  return mApproaches.size();
+}
+
+Approach* FGAirport::getApproachByIndex(unsigned int aIndex) const
+{
+  loadProcedures();
+  return mApproaches[aIndex];
+}
+
+Approach* FGAirport::findApproachWithIdent(const std::string& aIdent) const
+{
+  loadProcedures();
+  for (unsigned int i=0; i<mApproaches.size(); ++i) {
+    if (mApproaches[i]->ident() == aIdent) {
+      return mApproaches[i];
+    }
+  }
+  
+  return NULL;
+}
+
+CommStationList
+FGAirport::commStations() const
+{
+  NavDataCache* cache = NavDataCache::instance();
+  CommStationList result;
+  BOOST_FOREACH(PositionedID pos, cache->airportItemsOfType(guid(),
+                                                            FGPositioned::FREQ_GROUND,
+                                                            FGPositioned::FREQ_UNICOM))
+  {
+    result.push_back((CommStation*) cache->loadById(pos));
+  }
+  
+  return result;
+}
+
+CommStationList
+FGAirport::commStationsOfType(FGPositioned::Type aTy) const
+{
+  NavDataCache* cache = NavDataCache::instance();
+  CommStationList result;
+  BOOST_FOREACH(PositionedID pos, cache->airportItemsOfType(guid(), aTy)) {
+    result.push_back((CommStation*) cache->loadById(pos));
+  }
+  
+  return result;
+}
+
+// get airport elevation
+double fgGetAirportElev( const string& id )
+{
+    const FGAirport *a=fgFindAirportID( id);
+    if (a) {
+        return a->getElevation();
+    } else {
+        return -9999.0;
+    }
+}
+
+
+// get airport position
+SGGeod fgGetAirportPos( const string& id )
+{
+    const FGAirport *a = fgFindAirportID( id);
+
+    if (a) {
+        return SGGeod::fromDegM(a->getLongitude(), a->getLatitude(), a->getElevation());
+    } else {
+        return SGGeod::fromDegM(0.0, 0.0, -9999.0);
+    }
+}
diff --git a/src/Airports/airport.hxx b/src/Airports/airport.hxx
new file mode 100644 (file)
index 0000000..b58b2f3
--- /dev/null
@@ -0,0 +1,293 @@
+// airport.hxx -- a really simplistic class to manage airport ID,
+//                 lat, lon of the center of one of it's runways, and
+//                 elevation in feet.
+//
+// Written by Curtis Olson, started April 1998.
+// Updated by Durk Talsma, started December 2004.
+//
+// Copyright (C) 1998  Curtis L. Olson  - http://www.flightgear.org/~curt
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+//
+// $Id$
+
+
+#ifndef _FG_SIMPLE_HXX
+#define _FG_SIMPLE_HXX
+
+#include <simgear/compiler.h>
+
+#include <string>
+#include <vector>
+#include <map>
+
+#include <Navaids/positioned.hxx>
+
+// forward decls
+class FGAirportDynamics;
+class FGRunway;
+class FGHelipad;
+class FGTaxiway;
+class FGPavement;
+class SGPropertyNode;
+class FGAirport;
+
+namespace flightgear {
+  class SID;
+  class STAR;
+  class Approach;
+  class Waypt;
+  class CommStation;
+
+  typedef SGSharedPtr<Waypt> WayptRef;
+  typedef std::vector<WayptRef> WayptVec;
+  
+  typedef std::vector<CommStation*> CommStationList;
+  typedef std::map<std::string, FGAirport*> AirportCache;
+}
+
+
+
+/***************************************************************************************
+ *
+ **************************************************************************************/
+class FGAirport : public FGPositioned
+{
+public:
+    FGAirport(PositionedID aGuid, const std::string& id, const SGGeod& location,
+            const std::string& name, bool has_metar, Type aType);
+    ~FGAirport();
+
+    const std::string& getId() const { return ident(); }
+    const std::string& getName() const { return _name; }
+    double getLongitude() const { return longitude(); }
+    // Returns degrees
+    double getLatitude()  const { return latitude(); }
+    // Returns ft
+    double getElevation() const { return elevation(); }
+    bool   getMetar()     const { return _has_metar; }
+    bool   isAirport()    const;
+    bool   isSeaport()    const;
+    bool   isHeliport()   const;
+
+    static bool isAirportType(FGPositioned* pos);
+    
+    virtual const std::string& name() const
+    { return _name; }
+
+    /**
+     * reload the ILS data from XML if required.
+     * @result true if the data was refreshed, false if no data was loaded
+     * or previously cached data is still correct.
+     */
+    bool validateILSData();
+
+    SGGeod getTowerLocation() const;
+
+    void setMetar(bool value) { _has_metar = value; }
+
+    FGRunway* getActiveRunwayForUsage() const;
+
+    FGAirportDynamics *getDynamics();
+    
+    unsigned int numRunways() const;
+    unsigned int numHelipads() const;
+    FGRunway* getRunwayByIndex(unsigned int aIndex) const;
+    FGHelipad* getHelipadByIndex(unsigned int aIndex) const;
+
+    bool hasRunwayWithIdent(const std::string& aIdent) const;
+    FGRunway* getRunwayByIdent(const std::string& aIdent) const;
+    FGRunway* findBestRunwayForHeading(double aHeading) const;
+    
+    /**
+     * return the most likely target runway based on a position.
+     * Specifically, return the runway for which the course from aPos
+     * to the runway end, mostly closely matches the runway heading.
+     * This is a good approximation of which runway the position is on or
+     * aiming towards.
+     */
+    FGRunway* findBestRunwayForPos(const SGGeod& aPos) const;
+    
+     /**
+     * Useful predicate for FMS/GPS/NAV displays and similar - check if this
+     * aiport has a hard-surfaced runway of at least the specified length.
+     */
+    bool hasHardRunwayOfLengthFt(double aLengthFt) const;
+
+    unsigned int numTaxiways() const;
+    FGTaxiway* getTaxiwayByIndex(unsigned int aIndex) const;
+
+    unsigned int numPavements() const;
+    FGPavement* getPavementByIndex(unsigned int aIndex) const;
+    
+    class AirportFilter : public Filter
+     {
+     public:
+       virtual bool pass(FGPositioned* aPos) const { 
+         return passAirport(static_cast<FGAirport*>(aPos));
+       }
+       
+       virtual Type minType() const {
+         return AIRPORT;
+       }
+       
+       virtual Type maxType() const {
+         return AIRPORT;
+       }
+       
+       virtual bool passAirport(FGAirport* aApt) const {
+         return true;
+       }
+     };
+     
+     /**
+      * Filter which passes heliports and seaports in addition to airports
+      */
+     class PortsFilter : public AirportFilter
+     {
+     public:
+       virtual Type maxType() const {
+         return SEAPORT;
+       }
+     };
+     
+     class HardSurfaceFilter : public AirportFilter
+     {
+     public:
+       HardSurfaceFilter(double minLengthFt = -1);
+       
+       virtual bool passAirport(FGAirport* aApt) const;
+       
+     private:
+       double mMinLengthFt;
+     };
+     
+     
+     void setProcedures(const std::vector<flightgear::SID*>& aSids,
+      const std::vector<flightgear::STAR*>& aStars,
+      const std::vector<flightgear::Approach*>& aApproaches);
+     
+     void addSID(flightgear::SID* aSid);
+      void addSTAR(flightgear::STAR* aStar);
+      void addApproach(flightgear::Approach* aApp);
+
+      unsigned int numSIDs() const;
+      flightgear::SID* getSIDByIndex(unsigned int aIndex) const;
+      flightgear::SID* findSIDWithIdent(const std::string& aIdent) const;
+      
+      unsigned int numSTARs() const;
+      flightgear::STAR* getSTARByIndex(unsigned int aIndex) const;
+      flightgear::STAR* findSTARWithIdent(const std::string& aIdent) const;
+      
+      unsigned int numApproaches() const;
+      flightgear::Approach* getApproachByIndex(unsigned int aIndex) const;
+      flightgear::Approach* findApproachWithIdent(const std::string& aIdent) const;
+  
+     /**
+      * Syntactic wrapper around FGPositioned::findClosest - find the closest
+      * match for filter, and return it cast to FGAirport. The default filter
+      * passes airports, but not seaports or heliports
+      */
+     static FGAirport* findClosest(const SGGeod& aPos, double aCuttofNm, Filter* filter = NULL);
+     
+     /**
+      * Helper to look up an FGAirport instance by unique ident. Throws an 
+      * exception if the airport could not be found - so callers can assume
+      * the result is non-NULL.
+      */
+     static FGAirport* getByIdent(const std::string& aIdent);
+     
+     /**
+      * Helper to look up an FGAirport instance by unique ident. Returns NULL
+      * if the airport could not be found.
+      */
+     static FGAirport* findByIdent(const std::string& aIdent);
+     
+     /**
+      * Specialised helper to implement the AirportList dialog. Performs a
+      * case-insensitive search on airport names and ICAO codes, and returns
+      * matches in a format suitable for use by a puaList. 
+      */
+     static char** searchNamesAndIdents(const std::string& aFilter);
+         
+    flightgear::CommStationList commStationsOfType(FGPositioned::Type aTy) const;
+    
+    flightgear::CommStationList commStations() const;
+private:
+    static flightgear::AirportCache airportCache;
+
+    // disable these
+    FGAirport operator=(FGAirport &other);
+    FGAirport(const FGAirport&);
+  
+    /**
+     * helper to read airport data from the scenery XML files.
+     */
+    void loadSceneryDefinitions() const;
+    
+    /**
+     * Helpers to process property data loaded from an ICAO.threshold.xml file
+     */
+    void readThresholdData(SGPropertyNode* aRoot);
+    void processThreshold(SGPropertyNode* aThreshold);
+      
+    void readILSData(SGPropertyNode* aRoot);
+  
+    void validateTowerData() const;
+    
+    /**
+     * Helper to parse property data loaded from an ICAO.twr.xml file
+     */
+    void readTowerData(SGPropertyNode* aRoot);
+    
+    std::string _name;
+    bool _has_metar;
+    FGAirportDynamics *_dynamics;
+
+    void loadRunways() const;
+    void loadHelipads() const;
+    void loadTaxiways() const;
+    void loadProcedures() const;
+    
+    mutable bool mTowerDataLoaded;
+    mutable bool mRunwaysLoaded;
+    mutable bool mHelipadsLoaded;
+    mutable bool mTaxiwaysLoaded;
+    mutable bool mProceduresLoaded;
+    bool mILSDataLoaded;
+  
+    mutable PositionedIDVec mRunways;
+    mutable PositionedIDVec mHelipads;
+    mutable PositionedIDVec mTaxiways;
+    PositionedIDVec mPavements;
+    
+    typedef SGSharedPtr<flightgear::SID> SIDRef;
+    typedef SGSharedPtr<flightgear::STAR> STARRef;
+    typedef SGSharedPtr<flightgear::Approach> ApproachRef;
+    
+    std::vector<SIDRef> mSIDs;
+    std::vector<STARRef> mSTARs;
+    std::vector<ApproachRef> mApproaches;
+  };
+
+// find basic airport location info from airport database
+const FGAirport *fgFindAirportID( const std::string& id);
+
+// get airport elevation
+double fgGetAirportElev( const std::string& id );
+
+#endif // _FG_SIMPLE_HXX
+
+
index c223890fc1a4dcc1387d11a0b013ae226145b4ca..f4ad7793a8bf8b48122055598b85398d57ae9752 100644 (file)
@@ -43,7 +43,7 @@
 
 #include <string>
 
-#include "simple.hxx"
+#include "airport.hxx"
 #include "runways.hxx"
 #include "pavement.hxx"
 #include <Navaids/NavDataCache.hxx>
index bf9335ae3d36b1f6d00174ea7d556707996c6a92..d35891b0df5f95b9fbe2b668e967ef25c960137c 100644 (file)
@@ -25,7 +25,7 @@
 
 #include <Navaids/NavDataCache.hxx>
 #include <Airports/dynamics.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 
 /*****************************************************************************
  * Helper function for parsing position string
index d505d580c3d267bfddeabf1827d165c5994c9e87..3c45a1c45a8e94eccfe908d5332c01edd1fccf61 100644 (file)
@@ -42,7 +42,7 @@
 #include <ATCDCL/ATCutils.hxx>
 #include <Navaids/NavDataCache.hxx>
 
-#include "simple.hxx"
+#include "airport.hxx"
 #include "dynamics.hxx"
 
 using std::string;
index 62d229f687dd183ee061b2bbfd8dbce88c2ad4a1..3ea86f979243adc66ece7db3a01d714e71a4045f 100644 (file)
@@ -43,7 +43,7 @@
 #include <simgear/structure/exception.hxx>
 #include <simgear/timing/timestamp.hxx>
 
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/dynamics.hxx>
 #include <Airports/runways.hxx>
 
index fac1807fb1820daed60be9f78eb696d81b2e5058..2a2fceb0f743251d07e162c952b6720caf8d679d 100644 (file)
@@ -36,7 +36,7 @@
 #include <Airports/runways.hxx>
 
 #include "runwayprefs.hxx"
-#include "simple.hxx"
+#include "airport.hxx"
 
 /******************************************************************************
  * ScheduleTime
index 753eaf0d5d5eaa45f8a8514a7f0add498d3f4a25..72fb1609d47cf2044473bd50600126cb9644ef7d 100644 (file)
@@ -37,7 +37,7 @@
 
 #include "runways.hxx"
 
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Navaids/procedure.hxx>
 #include <Navaids/navrecord.hxx>
 #include <Navaids/NavDataCache.hxx>
index e19ff192577548b868e48a372f5ce002c12e1eab..93360b432cbb87c8696e27ee62f67bca94e2da78 100644 (file)
@@ -30,7 +30,7 @@
 
 
 
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 
 
 #include "sidstar.hxx"
diff --git a/src/Airports/simple.cxx b/src/Airports/simple.cxx
deleted file mode 100644 (file)
index 1ed7e99..0000000
+++ /dev/null
@@ -1,732 +0,0 @@
-//
-// simple.cxx -- a really simplistic class to manage airport ID,
-//               lat, lon of the center of one of it's runways, and
-//               elevation in feet.
-//
-// Written by Curtis Olson, started April 1998.
-// Updated by Durk Talsma, started December, 2004.
-//
-// Copyright (C) 1998  Curtis L. Olson  - http://www.flightgear.org/~curt
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-//
-// $Id$
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#include "simple.hxx"
-
-#include <cassert>
-#include <boost/foreach.hpp>
-
-#include <simgear/misc/sg_path.hxx>
-#include <simgear/props/props.hxx>
-#include <simgear/props/props_io.hxx>
-#include <simgear/debug/logstream.hxx>
-#include <simgear/sg_inlines.h>
-#include <simgear/structure/exception.hxx>
-
-#include <Environment/environment_mgr.hxx>
-#include <Environment/environment.hxx>
-#include <Main/fg_props.hxx>
-#include <Airports/runways.hxx>
-#include <Airports/pavement.hxx>
-#include <Airports/dynamics.hxx>
-#include <Airports/xmlloader.hxx>
-#include <Navaids/procedure.hxx>
-#include <Navaids/waypoint.hxx>
-#include <ATC/CommStation.hxx>
-#include <Navaids/NavDataCache.hxx>
-
-using std::vector;
-using std::pair;
-
-using namespace flightgear;
-
-
-/***************************************************************************
- * FGAirport
- ***************************************************************************/
-
-AirportCache FGAirport::airportCache;
-
-FGAirport::FGAirport(PositionedID aGuid, const string &id, const SGGeod& location,
-        const string &name, bool has_metar, Type aType) :
-    FGPositioned(aGuid, aType, id, location),
-    _name(name),
-    _has_metar(has_metar),
-    _dynamics(0),
-    mTowerDataLoaded(false),
-    mRunwaysLoaded(false),
-    mTaxiwaysLoaded(false),
-    mProceduresLoaded(false),
-    mILSDataLoaded(false)
-{
-}
-
-
-FGAirport::~FGAirport()
-{
-    delete _dynamics;
-}
-
-bool FGAirport::isAirport() const
-{
-  return type() == AIRPORT;
-}
-
-bool FGAirport::isSeaport() const
-{
-  return type() == SEAPORT;
-}
-
-bool FGAirport::isHeliport() const
-{
-  return type() == HELIPORT;
-}
-
-bool FGAirport::isAirportType(FGPositioned* pos)
-{
-    if (!pos) {
-        return false;
-    }
-    
-    return (pos->type() >= AIRPORT) && (pos->type() <= SEAPORT);
-}
-
-FGAirportDynamics * FGAirport::getDynamics()
-{
-    if (_dynamics) {
-        return _dynamics;
-    }
-    
-    _dynamics = new FGAirportDynamics(this);
-    XMLLoader::load(_dynamics);
-    _dynamics->init();
-  
-    FGRunwayPreference rwyPrefs(this);
-    XMLLoader::load(&rwyPrefs);
-    _dynamics->setRwyUse(rwyPrefs);
-    
-    return _dynamics;
-}
-
-unsigned int FGAirport::numRunways() const
-{
-  loadRunways();
-  return mRunways.size();
-}
-
-unsigned int FGAirport::numHelipads() const
-{
-  loadHelipads();
-  return mHelipads.size();
-}
-
-FGRunway* FGAirport::getRunwayByIndex(unsigned int aIndex) const
-{
-  loadRunways();
-  
-  assert(aIndex >= 0 && aIndex < mRunways.size());
-  return (FGRunway*) flightgear::NavDataCache::instance()->loadById(mRunways[aIndex]);
-}
-
-FGHelipad* FGAirport::getHelipadByIndex(unsigned int aIndex) const
-{
-  loadHelipads();
-
-  assert(aIndex >= 0 && aIndex < mHelipads.size());
-  return (FGHelipad*) flightgear::NavDataCache::instance()->loadById(mHelipads[aIndex]);
-}
-
-bool FGAirport::hasRunwayWithIdent(const string& aIdent) const
-{
-  return flightgear::NavDataCache::instance()->airportItemWithIdent(guid(), FGPositioned::RUNWAY, aIdent) != 0;
-}
-
-FGRunway* FGAirport::getRunwayByIdent(const string& aIdent) const
-{
-  PositionedID id = flightgear::NavDataCache::instance()->airportItemWithIdent(guid(), FGPositioned::RUNWAY, aIdent);  
-  if (id == 0) {
-    SG_LOG(SG_GENERAL, SG_ALERT, "no such runway '" << aIdent << "' at airport " << ident());
-    throw sg_range_exception("unknown runway " + aIdent + " at airport:" + ident(), "FGAirport::getRunwayByIdent");
-  }
-  
-  return (FGRunway*) flightgear::NavDataCache::instance()->loadById(id);
-}
-
-
-FGRunway* FGAirport::findBestRunwayForHeading(double aHeading) const
-{
-  loadRunways();
-  
-  FGRunway* result = NULL;
-  double currentBestQuality = 0.0;
-  
-  SGPropertyNode *param = fgGetNode("/sim/airport/runways/search", true);
-  double lengthWeight = param->getDoubleValue("length-weight", 0.01);
-  double widthWeight = param->getDoubleValue("width-weight", 0.01);
-  double surfaceWeight = param->getDoubleValue("surface-weight", 10);
-  double deviationWeight = param->getDoubleValue("deviation-weight", 1);
-    
-  BOOST_FOREACH(PositionedID id, mRunways) {
-    FGRunway* rwy = (FGRunway*) flightgear::NavDataCache::instance()->loadById(id);
-    double good = rwy->score(lengthWeight, widthWeight, surfaceWeight);
-    double dev = aHeading - rwy->headingDeg();
-    SG_NORMALIZE_RANGE(dev, -180.0, 180.0);
-    double bad = fabs(deviationWeight * dev) + 1e-20;
-    double quality = good / bad;
-    
-    if (quality > currentBestQuality) {
-      currentBestQuality = quality;
-      result = rwy;
-    }
-  }
-
-  return result;
-}
-
-FGRunway* FGAirport::findBestRunwayForPos(const SGGeod& aPos) const
-{
-  loadRunways();
-  
-  FGRunway* result = NULL;
-  double currentLowestDev = 180.0;
-  
-  BOOST_FOREACH(PositionedID id, mRunways) {
-    FGRunway* rwy = (FGRunway*) flightgear::NavDataCache::instance()->loadById(id);
-
-    double inboundCourse = SGGeodesy::courseDeg(aPos, rwy->end());
-    double dev = inboundCourse - rwy->headingDeg();
-    SG_NORMALIZE_RANGE(dev, -180.0, 180.0);
-
-    dev = fabs(dev);
-    if (dev < currentLowestDev) { // new best match
-      currentLowestDev = dev;
-      result = rwy;
-    }
-  } // of runway iteration
-  
-  return result;
-
-}
-
-bool FGAirport::hasHardRunwayOfLengthFt(double aLengthFt) const
-{
-  loadRunways();
-  
-  BOOST_FOREACH(PositionedID id, mRunways) {
-    FGRunway* rwy = (FGRunway*) flightgear::NavDataCache::instance()->loadById(id);
-
-    if (rwy->isReciprocal()) {
-      continue; // we only care about lengths, so don't do work twice
-    }
-
-    if (rwy->isHardSurface() && (rwy->lengthFt() >= aLengthFt)) {
-      return true; // we're done!
-    }
-  } // of runways iteration
-
-  return false;
-}
-
-unsigned int FGAirport::numTaxiways() const
-{
-  loadTaxiways();
-  return mTaxiways.size();
-}
-
-FGTaxiway* FGAirport::getTaxiwayByIndex(unsigned int aIndex) const
-{
-  loadTaxiways();
-  
-  assert(aIndex >= 0 && aIndex < mTaxiways.size());
-  return (FGTaxiway*) flightgear::NavDataCache::instance()->loadById(mTaxiways[aIndex]);
-}
-
-unsigned int FGAirport::numPavements() const
-{
-  loadTaxiways();
-  return mPavements.size();
-}
-
-FGPavement* FGAirport::getPavementByIndex(unsigned int aIndex) const
-{
-  loadTaxiways();
-  assert(aIndex >= 0 && aIndex < mPavements.size());
-  return (FGPavement*) flightgear::NavDataCache::instance()->loadById(mPavements[aIndex]);
-}
-
-FGRunway* FGAirport::getActiveRunwayForUsage() const
-{
-  FGEnvironmentMgr* envMgr = (FGEnvironmentMgr *) globals->get_subsystem("environment");
-  
-  // This forces West-facing rwys to be used in no-wind situations
-  // which is consistent with Flightgear's initial setup.
-  double hdg = 270;
-  
-  if (envMgr) {
-    FGEnvironment stationWeather(envMgr->getEnvironment(mPosition));
-  
-    double windSpeed = stationWeather.get_wind_speed_kt();
-    if (windSpeed > 0.0) {
-      hdg = stationWeather.get_wind_from_heading_deg();
-    }
-  }
-  
-  return findBestRunwayForHeading(hdg);
-}
-
-FGAirport* FGAirport::findClosest(const SGGeod& aPos, double aCuttofNm, Filter* filter)
-{
-  AirportFilter aptFilter;
-  if (filter == NULL) {
-    filter = &aptFilter;
-  }
-  
-  FGPositionedRef r = FGPositioned::findClosest(aPos, aCuttofNm, filter);
-  if (!r) {
-    return NULL;
-  }
-  
-  return static_cast<FGAirport*>(r.ptr());
-}
-
-FGAirport::HardSurfaceFilter::HardSurfaceFilter(double minLengthFt) :
-  mMinLengthFt(minLengthFt)
-{
-  if (minLengthFt < 0.0) {
-    mMinLengthFt = fgGetDouble("/sim/navdb/min-runway-length-ft", 0.0);
-  }
-}
-      
-bool FGAirport::HardSurfaceFilter::passAirport(FGAirport* aApt) const
-{
-  return aApt->hasHardRunwayOfLengthFt(mMinLengthFt);
-}
-
-FGAirport* FGAirport::findByIdent(const std::string& aIdent)
-{
-  AirportCache::iterator it = airportCache.find(aIdent);
-  if (it != airportCache.end())
-   return it->second;
-
-  PortsFilter filter;
-  FGAirport* r = static_cast<FGAirport*> (FGPositioned::findFirstWithIdent(aIdent, &filter).get());
-
-  // add airport to the cache (even when it's NULL, so we don't need to search in vain again)
-  airportCache[aIdent] = r;
-
-  // we don't warn here when r==NULL, let the caller do that
-  return r;
-}
-
-FGAirport* FGAirport::getByIdent(const std::string& aIdent)
-{
-  FGAirport* r = findByIdent(aIdent);
-  if (!r)
-    throw sg_range_exception("No such airport with ident: " + aIdent);
-  return r;
-}
-
-char** FGAirport::searchNamesAndIdents(const std::string& aFilter)
-{
-  return NavDataCache::instance()->searchAirportNamesAndIdents(aFilter);
-}
-
-// find basic airport location info from airport database
-const FGAirport *fgFindAirportID( const string& id)
-{
-    if ( id.empty() ) {
-        return NULL;
-    }
-    
-    return FGAirport::findByIdent(id);
-}
-
-void FGAirport::loadRunways() const
-{
-  if (mRunwaysLoaded) {
-    return; // already loaded, great
-  }
-  
-  loadSceneryDefinitions();
-  
-  mRunwaysLoaded = true;
-  mRunways = flightgear::NavDataCache::instance()->airportItemsOfType(guid(), FGPositioned::RUNWAY);
-}
-
-void FGAirport::loadHelipads() const
-{
-  if (mHelipadsLoaded) {
-    return; // already loaded, great
-  }
-
-  loadSceneryDefinitions();
-
-  mHelipadsLoaded = true;
-  mHelipads = flightgear::NavDataCache::instance()->airportItemsOfType(guid(), FGPositioned::HELIPAD);
-}
-
-void FGAirport::loadTaxiways() const
-{
-  if (mTaxiwaysLoaded) {
-    return; // already loaded, great
-  }
-  
-  mTaxiwaysLoaded =  true;
-  mTaxiways = flightgear::NavDataCache::instance()->airportItemsOfType(guid(), FGPositioned::TAXIWAY);
-}
-
-void FGAirport::loadProcedures() const
-{
-  if (mProceduresLoaded) {
-    return;
-  }
-  
-  mProceduresLoaded = true;
-  SGPath path;
-  if (!XMLLoader::findAirportData(ident(), "procedures", path)) {
-    SG_LOG(SG_GENERAL, SG_INFO, "no procedures data available for " << ident());
-    return;
-  }
-  
-  SG_LOG(SG_GENERAL, SG_INFO, ident() << ": loading procedures from " << path.str());
-  RouteBase::loadAirportProcedures(path, const_cast<FGAirport*>(this));
-}
-
-void FGAirport::loadSceneryDefinitions() const
-{
-  NavDataCache* cache = NavDataCache::instance();
-  SGPath path;
-  if (!XMLLoader::findAirportData(ident(), "threshold", path)) {
-    return; // no XML threshold data
-  }
-  
-  if (!cache->isCachedFileModified(path)) {
-    // cached values are correct, we're all done
-    return;
-  }
-  
-    flightgear::NavDataCache::Transaction txn(cache);
-    SGPropertyNode_ptr rootNode = new SGPropertyNode;
-    readProperties(path.str(), rootNode);
-    const_cast<FGAirport*>(this)->readThresholdData(rootNode);
-    cache->stampCacheFile(path);
-    txn.commit();
-}
-
-void FGAirport::readThresholdData(SGPropertyNode* aRoot)
-{
-  SGPropertyNode* runway;
-  int runwayIndex = 0;
-  for (; (runway = aRoot->getChild("runway", runwayIndex)) != NULL; ++runwayIndex) {
-    SGPropertyNode* t0 = runway->getChild("threshold", 0),
-      *t1 = runway->getChild("threshold", 1);
-    assert(t0);
-    assert(t1); // too strict? maybe we should finally allow single-ended runways
-    
-    processThreshold(t0);
-    processThreshold(t1);
-  } // of runways iteration
-}
-
-void FGAirport::processThreshold(SGPropertyNode* aThreshold)
-{
-  // first, let's identify the current runway
-  string rwyIdent(aThreshold->getStringValue("rwy"));
-  NavDataCache* cache = NavDataCache::instance(); 
-  PositionedID id = cache->airportItemWithIdent(guid(), FGPositioned::RUNWAY, rwyIdent);
-  if (id == 0) {
-    SG_LOG(SG_GENERAL, SG_DEBUG, "FGAirport::processThreshold: "
-           "found runway not defined in the global data:" << ident() << "/" << rwyIdent);
-    return;
-  }
-  
-  double lon = aThreshold->getDoubleValue("lon"),
-  lat = aThreshold->getDoubleValue("lat");
-  SGGeod newThreshold(SGGeod::fromDegM(lon, lat, mPosition.getElevationM()));
-  
-  double newHeading = aThreshold->getDoubleValue("hdg-deg");
-  double newDisplacedThreshold = aThreshold->getDoubleValue("displ-m") * SG_METER_TO_FEET;
-  double newStopway = aThreshold->getDoubleValue("stopw-m") * SG_METER_TO_FEET;
-  
-  cache->updateRunwayThreshold(id, newThreshold,
-                               newHeading, newDisplacedThreshold, newStopway);
-}
-
-SGGeod FGAirport::getTowerLocation() const
-{
-  validateTowerData();
-  
-  NavDataCache* cache = NavDataCache::instance();
-  PositionedIDVec towers = cache->airportItemsOfType(guid(), FGPositioned::TOWER);
-  if (towers.empty()) {
-    SG_LOG(SG_GENERAL, SG_ALERT, "No towers defined for:" <<ident());
-    return SGGeod();
-  }
-  
-  FGPositionedRef tower = cache->loadById(towers.front());
-  return tower->geod();
-}
-
-void FGAirport::validateTowerData() const
-{
-  if (mTowerDataLoaded) {
-    return;
-  }
-
-  mTowerDataLoaded = true;
-  NavDataCache* cache = NavDataCache::instance();
-  SGPath path;
-  if (!XMLLoader::findAirportData(ident(), "twr", path)) {
-    return; // no XML tower data
-  }
-  
-  if (!cache->isCachedFileModified(path)) {
-  // cached values are correct, we're all done
-    return;
-  }
-   
-  flightgear::NavDataCache::Transaction txn(cache);
-  SGPropertyNode_ptr rootNode = new SGPropertyNode;
-  readProperties(path.str(), rootNode);
-  const_cast<FGAirport*>(this)->readTowerData(rootNode);
-  cache->stampCacheFile(path);
-  txn.commit();
-}
-
-void FGAirport::readTowerData(SGPropertyNode* aRoot)
-{
-  SGPropertyNode* twrNode = aRoot->getChild("tower")->getChild("twr");
-  double lat = twrNode->getDoubleValue("lat"), 
-    lon = twrNode->getDoubleValue("lon"), 
-    elevM = twrNode->getDoubleValue("elev-m");  
-// tower elevation is AGL, not AMSL. Since we don't want to depend on the
-// scenery for a precise terrain elevation, we use the field elevation
-// (this is also what the apt.dat code does)
-  double fieldElevationM = geod().getElevationM();
-  SGGeod towerLocation(SGGeod::fromDegM(lon, lat, fieldElevationM + elevM));
-  
-  NavDataCache* cache = NavDataCache::instance();
-  PositionedIDVec towers = cache->airportItemsOfType(guid(), FGPositioned::TOWER);
-  if (towers.empty()) {
-    cache->insertTower(guid(), towerLocation);
-  } else {
-    // update the position
-    cache->updatePosition(towers.front(), towerLocation);
-  }
-}
-
-bool FGAirport::validateILSData()
-{
-  if (mILSDataLoaded) {
-    return false;
-  }
-  
-  mILSDataLoaded = true;
-  NavDataCache* cache = NavDataCache::instance();
-  SGPath path;
-  if (!XMLLoader::findAirportData(ident(), "ils", path)) {
-    return false; // no XML tower data
-  }
-  
-  if (!cache->isCachedFileModified(path)) {
-    // cached values are correct, we're all done
-    return false;
-  }
-  
-  SGPropertyNode_ptr rootNode = new SGPropertyNode;
-  readProperties(path.str(), rootNode);
-
-  flightgear::NavDataCache::Transaction txn(cache);
-  readILSData(rootNode);
-  cache->stampCacheFile(path);
-  txn.commit();
-    
-// we loaded data, tell the caller it might need to reload things
-  return true;
-}
-
-void FGAirport::readILSData(SGPropertyNode* aRoot)
-{
-  NavDataCache* cache = NavDataCache::instance();
-  
-  // find the entry matching the runway
-  SGPropertyNode* runwayNode, *ilsNode;
-  for (int i=0; (runwayNode = aRoot->getChild("runway", i)) != NULL; ++i) {
-    for (int j=0; (ilsNode = runwayNode->getChild("ils", j)) != NULL; ++j) {
-      // must match on both nav-ident and runway ident, to support the following:
-      // - runways with multiple distinct ILS installations (KEWD, for example)
-      // - runways where both ends share the same nav ident (LFAT, for example)
-      PositionedID ils = cache->findILS(guid(), ilsNode->getStringValue("rwy"),
-                                        ilsNode->getStringValue("nav-id"));
-      if (ils == 0) {
-        SG_LOG(SG_GENERAL, SG_INFO, "reading ILS data for " << ident() <<
-               ", couldn;t find runway/navaid for:" <<
-               ilsNode->getStringValue("rwy") << "/" <<
-               ilsNode->getStringValue("nav-id"));
-        continue;
-      }
-      
-      double hdgDeg = ilsNode->getDoubleValue("hdg-deg"),
-        lon = ilsNode->getDoubleValue("lon"),
-        lat = ilsNode->getDoubleValue("lat"),
-        elevM = ilsNode->getDoubleValue("elev-m");
-      cache->updateILS(ils, SGGeod::fromDegM(lon, lat, elevM), hdgDeg);
-    } // of ILS iteration
-  } // of runway iteration
-}
-
-void FGAirport::addSID(flightgear::SID* aSid)
-{
-  mSIDs.push_back(aSid);
-}
-
-void FGAirport::addSTAR(STAR* aStar)
-{
-  mSTARs.push_back(aStar);
-}
-
-void FGAirport::addApproach(Approach* aApp)
-{
-  mApproaches.push_back(aApp);
-}
-
-unsigned int FGAirport::numSIDs() const
-{
-  loadProcedures();
-  return mSIDs.size();
-}
-
-flightgear::SID* FGAirport::getSIDByIndex(unsigned int aIndex) const
-{
-  loadProcedures();
-  return mSIDs[aIndex];
-}
-
-flightgear::SID* FGAirport::findSIDWithIdent(const std::string& aIdent) const
-{
-  loadProcedures();
-  for (unsigned int i=0; i<mSIDs.size(); ++i) {
-    if (mSIDs[i]->ident() == aIdent) {
-      return mSIDs[i];
-    }
-  }
-  
-  return NULL;
-}
-
-unsigned int FGAirport::numSTARs() const
-{
-  loadProcedures();
-  return mSTARs.size();
-}
-
-STAR* FGAirport::getSTARByIndex(unsigned int aIndex) const
-{
-  loadProcedures();
-  return mSTARs[aIndex];
-}
-
-STAR* FGAirport::findSTARWithIdent(const std::string& aIdent) const
-{
-  loadProcedures();
-  for (unsigned int i=0; i<mSTARs.size(); ++i) {
-    if (mSTARs[i]->ident() == aIdent) {
-      return mSTARs[i];
-    }
-  }
-  
-  return NULL;
-}
-
-unsigned int FGAirport::numApproaches() const
-{
-  loadProcedures();
-  return mApproaches.size();
-}
-
-Approach* FGAirport::getApproachByIndex(unsigned int aIndex) const
-{
-  loadProcedures();
-  return mApproaches[aIndex];
-}
-
-Approach* FGAirport::findApproachWithIdent(const std::string& aIdent) const
-{
-  loadProcedures();
-  for (unsigned int i=0; i<mApproaches.size(); ++i) {
-    if (mApproaches[i]->ident() == aIdent) {
-      return mApproaches[i];
-    }
-  }
-  
-  return NULL;
-}
-
-CommStationList
-FGAirport::commStations() const
-{
-  NavDataCache* cache = NavDataCache::instance();
-  CommStationList result;
-  BOOST_FOREACH(PositionedID pos, cache->airportItemsOfType(guid(),
-                                                            FGPositioned::FREQ_GROUND,
-                                                            FGPositioned::FREQ_UNICOM))
-  {
-    result.push_back((CommStation*) cache->loadById(pos));
-  }
-  
-  return result;
-}
-
-CommStationList
-FGAirport::commStationsOfType(FGPositioned::Type aTy) const
-{
-  NavDataCache* cache = NavDataCache::instance();
-  CommStationList result;
-  BOOST_FOREACH(PositionedID pos, cache->airportItemsOfType(guid(), aTy)) {
-    result.push_back((CommStation*) cache->loadById(pos));
-  }
-  
-  return result;
-}
-
-// get airport elevation
-double fgGetAirportElev( const string& id )
-{
-    const FGAirport *a=fgFindAirportID( id);
-    if (a) {
-        return a->getElevation();
-    } else {
-        return -9999.0;
-    }
-}
-
-
-// get airport position
-SGGeod fgGetAirportPos( const string& id )
-{
-    const FGAirport *a = fgFindAirportID( id);
-
-    if (a) {
-        return SGGeod::fromDegM(a->getLongitude(), a->getLatitude(), a->getElevation());
-    } else {
-        return SGGeod::fromDegM(0.0, 0.0, -9999.0);
-    }
-}
diff --git a/src/Airports/simple.hxx b/src/Airports/simple.hxx
deleted file mode 100644 (file)
index a628712..0000000
+++ /dev/null
@@ -1,293 +0,0 @@
-// simple.hxx -- a really simplistic class to manage airport ID,
-//                 lat, lon of the center of one of it's runways, and
-//                 elevation in feet.
-//
-// Written by Curtis Olson, started April 1998.
-// Updated by Durk Talsma, started December 2004.
-//
-// Copyright (C) 1998  Curtis L. Olson  - http://www.flightgear.org/~curt
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-//
-// $Id$
-
-
-#ifndef _FG_SIMPLE_HXX
-#define _FG_SIMPLE_HXX
-
-#include <simgear/compiler.h>
-
-#include <string>
-#include <vector>
-#include <map>
-
-#include <Navaids/positioned.hxx>
-
-// forward decls
-class FGAirportDynamics;
-class FGRunway;
-class FGHelipad;
-class FGTaxiway;
-class FGPavement;
-class SGPropertyNode;
-class FGAirport;
-
-namespace flightgear {
-  class SID;
-  class STAR;
-  class Approach;
-  class Waypt;
-  class CommStation;
-
-  typedef SGSharedPtr<Waypt> WayptRef;
-  typedef std::vector<WayptRef> WayptVec;
-  
-  typedef std::vector<CommStation*> CommStationList;
-  typedef std::map<std::string, FGAirport*> AirportCache;
-}
-
-
-
-/***************************************************************************************
- *
- **************************************************************************************/
-class FGAirport : public FGPositioned
-{
-public:
-    FGAirport(PositionedID aGuid, const std::string& id, const SGGeod& location,
-            const std::string& name, bool has_metar, Type aType);
-    ~FGAirport();
-
-    const std::string& getId() const { return ident(); }
-    const std::string& getName() const { return _name; }
-    double getLongitude() const { return longitude(); }
-    // Returns degrees
-    double getLatitude()  const { return latitude(); }
-    // Returns ft
-    double getElevation() const { return elevation(); }
-    bool   getMetar()     const { return _has_metar; }
-    bool   isAirport()    const;
-    bool   isSeaport()    const;
-    bool   isHeliport()   const;
-
-    static bool isAirportType(FGPositioned* pos);
-    
-    virtual const std::string& name() const
-    { return _name; }
-
-    /**
-     * reload the ILS data from XML if required.
-     * @result true if the data was refreshed, false if no data was loaded
-     * or previously cached data is still correct.
-     */
-    bool validateILSData();
-
-    SGGeod getTowerLocation() const;
-
-    void setMetar(bool value) { _has_metar = value; }
-
-    FGRunway* getActiveRunwayForUsage() const;
-
-    FGAirportDynamics *getDynamics();
-    
-    unsigned int numRunways() const;
-    unsigned int numHelipads() const;
-    FGRunway* getRunwayByIndex(unsigned int aIndex) const;
-    FGHelipad* getHelipadByIndex(unsigned int aIndex) const;
-
-    bool hasRunwayWithIdent(const std::string& aIdent) const;
-    FGRunway* getRunwayByIdent(const std::string& aIdent) const;
-    FGRunway* findBestRunwayForHeading(double aHeading) const;
-    
-    /**
-     * return the most likely target runway based on a position.
-     * Specifically, return the runway for which the course from aPos
-     * to the runway end, mostly closely matches the runway heading.
-     * This is a good approximation of which runway the position is on or
-     * aiming towards.
-     */
-    FGRunway* findBestRunwayForPos(const SGGeod& aPos) const;
-    
-     /**
-     * Useful predicate for FMS/GPS/NAV displays and similar - check if this
-     * aiport has a hard-surfaced runway of at least the specified length.
-     */
-    bool hasHardRunwayOfLengthFt(double aLengthFt) const;
-
-    unsigned int numTaxiways() const;
-    FGTaxiway* getTaxiwayByIndex(unsigned int aIndex) const;
-
-    unsigned int numPavements() const;
-    FGPavement* getPavementByIndex(unsigned int aIndex) const;
-    
-    class AirportFilter : public Filter
-     {
-     public:
-       virtual bool pass(FGPositioned* aPos) const { 
-         return passAirport(static_cast<FGAirport*>(aPos));
-       }
-       
-       virtual Type minType() const {
-         return AIRPORT;
-       }
-       
-       virtual Type maxType() const {
-         return AIRPORT;
-       }
-       
-       virtual bool passAirport(FGAirport* aApt) const {
-         return true;
-       }
-     };
-     
-     /**
-      * Filter which passes heliports and seaports in addition to airports
-      */
-     class PortsFilter : public AirportFilter
-     {
-     public:
-       virtual Type maxType() const {
-         return SEAPORT;
-       }
-     };
-     
-     class HardSurfaceFilter : public AirportFilter
-     {
-     public:
-       HardSurfaceFilter(double minLengthFt = -1);
-       
-       virtual bool passAirport(FGAirport* aApt) const;
-       
-     private:
-       double mMinLengthFt;
-     };
-     
-     
-     void setProcedures(const std::vector<flightgear::SID*>& aSids,
-      const std::vector<flightgear::STAR*>& aStars,
-      const std::vector<flightgear::Approach*>& aApproaches);
-     
-     void addSID(flightgear::SID* aSid);
-      void addSTAR(flightgear::STAR* aStar);
-      void addApproach(flightgear::Approach* aApp);
-
-      unsigned int numSIDs() const;
-      flightgear::SID* getSIDByIndex(unsigned int aIndex) const;
-      flightgear::SID* findSIDWithIdent(const std::string& aIdent) const;
-      
-      unsigned int numSTARs() const;
-      flightgear::STAR* getSTARByIndex(unsigned int aIndex) const;
-      flightgear::STAR* findSTARWithIdent(const std::string& aIdent) const;
-      
-      unsigned int numApproaches() const;
-      flightgear::Approach* getApproachByIndex(unsigned int aIndex) const;
-      flightgear::Approach* findApproachWithIdent(const std::string& aIdent) const;
-  
-     /**
-      * Syntactic wrapper around FGPositioned::findClosest - find the closest
-      * match for filter, and return it cast to FGAirport. The default filter
-      * passes airports, but not seaports or heliports
-      */
-     static FGAirport* findClosest(const SGGeod& aPos, double aCuttofNm, Filter* filter = NULL);
-     
-     /**
-      * Helper to look up an FGAirport instance by unique ident. Throws an 
-      * exception if the airport could not be found - so callers can assume
-      * the result is non-NULL.
-      */
-     static FGAirport* getByIdent(const std::string& aIdent);
-     
-     /**
-      * Helper to look up an FGAirport instance by unique ident. Returns NULL
-      * if the airport could not be found.
-      */
-     static FGAirport* findByIdent(const std::string& aIdent);
-     
-     /**
-      * Specialised helper to implement the AirportList dialog. Performs a
-      * case-insensitive search on airport names and ICAO codes, and returns
-      * matches in a format suitable for use by a puaList. 
-      */
-     static char** searchNamesAndIdents(const std::string& aFilter);
-         
-    flightgear::CommStationList commStationsOfType(FGPositioned::Type aTy) const;
-    
-    flightgear::CommStationList commStations() const;
-private:
-    static flightgear::AirportCache airportCache;
-
-    // disable these
-    FGAirport operator=(FGAirport &other);
-    FGAirport(const FGAirport&);
-  
-    /**
-     * helper to read airport data from the scenery XML files.
-     */
-    void loadSceneryDefinitions() const;
-    
-    /**
-     * Helpers to process property data loaded from an ICAO.threshold.xml file
-     */
-    void readThresholdData(SGPropertyNode* aRoot);
-    void processThreshold(SGPropertyNode* aThreshold);
-      
-    void readILSData(SGPropertyNode* aRoot);
-  
-    void validateTowerData() const;
-    
-    /**
-     * Helper to parse property data loaded from an ICAO.twr.xml file
-     */
-    void readTowerData(SGPropertyNode* aRoot);
-    
-    std::string _name;
-    bool _has_metar;
-    FGAirportDynamics *_dynamics;
-
-    void loadRunways() const;
-    void loadHelipads() const;
-    void loadTaxiways() const;
-    void loadProcedures() const;
-    
-    mutable bool mTowerDataLoaded;
-    mutable bool mRunwaysLoaded;
-    mutable bool mHelipadsLoaded;
-    mutable bool mTaxiwaysLoaded;
-    mutable bool mProceduresLoaded;
-    bool mILSDataLoaded;
-  
-    mutable PositionedIDVec mRunways;
-    mutable PositionedIDVec mHelipads;
-    mutable PositionedIDVec mTaxiways;
-    PositionedIDVec mPavements;
-    
-    typedef SGSharedPtr<flightgear::SID> SIDRef;
-    typedef SGSharedPtr<flightgear::STAR> STARRef;
-    typedef SGSharedPtr<flightgear::Approach> ApproachRef;
-    
-    std::vector<SIDRef> mSIDs;
-    std::vector<STARRef> mSTARs;
-    std::vector<ApproachRef> mApproaches;
-  };
-
-// find basic airport location info from airport database
-const FGAirport *fgFindAirportID( const std::string& id);
-
-// get airport elevation
-double fgGetAirportElev( const std::string& id );
-
-#endif // _FG_SIMPLE_HXX
-
-
index 8ff3eb1fdae00f22fbb268c7922702f384091175..59a9ca9693d6fc3ae8a0118ab9d9169454907ebf 100644 (file)
@@ -32,7 +32,7 @@
 #include "runwayprefloader.hxx"
 
 #include "dynamics.hxx"
-#include "simple.hxx"
+#include "airport.hxx"
 #include "runwayprefs.hxx"
 
 #include <Navaids/NavDataCache.hxx>
index 4c41ebe7f4db9ca5c07b60b93db92385a6728fef..96f76325db2de6fbcb0e9c34f169490b2d853c68 100644 (file)
@@ -51,7 +51,7 @@
 #include "Navaids/positioned.hxx"
 #include <Navaids/waypoint.hxx>
 #include <Navaids/procedure.hxx>
-#include "Airports/simple.hxx"
+#include "Airports/airport.hxx"
 #include "Airports/runways.hxx"
 #include <GUI/new_gui.hxx>
 #include <GUI/dialog.hxx>
index 26720404a078f3504645c5899d514e622c8e9274..4c96c3ddea44e28b78e390634ea4a5cf20b5ec20 100644 (file)
@@ -70,7 +70,7 @@ using std::string;
 #include <Navaids/navrecord.hxx>
 #include <Navaids/navlist.hxx>
 #include <Navaids/fix.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/runways.hxx>
 #include "od_gauge.hxx"
 
index b7d2834136d5f8b370b75ce8d11388aa2457426c..7a2af9b62125ef2e19c5ae3dadd287afc72fae4a 100644 (file)
@@ -38,7 +38,7 @@
 #include <Main/globals.hxx>
 #include <Viewer/renderer.hxx>
 #include <Cockpit/panel.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/runways.hxx>
 #include <Airports/pavement.hxx>
 #include <simgear/math/sg_geodesy.hxx>
index b4e62bc15a8dde358902f8b9e22221cef8bf68c4..9aca5b0b5a86c7e6e20a7456a3ccf18aed6e4d1b 100644 (file)
@@ -43,7 +43,7 @@
 #include "precipitation_mgr.hxx"
 #include "ridge_lift.hxx"
 #include "terrainsampler.hxx"
-#include "Airports/simple.hxx"
+#include "Airports/airport.hxx"
 #include "gravity.hxx"
 #include "magvarmanager.hxx"
 
index 2374cd2360d29579d6d35f43823198baa5dc5812..f19d9d6fc5738255c943cf2bb81586a6fd688ce7 100644 (file)
@@ -40,7 +40,7 @@
 #include <Main/globals.hxx>
 #include <Main/util.hxx>
 #include <Viewer/renderer.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 
 #include "fgclouds.hxx"
 
index f31eb64f558f61f30cd6063427608cb8e2620df6..b20ac0a7e6d28e87c46459a63862b36adfbd8bfd 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef __METARAIRPORTFILTER_HXX
 #define __METARAIRPORTFILTER_HXX
 
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <simgear/props/props.hxx>
 
 namespace Environment {
index 7d108100defbf7f0d338197c6ca55c4571225d19..eac1af780003ba343af1db0bf4bc8d20a501e5b0 100644 (file)
@@ -23,7 +23,7 @@
 #ifndef __METARPROPERTIES_HXX
 #define __METARPROPERTIES_HXX
 
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <simgear/props/props.hxx>
 #include <simgear/props/tiedpropertylist.hxx>
 
index da25a861dcef80871649f23664e8ece6296b4344..5bff4f8999b31c3223f13491aaf5638faf1e75b8 100644 (file)
@@ -3,7 +3,7 @@
 #endif
 
 #include <Main/globals.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 
 #include "AirportList.hxx"
 
index 778cd72a7f315730c823faa88901febcc5460f22..b8bac7236bf9441cdd3343c3fd31137eb67177ff 100644 (file)
@@ -21,7 +21,7 @@
 #include <Navaids/navrecord.hxx>
 #include <Navaids/navlist.hxx>
 #include <Navaids/fix.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/runways.hxx>
 #include <Main/fg_os.hxx>      // fgGetKeyModifiers()
 #include <Navaids/routePath.hxx>
index 4cb5074419df5d770ec658518488f85d0a3f0f55..a084fea501dd383541ab1f050efe6752f2f802e5 100644 (file)
@@ -48,7 +48,7 @@
 
 #include <Main/fg_props.hxx>
 #include <simgear/structure/commands.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 
 #include <cstdio>
 
index c89c0f299db3a775bf7001ee039c4fb4b5e1578b..52a0778c319d202a75279171ae4ca1b15b3de47b 100644 (file)
@@ -34,7 +34,7 @@
 #include <ATC/CommStation.hxx>
 #include <Main/globals.hxx>
 #include <Airports/runways.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 
 using std::string;
 
index aeeb54fdc9534b322257aa15cb68e39b5b090dcd..24fba00405c47601889d1825c2a0824d07132025 100644 (file)
@@ -34,7 +34,7 @@
 #include <Main/fg_props.hxx>
 #include <Navaids/fix.hxx>
 #include <Navaids/navrecord.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/runways.hxx>
 
 #include <fstream>
index 3c26a539ba0a10ebb949ff7050e8a24df907477b..22094602bb8d09b4eca794a27cf8c341fcc5c8d9 100644 (file)
@@ -22,7 +22,7 @@
 #include "Navaids/positioned.hxx"
 #include <Navaids/waypoint.hxx>
 #include "Navaids/navrecord.hxx"
-#include "Airports/simple.hxx"
+#include "Airports/airport.hxx"
 #include "Airports/runways.hxx"
 #include "Autopilot/route_mgr.hxx"
 
index 9b0ee2b480428d5d32f0c16010907d18e914071d..eb40aee4d3b906a9f8d82b84436ceef99f821006 100644 (file)
@@ -76,7 +76,7 @@
 using std::string;
 
 #include <Airports/runways.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 
 #if defined( HAVE_VERSION_H ) && HAVE_VERSION_H
 #  include <Include/version.h>
index 25b50c3e4f08464cd3febe3c28d61a72490a70d4..81a33580b01f6c17b20365d0ca61000b9c7edafa 100644 (file)
@@ -38,7 +38,7 @@ using std::map;
 class SGSampleGroup;
 
 #include <Airports/runways.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Main/globals.hxx>
 #include <Sound/voiceplayer.hxx>
 
index 58bd9aeba7526ec586790c2d7d46eadc34030a6e..729301c2464d93eaa06cfd8189a584206c10b159 100644 (file)
@@ -59,7 +59,7 @@
 #include <Aircraft/replay.hxx>
 #include <Aircraft/FlightHistory.hxx>
 #include <Airports/runways.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/dynamics.hxx>
 
 #include <AIModel/AIManager.hxx>
index 777709ccf9845b988700dba9b67332bd47be1cc5..eb35799679e013dc0a09cf7a90642fe982603245 100644 (file)
@@ -32,7 +32,7 @@
 
 #include <Navaids/navlist.hxx>
 #include <Airports/runways.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/dynamics.hxx>
 #include <AIModel/AIManager.hxx>
 
index 84944069aa0202ae6a7e04ea2034b5e3133e92c6..d00c4860f11094c921c65b29a01d1faad51ecc40 100644 (file)
@@ -25,7 +25,7 @@
 #define FG_FLIGHTPLAN_HXX
 
 #include <Navaids/route.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 
 typedef SGSharedPtr<FGAirport> FGAirportRef;
     
index 41866cb71611fe66bbc1a76bd788f70b8e6a5aad..73b8f78f2287ba414304a91ebfc4d1aac4e88ea9 100644 (file)
@@ -10,7 +10,7 @@
 #include <simgear/misc/sg_path.hxx>
 
 #include <Navaids/waypoint.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 
 using std::string;
 using std::vector;
index 3cc8a255e3984f97eaac333cf485e3a5621b0b7c..1f1dc251a70cc7d8fb164b173eec852c5e1b29ee 100644 (file)
@@ -51,7 +51,7 @@
 #include <Main/globals.hxx>
 #include "markerbeacon.hxx"
 #include "navrecord.hxx"
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/runways.hxx>
 #include <ATC/CommStation.hxx>
 #include "fix.hxx"
index 42e0c2381832226e256efffee156f301a81497c2..9cc1654a974259e52e4c88d0b70cd73afd7303ff 100644 (file)
@@ -40,7 +40,7 @@
 #include "navlist.hxx"
 #include <Main/globals.hxx>
 #include <Navaids/markerbeacon.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/runways.hxx>
 #include <Airports/xmlloader.hxx>
 #include <Main/fg_props.hxx>
index c73e04b8fcb6a93ea1be64e40a9b849e1833d195..dc5cf7ab284995e7b06f89c359228116a216034b 100644 (file)
@@ -37,7 +37,7 @@
 #include <Navaids/navrecord.hxx>
 #include <Navaids/navdb.hxx>
 #include <Airports/runways.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/xmlloader.hxx>
 #include <Main/fg_props.hxx>
 #include <Navaids/NavDataCache.hxx>
index 9123d24c3059b0cc3cb6698b0d928fead8b7219f..6d6558a69e55e08fe7061ade87777773252be8b0 100644 (file)
@@ -48,7 +48,7 @@
 #include <Navaids/procedure.hxx>
 #include <Navaids/waypoint.hxx>
 #include <Navaids/LevelDXML.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 
 using std::string;
 using std::vector;
index 81e2c5c8261bd52ac8b563f50aed0665ac442b6f..aaeedd53c84dbcfc43f38fef9fdd5d96672d09c3 100644 (file)
@@ -25,7 +25,7 @@
 
 #include <simgear/structure/exception.hxx>
 
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/runways.hxx>
 
 using std::string;
index 4e10bd7d8b453052d760d68fdcc2a3d2930d653e..a01bf0c863c25963ca106af3ed8d4df41c9beba6 100644 (file)
@@ -37,7 +37,7 @@
 #include <simgear/bucket/newbucket.hxx>
 
 #include <Airports/runways.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/dynamics.hxx>
 #include <Airports/parking.hxx>
 #include <Scripting/NasalSys.hxx>
index 784c1443aed4bb4c67b2b4af57981252b16ce41c..4dc29b519206132c1879e9e5843d037ec67b53b8 100644 (file)
@@ -57,7 +57,7 @@
 
 #include <AIModel/AIFlightPlan.hxx>
 #include <AIModel/AIManager.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Main/fg_init.hxx>   // That's pretty ugly, but I need fgFindAirportID
 
 
index ea1ef0480a387991ebf7f8715264414bccbc0867..4ad1ed778e69b706c117330a06469f73ba1d89c9 100644 (file)
@@ -47,7 +47,7 @@
 #include <AIModel/AIFlightPlan.hxx>
 #include <AIModel/AIManager.hxx>
 #include <AIModel/AIAircraft.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Main/fg_init.hxx>   // That's pretty ugly, but I need fgFindAirportID
 
 
index 5c56d545103b9731786063dcd788107e057fe686..a9ab6e794a7ec7615c88e3b2fb2c36cad327d5e8 100644 (file)
@@ -64,7 +64,7 @@
 #include <AIModel/AIAircraft.hxx>
 #include <AIModel/AIFlightPlan.hxx>
 #include <AIModel/AIBase.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Main/fg_init.hxx>
 
 #include "TrafficMgr.hxx"