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;
58 double trackLength; // distance from previous waypoint (for AI purposes);
63 FGAIFlightPlan(const string& filename);
64 FGAIFlightPlan(FGAIAircraft *,
76 const string& fltType,
78 const string& airline);
81 waypoint* const getPreviousWaypoint( void ) const;
82 waypoint* const getCurrentWaypoint( void ) const;
83 waypoint* const getNextWaypoint( void ) const;
84 void IncrementWaypoint( bool erase );
85 void DecrementWaypoint( bool erase );
87 double getDistanceToGo(double lat, double lon, waypoint* wp) const;
88 int getLeg () const { return leg;};
89 void setLeadDistance(double speed, double bearing, waypoint* current, waypoint* next);
90 void setLeadDistance(double distance_ft);
91 double getLeadDistance( void ) const {return lead_distance;}
92 double getBearing(waypoint* previous, waypoint* next) const;
93 double getBearing(double lat, double lon, waypoint* next) const;
94 double checkTrackLength(string wptName);
95 time_t getStartTime() const { return start_time; }
96 time_t getArrivalTime() const { return arrivalTime; }
98 void create(FGAIAircraft *, FGAirport *dep, FGAirport *arr, int leg, double alt, double speed, double lat, double lon,
99 bool firstLeg, double radius, const string& fltType, const string& aircraftType, const string& airline, double distance);
101 void setLeg(int val) { leg = val;}
102 void setTime(time_t st) { start_time = st; }
103 int getGate() const { return gateId; }
104 double getLeadInAngle() const { return leadInAngle; }
105 const string& getRunway() const;
107 void setRepeat(bool r) { repeat = r; }
108 bool getRepeat(void) const { return repeat; }
110 int getNrOfWayPoints() { return waypoints.size(); }
111 int getRouteIndex(int i); // returns the AI related index of this current routes.
112 FGTaxiRoute *getTaxiRoute() { return taxiRoute; }
113 void deleteTaxiRoute();
114 string getRunway() { return activeRunway; }
115 bool isActive(time_t time) {return time >= this->getStartTime();}
117 void setRunway(string rwy) { activeRunway = rwy; };
118 string getRunwayClassFromTrafficType(string fltType);
120 void addWaypoint(waypoint* wpt) { waypoints.push_back(wpt); };
122 void setName(string n) { name = n; };
123 string getName() { return name; };
125 void setSID(FGAIFlightPlan* fp) { sid = fp;};
126 FGAIFlightPlan* getSID() { return sid; };
131 typedef vector <waypoint*> wpt_vector_type;
132 typedef wpt_vector_type::const_iterator wpt_vector_iterator;
135 wpt_vector_type waypoints;
136 wpt_vector_iterator wpt_iterator;
139 double distance_to_go;
140 double lead_distance;
143 time_t arrivalTime; // For AI/ATC purposes.
145 int gateId, lastNodeVisited;
148 FGTaxiRoute *taxiRoute;
151 void createPushBack(FGAIAircraft *, bool, FGAirport*, double, double, double, const string&, const string&, const string&);
152 void createPushBackFallBack(FGAIAircraft *, bool, FGAirport*, double, double, double, const string&, const string&, const string&);
153 void createTakeOff(FGAIAircraft *, bool, FGAirport *, double, const string&);
154 void createClimb(FGAIAircraft *, bool, FGAirport *, double, double, const string&);
155 void createCruise(FGAIAircraft *, bool, FGAirport*, FGAirport*, double, double, double, double, const string&);
156 void createDescent(FGAIAircraft *, FGAirport *, double latitude, double longitude, double speed, double alt,const string&, double distance);
157 void createLanding(FGAIAircraft *, FGAirport *, const string&);
158 void createParking(FGAIAircraft *, FGAirport *, double radius);
159 void deleteWaypoints();
160 void resetWaypoints();
162 void createLandingTaxi(FGAIAircraft *, FGAirport *apt, double radius, const string& fltType, const string& acType, const string& airline);
163 void createDefaultLandingTaxi(FGAIAircraft *, FGAirport* aAirport);
164 void createDefaultTakeoffTaxi(FGAIAircraft *, FGAirport* aAirport, FGRunway* aRunway);
165 void createTakeoffTaxi(FGAIAircraft *, bool firstFlight, FGAirport *apt, double radius, const string& fltType, const string& acType, const string& airline);
167 double getTurnRadius(double, bool);
169 waypoint* createOnGround(FGAIAircraft *, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed);
170 waypoint* createInAir(FGAIAircraft *, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed);
171 waypoint* cloneWithPos(FGAIAircraft *, waypoint* aWpt, const std::string& aName, const SGGeod& aPos);
172 waypoint* clone(waypoint* aWpt);
175 //void createCruiseFallback(bool, FGAirport*, FGAirport*, double, double, double, double);
176 void evaluateRoutePart(double deplat, double deplon, double arrlat, double arrlon);
178 wpt_vector_iterator getFirstWayPoint() { return waypoints.begin(); };
179 wpt_vector_iterator getLastWayPoint() { return waypoints.end(); };
183 #endif // _FG_AIFLIGHTPLAN_HXX