]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIFlightPlan.hxx
Leidson Campos A. Ferreira improved the jpeg http server
[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 #include <Navaids/awynet.hxx>
29
30 #include "AIBase.hxx"
31
32 SG_USING_STD(vector);
33 SG_USING_STD(string);
34
35
36 class FGAIFlightPlan {
37
38 public:
39
40   typedef struct {
41    string name;
42    double latitude;
43    double longitude;
44    double altitude;
45    double speed;
46    double crossat;
47    bool finished;
48    bool gear_down;
49    bool flaps_down;
50    bool on_ground;
51     int routeIndex;  // For AI/ATC purposes;
52   } waypoint;
53
54    FGAIFlightPlan(const string& filename);
55   FGAIFlightPlan(const std::string& p,
56                  double course,
57                  time_t start,
58                  FGAirport *dep,
59                  FGAirport *arr,
60                  bool firstLeg,
61                  double radius,
62                  double alt,
63                  double lat,
64                  double lon,
65                  double speed,
66                  const string& fltType,
67                  const string& acType,
68                  const string& airline);
69    ~FGAIFlightPlan();
70
71    waypoint* const getPreviousWaypoint( void ) const;
72    waypoint* const getCurrentWaypoint( void ) const;
73    waypoint* const getNextWaypoint( void ) const;
74    void IncrementWaypoint( bool erase );
75
76    double getDistanceToGo(double lat, double lon, waypoint* wp) const;
77    int getLeg () const { return leg;};
78    void setLeadDistance(double speed, double bearing, waypoint* current, waypoint* next);
79    void setLeadDistance(double distance_ft);
80    double getLeadDistance( void ) const {return lead_distance;}
81    double getBearing(waypoint* previous, waypoint* next) const;
82    double getBearing(double lat, double lon, waypoint* next) const;
83   time_t getStartTime() const { return start_time; }; 
84
85   void    create(FGAirport *dep, FGAirport *arr, int leg, double alt, double speed, double lat, double lon,
86                  bool firstLeg, double radius, const string& fltType, const string& aircraftType, const string& airline);
87
88   void setLeg(int val) { leg = val;};
89   void setTime(time_t st) { start_time = st; };
90   int getGate() const { return gateId; };
91   double getLeadInAngle() const { return leadInAngle; };
92   const string& getRunway() const { return rwy._rwy_no; };
93   const string& getRunwayId() const { return rwy._id; };
94   void setRepeat(bool r) { repeat = r; };
95   bool getRepeat(void) const { return repeat; };
96   void restart(void);
97   int getNrOfWayPoints() { return waypoints.size(); };
98   int getRouteIndex(int i); // returns the AI related index of this current routes. 
99   FGTaxiRoute *getTaxiRoute() { return taxiRoute; };
100   void deleteTaxiRoute();
101   string getRunway() { return activeRunway; };
102   
103
104 private:
105   FGRunway rwy;
106   typedef vector <waypoint*> wpt_vector_type;
107   typedef wpt_vector_type::const_iterator wpt_vector_iterator;
108
109   wpt_vector_type       waypoints;
110   wpt_vector_iterator   wpt_iterator;
111
112   bool repeat;
113   double distance_to_go;
114   double lead_distance;
115   double leadInAngle;
116    time_t start_time;
117   int leg;
118   int gateId;
119   string activeRunway;
120   FGAirRoute airRoute;
121   FGTaxiRoute *taxiRoute;
122
123
124   Point3D temp;
125   sgdVec3 a, b, cross;
126   sgdVec3 newPos;
127   sgdMat4 matrix;
128   double angle;
129   double midlat, midlon;
130   double course, distance;  
131
132   void createPushBack(bool, FGAirport*, double, double, double, const string&, const string&, const string&);
133   void createTaxi(bool, int, FGAirport *, double, double, double, const string&, const string&, const string&);
134   void createTakeOff(bool, FGAirport *, double);
135   void createClimb(bool, FGAirport *, double, double);
136   void createCruise(bool, FGAirport*, FGAirport*, double, double, double, double);
137   void createDecent(FGAirport *);
138   void createLanding(FGAirport *);
139   void createParking(FGAirport *, double radius);
140   void deleteWaypoints(); 
141   void resetWaypoints();
142
143   //void createCruiseFallback(bool, FGAirport*, FGAirport*, double, double, double, double);
144  void evaluateRoutePart(double deplat, double deplon, double arrlat, double arrlon);
145 };    
146
147
148
149 #endif  // _FG_AIFLIGHTPLAN_HXX