]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIFlightPlan.hxx
bc4e21b90def720ee00cf1b6a7fd7e66a888866d
[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
28 #include "AIBase.hxx"
29
30 SG_USING_STD(vector);
31 SG_USING_STD(string);
32
33
34 class FGAIFlightPlan {
35
36 public:
37
38   typedef struct {
39    string name;
40    double latitude;
41    double longitude;
42    double altitude;
43    double speed;
44    double crossat;
45    bool finished;
46    bool gear_down;
47    bool flaps_down;
48    bool on_ground;
49   } waypoint;
50
51    FGAIFlightPlan(string filename);
52   FGAIFlightPlan(FGAIModelEntity *entity,
53                  double course,
54                  time_t start,
55                  FGAirport *dep,
56                  FGAirport *arr);
57    ~FGAIFlightPlan();
58
59    waypoint* getPreviousWaypoint( void );
60    waypoint* getCurrentWaypoint( void );
61    waypoint* getNextWaypoint( void );
62    void IncrementWaypoint( void );
63
64    double getDistanceToGo(double lat, double lon, waypoint* wp);
65    void setLeadDistance(double speed, double bearing, waypoint* current, waypoint* next);
66    void setLeadDistance(double distance_ft);
67    double getLeadDistance( void ) const {return lead_distance;}
68    double getBearing(waypoint* previous, waypoint* next);
69    double getBearing(double lat, double lon, waypoint* next);
70   time_t getStartTime() { return start_time; }; 
71
72   void    create(FGAirport *dep, FGAirport *arr, double alt, double speed);
73
74 private:
75
76     typedef vector <waypoint*> wpt_vector_type;
77     typedef wpt_vector_type::iterator wpt_vector_iterator;
78
79     wpt_vector_type       waypoints;
80     wpt_vector_iterator   wpt_iterator;
81
82     double distance_to_go;
83     double lead_distance;
84     time_t start_time;
85
86 };    
87
88
89
90 #endif  // _FG_AIFLIGHTPLAN_HXX
91