]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/procedure.hxx
Reduce severity of a failure to create a marker beacon due to an unknown runway from...
[flightgear.git] / src / Navaids / procedure.hxx
index f6d63e2867f22471df598c9db49bac6f588e0bdd..11bbf4908632236b80c08798a28493c1d29f45fb 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <set>
 
+#include <simgear/math/sg_types.hxx> // for string_list
+
 #include <Navaids/route.hxx>
 #include <Airports/runways.hxx>
 
@@ -32,12 +34,32 @@ namespace flightgear {
 // forward decls
 class NavdataVisitor;
 
-class Procedure : public Route
+typedef std::vector<FGRunwayRef> RunwayVec;
+  
+typedef enum {
+  PROCEDURE_INVALID,
+  PROCEDURE_APPROACH_ILS,
+  PROCEDURE_APPROACH_VOR,
+  PROCEDURE_APPROACH_NDB,
+  PROCEDURE_APPROACH_RNAV,
+  PROCEDURE_SID,
+  PROCEDURE_STAR,
+  PROCEDURE_TRANSITION,
+  PROCEDURE_RUNWAY_TRANSITION
+} ProcedureType;
+  
+class Procedure : public RouteBase
 {
-public:
-
+public:  
+  virtual ProcedureType type() const = 0;
+  
   virtual std::string ident() const
   { return _ident; }
+  
+  virtual FGAirport* airport() const = 0;
+  
+  virtual RunwayVec runways() const
+  { return RunwayVec(); }
 protected:
   Procedure(const std::string& aIdent);
   
@@ -47,14 +69,16 @@ protected:
 /**
  * Encapsulate a transition segment
  */
-class Transition : public Route
+class Transition : public Procedure
 {
 public:
-  bool route(Waypt* aEnroute, WayptVec& aPath);
+  bool route(WayptVec& aPath);
   
   Procedure* parent() const
   { return _parent; }
   
+  virtual FGAirport* airport() const;
+  
   /**
    * Return the enroute end of the transition
    */
@@ -65,16 +89,19 @@ public:
    */
   WayptRef procedureEnd() const;
   
-  virtual std::string ident() const
-  { return _ident; }
+  
+  virtual ProcedureType type() const
+  { return _type; }
+  
+  void mark(WayptFlag f);
 private:
   friend class NavdataVisitor;
 
-  Transition(const std::string& aIdent, Procedure* aPr);
+  Transition(const std::string& aIdent, ProcedureType ty, Procedure* aPr);
 
   void setPrimary(const WayptVec& aWps);
   
-  std::string _ident;
+  ProcedureType _type;
   Procedure* _parent;
   WayptVec _primary;
 };
@@ -89,6 +116,12 @@ public:
   FGRunwayRef runway() 
   { return _runway; }
 
+  static bool isApproach(ProcedureType ty);
+  
+  virtual FGAirport* airport() const;
+  
+  virtual RunwayVec runways() const;
+  
   /**
    * Build a route from a valid IAF to the runway, including the missed
    * segment. Return false if no valid transition from the specified IAF
@@ -108,16 +141,19 @@ public:
   const WayptVec& missed() const
     { return _missed; }
 
+  virtual ProcedureType type() const
+  { return _type; }
 private:
   friend class NavdataVisitor;
   
-  Approach(const std::string& aIdent);
+  Approach(const std::string& aIdent, ProcedureType ty);
   
   void setRunway(FGRunwayRef aRwy);
   void setPrimaryAndMissed(const WayptVec& aPrimary, const WayptVec& aMissed);
   void addTransition(Transition* aTrans);
   
   FGRunwayRef _runway;
+  ProcedureType _type;
   
   typedef std::map<WayptRef, Transition*> WptTransitionMap;
   WptTransitionMap _transitions;
@@ -129,20 +165,27 @@ private:
 class ArrivalDeparture : public Procedure
 {
 public:
+  virtual FGAirport* airport() const
+  { return _airport; }
+  
   /**
    * Predicate, test if this procedure applies to the requested runway
    */
-  virtual bool isForRunway(FGRunwayRef aWay) const;
+  virtual bool isForRunway(const FGRunway* aWay) const;
+
+  virtual RunwayVec runways() const;
 
   /**
    * Find a path between the runway and enroute structure. Waypoints 
    * corresponding to the appropriate transitions and segments will be created.
    */
-  virtual bool route(FGRunwayRef aWay, Waypt* aEnroute, WayptVec& aPath) = 0;
+  virtual bool route(FGRunwayRef aWay, Transition* trans, WayptVec& aPath) = 0;
 
   const WayptVec& common() const
     { return _common; }
 
+  string_list transitionIdents() const;
+  
   /**
    * Given an enroute location, find the best enroute transition point for 
    * this arrival/departure. Best is currently determined as 'closest to the
@@ -155,14 +198,14 @@ public:
    * for the route-manager and similar code that that needs to talk about
    * transitions in a human-meaningful way (including persistence).
    */
-  WayptRef findTransitionByName(const std::string& aIdent) const;
+  Transition* findTransitionByName(const std::string& aIdent) const;
   
   Transition* findTransitionByEnroute(Waypt* aEnroute) const;
 protected:
     
-  bool commonRoute(Waypt* aEnroute, WayptVec& aPath, FGRunwayRef aRwy);
+  bool commonRoute(Transition* t, WayptVec& aPath, FGRunwayRef aRwy);
   
-  ArrivalDeparture(const std::string& aIdent);
+  ArrivalDeparture(const std::string& aIdent, FGAirport* apt);
   
   
   void addRunway(FGRunwayRef aRwy);
@@ -170,6 +213,7 @@ protected:
   typedef std::map<FGRunwayRef, Transition*> RunwayTransitionMap;
   RunwayTransitionMap _runways;
   
+  virtual WayptFlag flagType() const = 0;
 private:
   friend class NavdataVisitor;
   
@@ -179,6 +223,7 @@ private:
 
   void addRunwayTransition(FGRunwayRef aRwy, Transition* aTrans);
   
+  FGAirport* _airport;
   WayptVec _common;
   
   typedef std::map<WayptRef, Transition*> WptTransitionMap;
@@ -190,23 +235,37 @@ private:
 class SID : public ArrivalDeparture
 {
 public:  
-  virtual bool route(FGRunwayRef aWay, Waypt* aEnroute, WayptVec& aPath);
+  virtual bool route(FGRunwayRef aWay, Transition* aTrans, WayptVec& aPath);
+  
+  virtual ProcedureType type() const
+  { return PROCEDURE_SID; }
+  
+protected:
+  virtual WayptFlag flagType() const
+  { return WPT_DEPARTURE; }
   
 private:
   friend class NavdataVisitor;
     
-  SID(const std::string& aIdent);
+  SID(const std::string& aIdent, FGAirport* apt);
 };
 
 class STAR : public ArrivalDeparture
 {
 public:  
-  virtual bool route(FGRunwayRef aWay, Waypt* aEnroute, WayptVec& aPath);
+  virtual bool route(FGRunwayRef aWay, Transition* aTrans, WayptVec& aPath);
+  
+  virtual ProcedureType type() const
+  { return PROCEDURE_STAR; }
+  
+protected:
+  virtual WayptFlag flagType() const
+  { return WPT_ARRIVAL; }
   
 private:
   friend class NavdataVisitor;
   
-  STAR(const std::string& aIdent);
+  STAR(const std::string& aIdent, FGAirport* apt);
 };
 
 } // of namespace