]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIFlightPlan.hxx
Merge branch 'maint' into next
[flightgear.git] / src / AIModel / AIFlightPlan.hxx
1 // FGAIFlightPlan - class for loading and storing  AI flight plans
2 // Written by David Culp, started May 2004
3 // - davidculp2@comcast.net
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 #ifndef _FG_AIFLIGHTPLAN_HXX
20 #define _FG_AIFLIGHTPLAN_HXX
21
22 #include <simgear/compiler.h>
23 #include <vector>
24 #include <string>
25
26 #include <Airports/simple.hxx>
27 #include <Navaids/awynet.hxx>
28
29 #include "AIBase.hxx"
30
31 using std::vector;
32 using std::string;
33
34 class FGTaxiRoute;
35 class FGRunway;
36
37 class FGAIFlightPlan {
38
39 public:
40
41   typedef struct {
42    string name;
43    double latitude;
44    double longitude;
45    double altitude;
46    double speed;
47    double crossat;
48    bool finished;
49    bool gear_down;
50    bool flaps_down;
51    bool on_ground;
52     int routeIndex;  // For AI/ATC purposes;
53    double time_sec;
54    string time;
55
56   } waypoint;
57
58   FGAIFlightPlan(const string& filename);
59   FGAIFlightPlan(const std::string& p,
60                  double course,
61                  time_t start,
62                  FGAirport *dep,
63                  FGAirport *arr,
64                  bool firstLeg,
65                  double radius,
66                  double alt,
67                  double lat,
68                  double lon,
69                  double speed,
70                  const string& fltType,
71                  const string& acType,
72                  const string& airline);
73    ~FGAIFlightPlan();
74
75    waypoint* const getPreviousWaypoint( void ) const;
76    waypoint* const getCurrentWaypoint( void ) const;
77    waypoint* const getNextWaypoint( void ) const;
78    void IncrementWaypoint( bool erase );
79
80    double getDistanceToGo(double lat, double lon, waypoint* wp) const;
81    int getLeg () const { return leg;};
82    void setLeadDistance(double speed, double bearing, waypoint* current, waypoint* next);
83    void setLeadDistance(double distance_ft);
84    double getLeadDistance( void ) const {return lead_distance;}
85    double getBearing(waypoint* previous, waypoint* next) const;
86    double getBearing(double lat, double lon, waypoint* next) const;
87   time_t getStartTime() const { return start_time; }
88
89   void    create(FGAirport *dep, FGAirport *arr, int leg, double alt, double speed, double lat, double lon,
90                  bool firstLeg, double radius, const string& fltType, const string& aircraftType, const string& airline);
91
92   void setLeg(int val) { leg = val;}
93   void setTime(time_t st) { start_time = st; }
94   int getGate() const { return gateId; }
95   double getLeadInAngle() const { return leadInAngle; }
96   const string& getRunway() const;
97   
98   void setRepeat(bool r) { repeat = r; }
99   bool getRepeat(void) const { return repeat; }
100   void restart(void);
101   int getNrOfWayPoints() { return waypoints.size(); }
102   int getRouteIndex(int i); // returns the AI related index of this current routes. 
103   FGTaxiRoute *getTaxiRoute() { return taxiRoute; }
104   void deleteTaxiRoute();
105   string getRunway() { return activeRunway; }
106   bool isActive(time_t time) {return time >= this->getStartTime();}
107
108 private:
109   FGRunway* rwy;
110   typedef vector <waypoint*> wpt_vector_type;
111   typedef wpt_vector_type::const_iterator wpt_vector_iterator;
112
113   wpt_vector_type       waypoints;
114   wpt_vector_iterator   wpt_iterator;
115
116   bool repeat;
117   double distance_to_go;
118   double lead_distance;
119   double leadInAngle;
120   time_t start_time;
121   int leg;
122   int gateId, lastNodeVisited;
123   string activeRunway;
124   FGAirRoute airRoute;
125   FGTaxiRoute *taxiRoute;
126
127   void createPushBack(bool, FGAirport*, double, double, double, const string&, const string&, const string&);
128   void createPushBackFallBack(bool, FGAirport*, double, double, double, const string&, const string&, const string&);
129   void createTakeOff(bool, FGAirport *, double, const string&);
130   void createClimb(bool, FGAirport *, double, double, const string&);
131   void createCruise(bool, FGAirport*, FGAirport*, double, double, double, double, const string&);
132   void createDecent(FGAirport *, const string&);
133   void createLanding(FGAirport *);
134   void createParking(FGAirport *, double radius);
135   void deleteWaypoints(); 
136   void resetWaypoints();
137
138   void createLandingTaxi(FGAirport *apt, double radius, const string& fltType, const string& acType, const string& airline);
139   void createDefaultLandingTaxi(FGAirport* aAirport);
140   void createDefaultTakeoffTaxi(FGAirport* aAirport, FGRunway* aRunway);
141   void createTakeoffTaxi(bool firstFlight, FGAirport *apt, double radius, const string& fltType, const string& acType, const string& airline);
142         
143   waypoint* createOnGround(const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed);
144   waypoint* createInAir(const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed);
145   waypoint* cloneWithPos(waypoint* aWpt, const std::string& aName, const SGGeod& aPos);
146     
147   string getRunwayClassFromTrafficType(string fltType);
148
149   //void createCruiseFallback(bool, FGAirport*, FGAirport*, double, double, double, double);
150  void evaluateRoutePart(double deplat, double deplon, double arrlat, double arrlon);
151 };    
152
153 #endif  // _FG_AIFLIGHTPLAN_HXX