]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIFlightPlan.hxx
toggle fullscreen: also adapt GUI plane when resizing
[flightgear.git] / src / AIModel / AIFlightPlan.hxx
index e5e4bb10db4090f3b77f281d429954de4101ec4b..94476aa8dc49254747b4ddc9cca5abdd312a0ffb 100644 (file)
 #ifndef _FG_AIFLIGHTPLAN_HXX
 #define _FG_AIFLIGHTPLAN_HXX
 
-#include <simgear/compiler.h>
 #include <vector>
 #include <string>
 
+#include <simgear/compiler.h>
+#include <simgear/math/SGMath.hxx>
+#include <simgear/structure/SGSharedPtr.hxx>
+#include <Navaids/positioned.hxx>
+#include <Airports/dynamics.hxx>
 
+// forward decls
 class FGTaxiRoute;
 class FGRunway;
 class FGAIAircraft;
 class FGAirport;
-class SGGeod;
+
+typedef SGSharedPtr<FGAirport> FGAirportRef;
 
 class FGAIWaypoint {
 private:
    std::string name;
-   double latitude;
-   double longitude;
-   double altitude;
+   SGGeod pos;
    double speed;
    double crossat;
    bool finished;
@@ -51,9 +55,10 @@ public:
     FGAIWaypoint();
     ~FGAIWaypoint() {};
     void setName        (std::string nam) { name        = nam; };
-    void setLatitude    (double lat) { latitude    = lat; };
-    void setLongitude   (double lon) { longitude   = lon; };
-    void setAltitude    (double alt) { altitude    = alt; };
+    void setLatitude    (double lat);
+    void setLongitude   (double lon);
+    void setAltitude    (double alt);
+    void setPos         (const SGGeod& aPos) { pos = aPos; }
     void setSpeed       (double spd) { speed       = spd; };
     void setCrossat     (double val) { crossat     = val; };
     void setFinished    (bool   fin) { finished    = fin; };
@@ -68,9 +73,10 @@ public:
     bool contains(std::string name);
 
     std::string getName  () { return name;        };
-    double getLatitude   () { return latitude;    };
-    double getLongitude  () { return longitude;   };
-    double getAltitude   () { return altitude;    };
+    const SGGeod& getPos () { return pos;         };
+    double getLatitude   ();
+    double getLongitude  ();
+    double getAltitude   ();
     double getSpeed      () { return speed;       };
 
     double getCrossat    () { return crossat;     };
@@ -122,7 +128,8 @@ public:
    void setLeadDistance(double distance_ft);
    double getLeadDistance( void ) const {return lead_distance;}
    double getBearing(FGAIWaypoint* previous, FGAIWaypoint* next) const;
-   double getBearing(double lat, double lon, FGAIWaypoint* next) const;
+   double getBearing(const SGGeod& aPos, FGAIWaypoint* next) const;
+  
    double checkTrackLength(std::string wptName);
   time_t getStartTime() const { return start_time; }
    time_t getArrivalTime() const { return arrivalTime; }
@@ -134,8 +141,7 @@ public:
 
   void setLeg(int val) { leg = val;}
   void setTime(time_t st) { start_time = st; }
-  int getGate() const { return gateId; }
-  void setGate(int id) { gateId = id; };
+
 
   double getLeadInAngle() const { return leadInAngle; }
   const std::string& getRunway() const;
@@ -144,9 +150,9 @@ public:
   bool getRepeat(void) const { return repeat; }
   void restart(void);
   int getNrOfWayPoints() { return waypoints.size(); }
-  int getRouteIndex(int i); // returns the AI related index of this current routes. 
-  FGTaxiRoute *getTaxiRoute() { return taxiRoute; }
-  void deleteTaxiRoute();
+
+  int getRouteIndex(int i); // returns the AI related index of this current routes.
+
   std::string getRunway() { return activeRunway; }
   bool isActive(time_t time) {return time >= this->getStartTime();}
 
@@ -167,6 +173,8 @@ public:
   
   void shortenToFirst(unsigned int number, std::string name);
 
+  void setGate(ParkingAssignment pka);
+  FGParking* getParkingGate();
 private:
   FGAIFlightPlan *sid;
   typedef std::vector <FGAIWaypoint*> wpt_vector_type;
@@ -183,14 +191,15 @@ private:
   time_t start_time;
   time_t arrivalTime;       // For AI/ATC purposes.
   int leg;
-  int gateId, lastNodeVisited;
+  ParkingAssignment gate;
+  PositionedID lastNodeVisited;
   std::string activeRunway;
-  FGTaxiRoute *taxiRoute;
   std::string name;
   bool isValid;
-
+  FGAirportRef departure, arrival;
+  
   void createPushBackFallBack(FGAIAircraft *, bool, FGAirport*, double radius, const std::string&, const std::string&, const std::string&);
-  bool createClimb(FGAIAircraft *, bool, FGAirport *, double, double, const std::string&);
+  bool createClimb(FGAIAircraft *, bool, FGAirport *, FGAirport* arrival, double, double, const std::string&);
   bool createCruise(FGAIAircraft *, bool, FGAirport*, FGAirport*, double, double, double, double, const std::string&);
   bool createDescent(FGAIAircraft *, FGAirport *,  double latitude, double longitude, double speed, double alt,const std::string&, double distance);
   bool createLanding(FGAIAircraft *, FGAirport *, const std::string&);
@@ -215,6 +224,28 @@ private:
 
   //void createCruiseFallback(bool, FGAirport*, FGAirport*, double, double, double, double);
  void evaluateRoutePart(double deplat, double deplon, double arrlat, double arrlon);
+  
+  /**
+   * look for and parse an PropertyList flight-plan file - essentially
+   * a flat list waypoint objects, encoded to properties
+   */
+  bool parseProperties(const std::string& filename);
+  
+  void createWaypoints(FGAIAircraft *ac,
+                       double course,
+                       time_t start,
+                       FGAirport *dep,
+                       FGAirport *arr,
+                       bool firstLeg,
+                       double radius,
+                       double alt,
+                       double lat,
+                       double lon,
+                       double speed,
+                       const std::string& fltType,
+                       const std::string& acType,
+                       const std::string& airline);
+  
  public:
   wpt_vector_iterator getFirstWayPoint() { return waypoints.begin(); };
   wpt_vector_iterator getLastWayPoint()  { return waypoints.end(); };