1 // FGAIFlightPlan - class for loading and storing AI flight plans
2 // Written by David Culp, started May 2004
3 // - davidculp2@comcast.net
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.
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.
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.
19 #ifndef _FG_AIFLIGHTPLAN_HXX
20 #define _FG_AIFLIGHTPLAN_HXX
22 #include <simgear/compiler.h>
26 #include <Airports/simple.hxx>
27 #include <Airports/runways.hxx>
28 #include <Navaids/awynet.hxx>
36 class FGAIFlightPlan {
51 int routeIndex; // For AI/ATC purposes;
57 FGAIFlightPlan(const string& filename);
58 FGAIFlightPlan(const std::string& p,
69 const string& fltType,
71 const string& airline);
74 waypoint* const getPreviousWaypoint( void ) const;
75 waypoint* const getCurrentWaypoint( void ) const;
76 waypoint* const getNextWaypoint( void ) const;
77 void IncrementWaypoint( bool erase );
79 double getDistanceToGo(double lat, double lon, waypoint* wp) const;
80 int getLeg () const { return leg;};
81 void setLeadDistance(double speed, double bearing, waypoint* current, waypoint* next);
82 void setLeadDistance(double distance_ft);
83 double getLeadDistance( void ) const {return lead_distance;}
84 double getBearing(waypoint* previous, waypoint* next) const;
85 double getBearing(double lat, double lon, waypoint* next) const;
86 time_t getStartTime() const { return start_time; }
88 void create(FGAirport *dep, FGAirport *arr, int leg, double alt, double speed, double lat, double lon,
89 bool firstLeg, double radius, const string& fltType, const string& aircraftType, const string& airline);
91 void setLeg(int val) { leg = val;}
92 void setTime(time_t st) { start_time = st; }
93 int getGate() const { return gateId; }
94 double getLeadInAngle() const { return leadInAngle; }
95 const string& getRunway() const { return rwy._rwy_no; }
96 const string& getRunwayId() const { return rwy._id; }
97 void setRepeat(bool r) { repeat = r; }
98 bool getRepeat(void) const { return repeat; }
100 int getNrOfWayPoints() { return waypoints.size(); }
101 int getRouteIndex(int i); // returns the AI related index of this current routes.
102 FGTaxiRoute *getTaxiRoute() { return taxiRoute; }
103 void deleteTaxiRoute();
104 string getRunway() { return activeRunway; }
105 bool isActive(time_t time) {return time >= this->getStartTime();}
109 typedef vector <waypoint*> wpt_vector_type;
110 typedef wpt_vector_type::const_iterator wpt_vector_iterator;
112 wpt_vector_type waypoints;
113 wpt_vector_iterator wpt_iterator;
116 double distance_to_go;
117 double lead_distance;
121 int gateId, lastNodeVisited;
124 FGTaxiRoute *taxiRoute;
126 void createPushBack(bool, FGAirport*, double, double, double, const string&, const string&, const string&);
127 void createPushBackFallBack(bool, FGAirport*, double, double, double, const string&, const string&, const string&);
128 void createTaxi(bool, int, 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();
138 string getRunwayClassFromTrafficType(string fltType);
140 //void createCruiseFallback(bool, FGAirport*, FGAirport*, double, double, double, double);
141 void evaluateRoutePart(double deplat, double deplon, double arrlat, double arrlon);
144 #endif // _FG_AIFLIGHTPLAN_HXX