]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/positioned.hxx
Reduce severity of a failure to create a marker beacon due to an unknown runway from...
[flightgear.git] / src / Navaids / positioned.hxx
index 4a0bd4c204e73977f554b7e3dc056ad049a125e0..5f8d90e6ff8220505e96cb55f88b638b3da216d3 100644 (file)
 #ifndef FG_POSITIONED_HXX
 #define FG_POSITIONED_HXX
 
+#include <string>
 #include <vector>
 
 #include <simgear/structure/SGSharedPtr.hxx>
-#include <simgear/bucket/newbucket.hxx>
+#include <simgear/math/SGMath.hxx>
 
 class FGPositioned;
+class SGPropertyNode;
 
 typedef SGSharedPtr<FGPositioned> FGPositionedRef;
 
@@ -41,7 +43,9 @@ public:
     SEAPORT,
     RUNWAY,
     TAXIWAY,
+    PAVEMENT,
     PARK_STAND,
+    WAYPOINT,
     FIX,
     VOR,
     NDB,
@@ -54,10 +58,14 @@ public:
     DME,
     TACAN,
     OBSTACLE,
-    WAYPOINT, // user-defined waypoint
-    FREQ_GND,
-    FREQ_TWR,
+    FREQ_GROUND,
+    FREQ_TOWER,
     FREQ_ATIS,
+    FREQ_AWOS,
+    FREQ_APP_DEP,
+    FREQ_ENROUTE,
+    FREQ_CLEARANCE,
+    FREQ_UNICOM,
     LAST_TYPE
   } Type;
 
@@ -82,8 +90,11 @@ public:
   const SGGeod& geod() const
   { return mPosition; }
 
-  SGBucket bucket() const;
-  
+  /**
+   *  The cartesian position associated with this object
+   */
+  const SGVec3d& cart() const;
+
   double latitude() const
   { return mPosition.getLatitudeDeg(); }
   
@@ -108,6 +119,22 @@ public:
     virtual bool pass(FGPositioned* aPos) const
     { return true; }
     
+    virtual Type minType() const
+    { return INVALID; }
+    
+    virtual Type maxType() const
+    { return INVALID; }
+    
+    /**
+     * Test if this filter has a non-empty type range
+     */
+    bool hasTypeRange() const;
+    
+    /**
+     * Assuming hasTypeRange is true, test if a given type passes the range
+     */
+    bool passType(Type aTy) const;
+    
     bool operator()(FGPositioned* aPos) const
     { return pass(aPos); }
   };
@@ -115,13 +142,13 @@ public:
   class TypeFilter : public Filter
   {
   public:
-    TypeFilter(Type aTy) : mType(aTy) { ; }
-    virtual bool pass(FGPositioned* aPos) const
-    { return (mType == aPos->type()); }
+    TypeFilter(Type aTy);
+    virtual bool pass(FGPositioned* aPos) const;
+    void addType(Type aTy);
   private:
-    const Type mType;
+      std::vector<Type> types;
   };
-  
+    
   static List findWithinRange(const SGGeod& aPos, double aRangeNm, Filter* aFilter = NULL);
         
   static FGPositionedRef findClosestWithIdent(const std::string& aIdent, const SGGeod& aPos, Filter* aFilter = NULL);
@@ -137,12 +164,20 @@ public:
   static FGPositionedRef findNextWithPartialId(FGPositionedRef aCur, const std::string& aId, Filter* aFilter = NULL);
   
   /**
-   * Find all items with the specified ident, and return then sorted by
-   * distance from a position
-   *
+   * Find all items with the specified ident
    * @param aFilter - optional filter on items
    */
-  static List findAllWithIdentSortedByRange(const std::string& aIdent, const SGGeod& aPos, Filter* aFilter = NULL);
+  static List findAllWithIdent(const std::string& aIdent, Filter* aFilter = NULL, bool aExact = true);
+  
+  /**
+   * As above, but searches names instead of idents
+   */
+  static List findAllWithName(const std::string& aName, Filter* aFilter = NULL, bool aExact = true);
+  
+  /**
+   * Sort an FGPositionedList by distance from a position
+   */
+  static void sortByRange(List&, const SGGeod& aPos);
   
   /**
    * Find the closest item to a position, which pass the specified filter
@@ -160,27 +195,37 @@ public:
    * Very large cutoff values will make this slow.
    * 
    * @result The matches (possibly less than N, depending on the filter and cutoff),
-  *    sorted by distance from the search pos
+   *    sorted by distance from the search pos
    * @param aN - number of matches to find
    * @param aCutoffNm - maximum distance to search within, in nautical miles
    */
   static List findClosestN(const SGGeod& aPos, unsigned int aN, double aCutoffNm, Filter* aFilter = NULL);
   
-  
+  /**
+   * Map a candidate type string to a real type. Returns INVALID if the string
+   * does not correspond to a defined type.
+   */
+  static Type typeFromName(const std::string& aName);
   
   /**
-   * Debug helper, map a type to a human-readable string
+   * Map a type to a human-readable string
    */
   static const char* nameForType(Type aTy);
+  
+  static FGPositioned* createUserWaypoint(const std::string& aIdent, const SGGeod& aPos);
 protected:
-  FGPositioned(Type ty, const std::string& aIdent, double aLat, double aLon, double aElev);
   
   FGPositioned(Type ty, const std::string& aIdent, const SGGeod& aPos);
   
-  SGGeod mPosition; // can't be const right now
+  void init(bool aIndexed);
+  
+  // can't be const right now, navrecord at least needs to fix up the position
+  // after navaids are parsed
+  SGGeod mPosition; 
   
-  Type mType;
-  std::string mIdent;
+  SGVec3d mCart; // once mPosition is const, this can be const too
+  const Type mType;
+  const std::string mIdent;
 };
 
 #endif // of FG_POSITIONED_HXX