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 void 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);
93 void setLeg(int val) { leg = val;}
94 void setTime(time_t st) { start_time = st; }
95 int getGate() const { return gateId; }
96 double getLeadInAngle() const { return leadInAngle; }
97 const std::string& getRunway() const;
99 void setRepeat(bool r) { repeat = r; }
100 bool getRepeat(void) const { return repeat; }
102 int getNrOfWayPoints() { return waypoints.size(); }
103 int getRouteIndex(int i); // returns the AI related index of this current routes.
104 FGTaxiRoute *getTaxiRoute() { return taxiRoute; }
105 void deleteTaxiRoute();
106 std::string getRunway() { return activeRunway; }
107 bool isActive(time_t time) {return time >= this->getStartTime();}
109 void setRunway(std::string rwy) { activeRunway = rwy; };
110 std::string getRunwayClassFromTrafficType(std::string fltType);
112 void addWaypoint(waypoint* wpt) { waypoints.push_back(wpt); };
114 void setName(std::string n) { name = n; };
115 std::string getName() { return name; };
117 void setSID(FGAIFlightPlan* fp) { sid = fp;};
118 FGAIFlightPlan* getSID() { return sid; };
123 typedef std::vector <waypoint*> wpt_vector_type;
124 typedef wpt_vector_type::const_iterator wpt_vector_iterator;
127 wpt_vector_type waypoints;
128 wpt_vector_iterator wpt_iterator;
131 double distance_to_go;
132 double lead_distance;
135 time_t arrivalTime; // For AI/ATC purposes.
137 int gateId, lastNodeVisited;
138 std::string activeRunway;
139 FGTaxiRoute *taxiRoute;
142 void createPushBack(FGAIAircraft *, bool, FGAirport*, double, double, double, const std::string&, const std::string&, const std::string&);
143 void createPushBackFallBack(FGAIAircraft *, bool, FGAirport*, double, double, double, const std::string&, const std::string&, const std::string&);
144 void createTakeOff(FGAIAircraft *, bool, FGAirport *, double, const std::string&);
145 void createClimb(FGAIAircraft *, bool, FGAirport *, double, double, const std::string&);
146 void createCruise(FGAIAircraft *, bool, FGAirport*, FGAirport*, double, double, double, double, const std::string&);
147 void createDescent(FGAIAircraft *, FGAirport *, double latitude, double longitude, double speed, double alt,const std::string&, double distance);
148 void createLanding(FGAIAircraft *, FGAirport *, const std::string&);
149 void createParking(FGAIAircraft *, FGAirport *, double radius);
150 void deleteWaypoints();
151 void resetWaypoints();
153 void createLandingTaxi(FGAIAircraft *, FGAirport *apt, double radius, const std::string& fltType, const std::string& acType, const std::string& airline);
154 void createDefaultLandingTaxi(FGAIAircraft *, FGAirport* aAirport);
155 void createDefaultTakeoffTaxi(FGAIAircraft *, FGAirport* aAirport, FGRunway* aRunway);
156 void createTakeoffTaxi(FGAIAircraft *, bool firstFlight, FGAirport *apt, double radius, const std::string& fltType, const std::string& acType, const std::string& airline);
158 double getTurnRadius(double, bool);
160 waypoint* createOnGround(FGAIAircraft *, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed);
161 waypoint* createInAir(FGAIAircraft *, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed);
162 waypoint* cloneWithPos(FGAIAircraft *, waypoint* aWpt, const std::string& aName, const SGGeod& aPos);
163 waypoint* clone(waypoint* aWpt);
166 //void createCruiseFallback(bool, FGAirport*, FGAirport*, double, double, double, double);
167 void evaluateRoutePart(double deplat, double deplon, double arrlat, double arrlon);
169 wpt_vector_iterator getFirstWayPoint() { return waypoints.begin(); };
170 wpt_vector_iterator getLastWayPoint() { return waypoints.end(); };
174 #endif // _FG_AIFLIGHTPLAN_HXX