]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/simple.hxx
Conditional compilation of ATCDCL module. Use --disable-atcdcl to try building flight...
[flightgear.git] / src / Airports / simple.hxx
index 6d95bcf87626a1fadbca11c60873fc3145580e00..521c48c9abedb77afbe9435b675b6b04a17a966d 100644 (file)
 #include <string>
 #include <vector>
 
-#include "Navaids/positioned.hxx"
+#include <Navaids/positioned.hxx>
 
 // forward decls
 class FGAirportDynamics;
 class FGRunway;
+class FGTaxiway;
+class FGPavement;
+class SGPropertyNode;
 
 typedef SGSharedPtr<FGRunway> FGRunwayPtr;
+typedef SGSharedPtr<FGTaxiway> FGTaxiwayPtr;
+typedef SGSharedPtr<FGPavement> FGPavementPtr;
 
 /***************************************************************************************
  *
  **************************************************************************************/
 class FGAirport : public FGPositioned
 {
-private:
-    SGGeod _tower_location;
-    std::string _name;
-    bool _has_metar;
-    FGAirportDynamics *_dynamics;
-
 public:
     FGAirport(const std::string& id, const SGGeod& location, const SGGeod& tower, 
             const std::string& name, bool has_metar, Type aType);
@@ -91,27 +90,55 @@ public:
      * aiport has a hard-surfaced runway of at least the specified length.
      */
     bool hasHardRunwayOfLengthFt(double aLengthFt) const;
-    
+
     unsigned int numTaxiways() const;
-    FGRunway* getTaxiwayByIndex(unsigned int aIndex) const;
-    
-    void addRunway(FGRunway* aRunway);
+    FGTaxiway* getTaxiwayByIndex(unsigned int aIndex) const;
+
+    unsigned int numPavements() const;
+    FGPavement* getPavementByIndex(unsigned int aIndex) const;
+
+    void setRunwaysAndTaxiways(std::vector<FGRunwayPtr>& rwys,
+      std::vector<FGTaxiwayPtr>& txwys,
+      std::vector<FGPavementPtr>& pvts);
     
     class AirportFilter : public Filter
      {
      public:
        virtual bool pass(FGPositioned* aPos) const { 
-         Type ty(aPos->type());
-         return (ty >= AIRPORT) && (ty <= SEAPORT);
+         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 Filter
+     class HardSurfaceFilter : public AirportFilter
      {
      public:
        HardSurfaceFilter(double minLengthFt);
        
-       virtual bool pass(FGPositioned* aPos) const;
+       virtual bool passAirport(FGAirport* aApt) const;
+       
      private:
        double mMinLengthFt;
      };
@@ -119,7 +146,7 @@ public:
      /**
       * Syntactic wrapper around FGPositioned::findClosest - find the closest
       * match for filter, and return it cast to FGAirport. The default filter
-      * passes all airports, including seaports and heliports.
+      * passes airports, but not seaports or heliports
       */
      static FGAirport* findClosest(const SGGeod& aPos, double aCuttofNm, Filter* filter = NULL);
      
@@ -149,45 +176,40 @@ private:
      */
     Runway_iterator getIteratorForRunwayIdent(const std::string& aIdent) const;
 
+    // disable these
     FGAirport operator=(FGAirport &other);
     FGAirport(const FGAirport&);
+  
+    /**
+     * helper to read airport data from the scenery XML files.
+     */
+    void loadSceneryDefintions() const;
     
-    std::vector<FGRunwayPtr> mRunways;
-    std::vector<FGRunwayPtr> mTaxiways;
-};
-
-typedef std::vector < FGAirport * > airport_list;
-typedef airport_list::iterator airport_list_iterator;
-typedef airport_list::const_iterator const_airport_list_iterator;
-
-
-
-class FGAirportList {
-private:
-
-    airport_list airports_array;
-
-public:
-    // Constructor (new)
-    FGAirportList();
-
-    // Destructor
-    ~FGAirportList();
-
-    // add an entry to the list
-    FGAirport* add( const std::string& id, const SGGeod& location, const SGGeod& tower,
-              const std::string& name, bool has_metar, FGPositioned::Type aType);
-
     /**
-     * Return the number of airports in the list.
+     * Helpers to process property data loaded from an ICAO.threshold.xml file
      */
-    int size() const;
-
+    void readThresholdData(SGPropertyNode* aRoot);
+    void processThreshold(SGPropertyNode* aThreshold);
+    
     /**
-     * Return a specific airport, by position.
+     * Helper to parse property data loaded from an ICAO.twr.xml filke
      */
-    const FGAirport *getAirport( unsigned int index ) const;
+    void readTowerData(SGPropertyNode* aRoot);
+    
+    SGGeod _tower_location;
+    std::string _name;
+    bool _has_metar;
+    FGAirportDynamics *_dynamics;
 
+    void loadRunways() const;
+    void loadTaxiways() const;
+    
+    mutable bool mRunwaysLoaded;
+    mutable bool mTaxiwaysLoaded;
+    
+    std::vector<FGRunwayPtr> mRunways;
+    std::vector<FGTaxiwayPtr> mTaxiways;
+    std::vector<FGPavementPtr> mPavements;
 };
 
 // find basic airport location info from airport database