]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIFlightPlan.hxx
Mathias Froehlich:
[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 <Airports/runways.hxx>
28
29 #include "AIBase.hxx"
30
31 SG_USING_STD(vector);
32 SG_USING_STD(string);
33
34
35 class FGAIFlightPlan {
36
37 public:
38
39   typedef struct {
40    string name;
41    double latitude;
42    double longitude;
43    double altitude;
44    double speed;
45    double crossat;
46    bool finished;
47    bool gear_down;
48    bool flaps_down;
49    bool on_ground;
50   } waypoint;
51
52    FGAIFlightPlan(const string& filename);
53   FGAIFlightPlan(const std::string& p,
54                  double course,
55                  time_t start,
56                  FGAirport *dep,
57                  FGAirport *arr,
58                  bool firstLeg,
59                  double radius,
60                  double alt,
61                  double lat,
62                  double lon,
63                  double speed,
64                  const string& fltType,
65                  const string& acType,
66                  const string& airline);
67    ~FGAIFlightPlan();
68
69    waypoint* const getPreviousWaypoint( void ) const;
70    waypoint* const getCurrentWaypoint( void ) const;
71    waypoint* const getNextWaypoint( void ) const;
72    void IncrementWaypoint( bool erase );
73
74    double getDistanceToGo(double lat, double lon, waypoint* wp) const;
75    int getLeg () const { return leg;};
76    void setLeadDistance(double speed, double bearing, waypoint* current, waypoint* next);
77    void setLeadDistance(double distance_ft);
78    double getLeadDistance( void ) const {return lead_distance;}
79    double getBearing(waypoint* previous, waypoint* next) const;
80    double getBearing(double lat, double lon, waypoint* next) const;
81   time_t getStartTime() const { return start_time; }; 
82
83   void    create(FGAirport *dep, FGAirport *arr, int leg, double alt, double speed, double lat, double lon,
84                  bool firstLeg, double radius, const string& fltType, const string& aircraftType, const string& airline);
85
86   void setLeg(int val) { leg = val;};
87   void setTime(time_t st) { start_time = st; };
88   int getGate() const { return gateId; };
89   double getLeadInAngle() const { return leadInAngle; };
90   const string& getRunway() const { return rwy._rwy_no; };
91   const string& getRunwayId() const { return rwy._id; };
92   void setRepeat(bool r) { repeat = r; };
93   bool getRepeat(void) const { return repeat; };
94   void restart(void);
95
96 private:
97   FGRunway rwy;
98   typedef vector <waypoint*> wpt_vector_type;
99   typedef wpt_vector_type::const_iterator wpt_vector_iterator;
100
101   wpt_vector_type       waypoints;
102   wpt_vector_iterator   wpt_iterator;
103
104   bool repeat;
105   double distance_to_go;
106   double lead_distance;
107   double leadInAngle;
108    time_t start_time;
109   int leg;
110   int gateId;
111   string activeRunway;
112
113   void createPushBack(bool, FGAirport*, double, double, double, const string&, const string&, const string&);
114   void createTaxi(bool, int, FGAirport *, double, double, double, const string&, const string&, const string&);
115   void createTakeOff(bool, FGAirport *, double);
116   void createClimb(bool, FGAirport *, double, double);
117   void createCruise(bool, FGAirport*, FGAirport*, double, double, double, double);
118   void createDecent(FGAirport *);
119   void createLanding(FGAirport *);
120   void createParking(FGAirport *);
121   void deleteWaypoints(); 
122   void resetWaypoints();
123 };    
124
125
126
127 #endif  // _FG_AIFLIGHTPLAN_HXX