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>
33 class FGAIFlightPlan {
48 int routeIndex; // For AI/ATC purposes;
50 double trackLength; // distance from previous waypoint (for AI purposes);
55 FGAIFlightPlan(const std::string& filename);
56 FGAIFlightPlan(FGAIAircraft *,
68 const std::string& fltType,
69 const std::string& acType,
70 const std::string& airline);
73 waypoint* const getPreviousWaypoint( void ) const;
74 waypoint* const getCurrentWaypoint( void ) const;
75 waypoint* const getNextWaypoint( void ) const;
76 void IncrementWaypoint( bool erase );
77 void DecrementWaypoint( 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 double checkTrackLength(std::string wptName);
87 time_t getStartTime() const { return start_time; }
88 time_t getArrivalTime() const { return arrivalTime; }
90 bool create(FGAIAircraft *, FGAirport *dep, FGAirport *arr, int leg, double alt, double speed, double lat, double lon,
91 bool firstLeg, double radius, const std::string& fltType, const std::string& aircraftType, const std::string& airline, double distance);
92 bool createPushBack(FGAIAircraft *, bool, FGAirport*, double, double, double, const std::string&, const std::string&, const std::string&);
93 bool createTakeOff(FGAIAircraft *, bool, FGAirport *, double, const std::string&);
95 void setLeg(int val) { leg = val;}
96 void setTime(time_t st) { start_time = st; }
97 int getGate() const { return gateId; }
98 void setGate(int id) { gateId = id; };
100 double getLeadInAngle() const { return leadInAngle; }
101 const std::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 std::string getRunway() { return activeRunway; }
111 bool isActive(time_t time) {return time >= this->getStartTime();}
113 void setRunway(std::string rwy) { activeRunway = rwy; };
114 std::string getRunwayClassFromTrafficType(std::string fltType);
116 void addWaypoint(waypoint* wpt) { waypoints.push_back(wpt); };
118 void setName(std::string n) { name = n; };
119 std::string getName() { return name; };
121 void setSID(FGAIFlightPlan* fp) { sid = fp;};
122 FGAIFlightPlan* getSID() { return sid; };
127 typedef std::vector <waypoint*> wpt_vector_type;
128 typedef wpt_vector_type::const_iterator wpt_vector_iterator;
131 wpt_vector_type waypoints;
132 wpt_vector_iterator wpt_iterator;
135 double distance_to_go;
136 double lead_distance;
139 time_t arrivalTime; // For AI/ATC purposes.
141 int gateId, lastNodeVisited;
142 std::string activeRunway;
143 FGTaxiRoute *taxiRoute;
147 void createPushBackFallBack(FGAIAircraft *, bool, FGAirport*, double, double, double, const std::string&, const std::string&, const std::string&);
148 bool createClimb(FGAIAircraft *, bool, FGAirport *, double, double, const std::string&);
149 bool createCruise(FGAIAircraft *, bool, FGAirport*, FGAirport*, double, double, double, double, const std::string&);
150 bool createDescent(FGAIAircraft *, FGAirport *, double latitude, double longitude, double speed, double alt,const std::string&, double distance);
151 bool createLanding(FGAIAircraft *, FGAirport *, const std::string&);
152 bool createParking(FGAIAircraft *, FGAirport *, double radius);
153 void deleteWaypoints();
154 void resetWaypoints();
156 bool createLandingTaxi(FGAIAircraft *, FGAirport *apt, double radius, const std::string& fltType, const std::string& acType, const std::string& airline);
157 void createDefaultLandingTaxi(FGAIAircraft *, FGAirport* aAirport);
158 void createDefaultTakeoffTaxi(FGAIAircraft *, FGAirport* aAirport, FGRunway* aRunway);
159 bool createTakeoffTaxi(FGAIAircraft *, bool firstFlight, FGAirport *apt, double radius, const std::string& fltType, const std::string& acType, const std::string& airline);
161 double getTurnRadius(double, bool);
163 waypoint* createOnGround(FGAIAircraft *, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed);
164 waypoint* createInAir(FGAIAircraft *, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed);
165 waypoint* cloneWithPos(FGAIAircraft *, waypoint* aWpt, const std::string& aName, const SGGeod& aPos);
166 waypoint* clone(waypoint* aWpt);
169 //void createCruiseFallback(bool, FGAirport*, FGAirport*, double, double, double, double);
170 void evaluateRoutePart(double deplat, double deplon, double arrlat, double arrlon);
172 wpt_vector_iterator getFirstWayPoint() { return waypoints.begin(); };
173 wpt_vector_iterator getLastWayPoint() { return waypoints.end(); };
174 bool isValidPlan() { return isValid; };
177 #endif // _FG_AIFLIGHTPLAN_HXX