]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/positioned.hxx
Clean up/prepare for porting NasalPositioned to cppbind
[flightgear.git] / src / Navaids / positioned.hxx
index a9f2cd4bf8decd2c1badb65bba405096a870f033..8341c22f1c7968a97a9c5dc483fabb858c9d3b06 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef FG_POSITIONED_HXX
 #define FG_POSITIONED_HXX
 
+#include <cassert>
 #include <string>
 #include <vector>
 #include <stdint.h>
@@ -47,6 +48,7 @@ public:
     HELIPORT,
     SEAPORT,
     RUNWAY,
+    HELIPAD,
     TAXIWAY,
     PAVEMENT,
     WAYPOINT,
@@ -80,6 +82,12 @@ public:
 // groundnet items
     PARKING,  ///< parking position - might be a gate, or stand
     TAXI_NODE,
+// POI items
+    COUNTRY,
+    CITY,
+    TOWN,
+    VILLAGE,
+      
     LAST_TYPE
   } Type;
 
@@ -121,6 +129,9 @@ public:
   double elevation() const
   { return mPosition.getElevationFt(); }
   
+  double elevationM() const
+  { return mPosition.getElevationM(); }
+
   /**
    * Predicate class to support custom filtering of FGPositioned queries
    * Default implementation of this passes any FGPositioned instance.
@@ -164,8 +175,10 @@ public:
     std::vector<Type> types;
     Type mMinType, mMaxType;
   };
-    
+  
   static List findWithinRange(const SGGeod& aPos, double aRangeNm, Filter* aFilter = NULL);
+  
+  static List findWithinRangePartial(const SGGeod& aPos, double aRangeNm, Filter* aFilter, bool& aPartial);
         
   static FGPositionedRef findClosestWithIdent(const std::string& aIdent, const SGGeod& aPos, Filter* aFilter = NULL);
 
@@ -208,7 +221,13 @@ public:
    * @param aCutoffNm - maximum distance to search within, in nautical miles
    */
   static List findClosestN(const SGGeod& aPos, unsigned int aN, double aCutoffNm, Filter* aFilter = NULL);
-  
+    
+  /**
+   * Same as above, but with a time-bound in msec too.
+   */
+  static List findClosestNPartial(const SGGeod& aPos, unsigned int aN, double aCutoffNm, Filter* aFilter,
+                           bool& aPartial);
+    
   /**
    * Map a candidate type string to a real type. Returns INVALID if the string
    * does not correspond to a defined type.
@@ -221,15 +240,42 @@ public:
   static const char* nameForType(Type aTy);
   
   static FGPositioned* createUserWaypoint(const std::string& aIdent, const SGGeod& aPos);
+  static void deleteUserWaypoint(const std::string& aIdent);
 protected:
   friend class flightgear::NavDataCache;
   
   FGPositioned(PositionedID aGuid, Type ty, const std::string& aIdent, const SGGeod& aPos);
     
   void modifyPosition(const SGGeod& newPos);
-  
+
+  static FGPositioned* loadByIdImpl(PositionedID id);
+
+  template<class T>
+  static T* loadById(PositionedID id)
+  {
+    return static_cast<T*>( loadByIdImpl(id) );
+  }
+
+  template<class T>
+  static T* loadById(const PositionedIDVec& id_vec, size_t index)
+  {
+    assert(index >= 0 && index < id_vec.size());
+    return loadById<T>(id_vec[index]);
+  }
+
+  template<class T>
+  static std::vector<T*> loadAllById(const PositionedIDVec& id_vec)
+  {
+    std::vector<T*> vec(id_vec.size());
+
+    for(size_t i = 0; i < id_vec.size(); ++i)
+      vec[i] = loadById<T>(id_vec[i]);
+
+    return vec;
+  }
+
   const PositionedID mGuid;
-  SGGeod mPosition;
+  const SGGeod mPosition;
   const SGVec3d mCart;
   const Type mType;
   const std::string mIdent;