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>
27 #include <Airports/simple.hxx>
28 #include <Navaids/awynet.hxx>
41 class FGAIFlightPlan {
56 int routeIndex; // For AI/ATC purposes;
62 FGAIFlightPlan(const string& filename);
63 FGAIFlightPlan(FGAIAircraft *,
75 const string& fltType,
77 const string& airline);
80 waypoint* const getPreviousWaypoint( void ) const;
81 waypoint* const getCurrentWaypoint( void ) const;
82 waypoint* const getNextWaypoint( void ) const;
83 void IncrementWaypoint( bool erase );
85 double getDistanceToGo(double lat, double lon, waypoint* wp) const;
86 int getLeg () const { return leg;};
87 void setLeadDistance(double speed, double bearing, waypoint* current, waypoint* next);
88 void setLeadDistance(double distance_ft);
89 double getLeadDistance( void ) const {return lead_distance;}
90 double getBearing(waypoint* previous, waypoint* next) const;
91 double getBearing(double lat, double lon, waypoint* next) const;
92 time_t getStartTime() const { return start_time; }
94 void create(FGAIAircraft *, FGAirport *dep, FGAirport *arr, int leg, double alt, double speed, double lat, double lon,
95 bool firstLeg, double radius, const string& fltType, const string& aircraftType, const string& airline);
97 void setLeg(int val) { leg = val;}
98 void setTime(time_t st) { start_time = st; }
99 int getGate() const { return gateId; }
100 double getLeadInAngle() const { return leadInAngle; }
101 const string& getRunway() const;
103 void setRepeat(bool r) { repeat = r; }
104 bool getRepeat(void) const { return repeat; }
106 int getNrOfWayPoints() { return waypoints.size(); }
107 int getRouteIndex(int i); // returns the AI related index of this current routes.
108 FGTaxiRoute *getTaxiRoute() { return taxiRoute; }
109 void deleteTaxiRoute();
110 string getRunway() { return activeRunway; }
111 bool isActive(time_t time) {return time >= this->getStartTime();}
113 void setRunway(string rwy) { activeRunway = rwy; };
114 string getRunwayClassFromTrafficType(string fltType);
116 void addWaypoint(waypoint* wpt) { waypoints.push_back(wpt); };
118 void setName(string n) { name = n; };
119 string getName() { return name; };
121 void setSID(FGAIFlightPlan* fp) { sid = fp;};
122 FGAIFlightPlan* getSID() { return sid; };
127 typedef vector <waypoint*> wpt_vector_type;
128 typedef wpt_vector_type::const_iterator wpt_vector_iterator;
130 wpt_vector_type waypoints;
131 wpt_vector_iterator wpt_iterator;
134 double distance_to_go;
135 double lead_distance;
139 int gateId, lastNodeVisited;
142 FGTaxiRoute *taxiRoute;
145 void createPushBack(FGAIAircraft *, bool, FGAirport*, double, double, double, const string&, const string&, const string&);
146 void createPushBackFallBack(FGAIAircraft *, bool, FGAirport*, double, double, double, const string&, const string&, const string&);
147 void createTakeOff(FGAIAircraft *, bool, FGAirport *, double, const string&);
148 void createClimb(FGAIAircraft *, bool, FGAirport *, double, double, const string&);
149 void createCruise(FGAIAircraft *, bool, FGAirport*, FGAirport*, double, double, double, double, const string&);
150 void createDecent(FGAIAircraft *, FGAirport *, const string&);
151 void createLanding(FGAIAircraft *, FGAirport *);
152 void createParking(FGAIAircraft *, FGAirport *, double radius);
153 void deleteWaypoints();
154 void resetWaypoints();
156 void createLandingTaxi(FGAIAircraft *, FGAirport *apt, double radius, const string& fltType, const string& acType, const string& airline);
157 void createDefaultLandingTaxi(FGAIAircraft *, FGAirport* aAirport);
158 void createDefaultTakeoffTaxi(FGAIAircraft *, FGAirport* aAirport, FGRunway* aRunway);
159 void createTakeoffTaxi(FGAIAircraft *, bool firstFlight, FGAirport *apt, double radius, const string& fltType, const string& acType, const string& airline);
161 waypoint* createOnGround(FGAIAircraft *, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed);
162 waypoint* createInAir(FGAIAircraft *, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed);
163 waypoint* cloneWithPos(FGAIAircraft *, waypoint* aWpt, const std::string& aName, const SGGeod& aPos);
164 waypoint* clone(waypoint* aWpt);
167 //void createCruiseFallback(bool, FGAirport*, FGAirport*, double, double, double, double);
168 void evaluateRoutePart(double deplat, double deplon, double arrlat, double arrlon);
170 wpt_vector_iterator getFirstWayPoint() { return waypoints.begin(); };
171 wpt_vector_iterator getLastWayPoint() { return waypoints.end(); };
175 #endif // _FG_AIFLIGHTPLAN_HXX