]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIFlightPlanCreate.cxx
Remove stray debug statement.
[flightgear.git] / src / AIModel / AIFlightPlanCreate.cxx
1 /******************************************************************************
2  * AIFlightPlanCreate.cxx
3  * Written by Durk Talsma, started May, 2004.
4  *
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.
9  *
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.
14  *
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  *
19  **************************************************************************/
20
21 #ifdef HAVE_CONFIG_H
22 #  include <config.h>
23 #endif
24
25 #include "AIFlightPlan.hxx"
26 #include <simgear/math/sg_geodesy.hxx>
27 #include <simgear/props/props.hxx>
28 #include <simgear/props/props_io.hxx>
29
30 #include <Airports/runways.hxx>
31 #include <Airports/dynamics.hxx>
32 #include "AIAircraft.hxx"
33 #include "performancedata.hxx"
34
35 #include <Environment/environment_mgr.hxx>
36 #include <Environment/environment.hxx>
37
38
39 /* FGAIFlightPlan::create()
40  * dynamically create a flight plan for AI traffic, based on data provided by the
41  * Traffic Manager, when reading a filed flightplan failes. (DT, 2004/07/10) 
42  *
43  * This is the top-level function, and the only one that is publicly available.
44  *
45  */ 
46
47
48 // Check lat/lon values during initialization;
49 void FGAIFlightPlan::create(FGAIAircraft *ac, FGAirport *dep, FGAirport *arr, int legNr, 
50                             double alt, double speed, double latitude, 
51                             double longitude, bool firstFlight,double radius, 
52                             const string& fltType, const string& aircraftType, 
53                             const string& airline)
54
55   int currWpt = wpt_iterator - waypoints.begin();
56   switch(legNr)
57     {
58       case 1:
59       createPushBack(ac, firstFlight,dep, latitude, longitude, 
60                      radius, fltType, aircraftType, airline);
61       break;
62     case 2: 
63       createTakeoffTaxi(ac, firstFlight, dep, radius, fltType, aircraftType, airline);
64       break;
65     case 3: 
66       createTakeOff(ac, firstFlight, dep, speed, fltType);
67       break;
68     case 4: 
69       createClimb(ac, firstFlight, dep, speed, alt, fltType);
70       break;
71     case 5: 
72       createCruise(ac, firstFlight, dep,arr, latitude, longitude, speed, alt, fltType);
73       break;
74     case 6: 
75       createDecent(ac, arr, fltType);
76       break;
77     case 7: 
78       createLanding(ac, arr);
79       break;
80     case 8: 
81       createLandingTaxi(ac, arr, radius, fltType, aircraftType, airline);
82       break;
83       case 9: 
84         createParking(ac, arr, radius);
85       break;
86     default:
87       //exit(1);
88       SG_LOG(SG_INPUT, SG_ALERT, "AIFlightPlan::create() attempting to create unknown leg"
89              " this is probably an internal program error");
90     }
91   wpt_iterator = waypoints.begin()+currWpt;
92   leg++;
93 }
94
95 FGAIFlightPlan::waypoint*
96 FGAIFlightPlan::createOnGround(FGAIAircraft *ac, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed)
97 {
98   waypoint* wpt = new waypoint;
99   wpt->name = aName;
100   wpt->longitude = aPos.getLongitudeDeg();
101   wpt->latitude = aPos.getLatitudeDeg();
102   wpt->altitude  = aElev;
103   wpt->speed     = aSpeed; 
104   wpt->crossat   = -10000;
105   wpt->gear_down = true;
106   wpt->flaps_down= true;
107   wpt->finished  = false;
108   wpt->on_ground = true;
109   wpt->routeIndex= 0;
110   return wpt;
111 }
112
113 FGAIFlightPlan::waypoint*
114 FGAIFlightPlan::createInAir(FGAIAircraft *ac, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed)
115 {
116   waypoint* wpt = new waypoint;
117   wpt->name = aName;
118   wpt->longitude = aPos.getLongitudeDeg();
119   wpt->latitude = aPos.getLatitudeDeg();
120   wpt->altitude  = aElev;
121   wpt->speed     = aSpeed; 
122   wpt->crossat   = -10000;
123   wpt->gear_down = false;
124   wpt->flaps_down= false;
125   wpt->finished  = false;
126   wpt->on_ground = false;
127   wpt->routeIndex= 0;
128   return wpt;
129 }
130
131 FGAIFlightPlan::waypoint*
132 FGAIFlightPlan::cloneWithPos(FGAIAircraft *ac, waypoint* aWpt, const std::string& aName, const SGGeod& aPos)
133 {
134   waypoint* wpt = new waypoint;
135   wpt->name = aName;
136   wpt->longitude = aPos.getLongitudeDeg();
137   wpt->latitude = aPos.getLatitudeDeg();
138   
139   wpt->altitude  = aWpt->altitude;
140   wpt->speed     = aWpt->speed; 
141   wpt->crossat   = aWpt->crossat;
142   wpt->gear_down = aWpt->gear_down;
143   wpt->flaps_down= aWpt->flaps_down;
144   wpt->finished  = aWpt->finished;
145   wpt->on_ground = aWpt->on_ground;
146   wpt->routeIndex = 0;
147   
148   return wpt;
149 }
150
151 void FGAIFlightPlan::createDefaultTakeoffTaxi(FGAIAircraft *ac, FGAirport* aAirport, FGRunway* aRunway)
152 {
153   SGGeod runwayTakeoff = aRunway->pointOnCenterline(5.0);
154   double airportElev = aAirport->getElevation();
155   
156   waypoint* wpt;
157   wpt = createOnGround(ac, "Airport Center", aAirport->geod(), airportElev, 15);
158   waypoints.push_back(wpt);
159   wpt = createOnGround(ac, "Runway Takeoff", runwayTakeoff, airportElev, 15);
160   waypoints.push_back(wpt);     
161 }
162
163 void FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft *ac, bool firstFlight, 
164                                 FGAirport *apt,
165                                 double radius, const string& fltType, 
166                                 const string& acType, const string& airline)
167 {
168   double heading, lat, lon;
169   
170   // If this function is called during initialization,
171   // make sure we obtain a valid gate ID first
172   // and place the model at the location of the gate.
173   if (firstFlight) {
174     if (!(apt->getDynamics()->getAvailableParking(&lat, &lon, 
175               &heading, &gateId, 
176               radius, fltType, 
177               acType, airline)))
178     {
179       SG_LOG(SG_INPUT, SG_WARN, "Could not find parking for a " << 
180        acType <<
181        " of flight type " << fltType <<
182        " of airline     " << airline <<
183        " at airport     " << apt->getId());
184     }
185   }
186   
187   string rwyClass = getRunwayClassFromTrafficType(fltType);
188
189   // Only set this if it hasn't been set by ATC already.
190   if (activeRunway.empty()) {
191       //cerr << "Getting runway for " << ac->getTrafficRef()->getCallSign() << " at " << apt->getId() << endl;
192       double depHeading = ac->getTrafficRef()->getCourse();
193       apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway, depHeading);
194   }
195   rwy = apt->getRunwayByIdent(activeRunway);
196   SGGeod runwayTakeoff = rwy->pointOnCenterline(5.0);
197
198   FGGroundNetwork* gn = apt->getDynamics()->getGroundNetwork();
199   if (!gn->exists()) {
200     createDefaultTakeoffTaxi(ac, apt, rwy);
201     return;
202   }
203   
204   intVec ids;
205   int runwayId = gn->findNearestNode(runwayTakeoff);
206
207   // A negative gateId indicates an overflow parking, use a
208   // fallback mechanism for this. 
209   // Starting from gate 0 in this case is a bit of a hack
210   // which requires a more proper solution later on.
211   delete taxiRoute;
212   taxiRoute = new FGTaxiRoute;
213
214   // Determine which node to start from.
215   int node = 0;
216   // Find out which node to start from
217   FGParking *park = apt->getDynamics()->getParking(gateId);
218   if (park) {
219     node = park->getPushBackPoint();
220   }
221   
222   if (node == -1) {
223     node = gateId;
224   }
225   
226   // HAndle case where parking doens't have a node
227   if ((node == 0) && park) {
228     if (firstFlight) {
229       node = gateId;
230     } else {
231       node = lastNodeVisited;
232     }
233   }
234
235   *taxiRoute = gn->findShortestRoute(node, runwayId);
236   intVecIterator i;
237          
238   if (taxiRoute->empty()) {
239     createDefaultTakeoffTaxi(ac, apt, rwy);
240     return;
241   }
242   
243   taxiRoute->first();
244   //bool isPushBackPoint = false;
245   if (firstFlight) {
246     // If this is called during initialization, randomly
247     // skip a number of waypoints to get a more realistic
248     // taxi situation.
249     int nrWaypointsToSkip = rand() % taxiRoute->size();
250     // but make sure we always keep two active waypoints
251     // to prevent a segmentation fault
252     for (int i = 0; i < nrWaypointsToSkip-2; i++) {
253       taxiRoute->next(&node);
254     }
255     apt->getDynamics()->releaseParking(gateId);
256   } else {
257     if (taxiRoute->size() > 1) {
258       taxiRoute->next(&node); // chop off the first waypoint, because that is already the last of the pushback route
259     }
260   }
261   
262   // push each node on the taxi route as a waypoint
263   int route;
264   while(taxiRoute->next(&node, &route)) {
265                 char buffer[10];
266                 snprintf (buffer, 10, "%d", node);
267                 FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findNode(node);
268     waypoint* wpt = createOnGround(ac, buffer, tn->geod(), apt->getElevation(), 15);
269     wpt->routeIndex = route;
270                 waypoints.push_back(wpt);
271   }
272 }
273
274 void FGAIFlightPlan::createDefaultLandingTaxi(FGAIAircraft *ac, FGAirport* aAirport)
275 {
276   SGGeod lastWptPos = 
277     SGGeod::fromDeg(waypoints.back()->longitude, waypoints.back()->latitude);
278   double airportElev = aAirport->getElevation();
279   
280   waypoint* wpt;
281   wpt = createOnGround(ac, "Runway Exit", lastWptPos, airportElev, 15);
282   waypoints.push_back(wpt);     
283   wpt = createOnGround(ac, "Airport Center", aAirport->geod(), airportElev, 15);
284   waypoints.push_back(wpt);
285   
286   double heading, lat, lon;
287   aAirport->getDynamics()->getParking(gateId, &lat, &lon, &heading);
288   wpt = createOnGround(ac, "END", SGGeod::fromDeg(lon, lat), airportElev, 15);
289   waypoints.push_back(wpt);
290 }
291
292 void FGAIFlightPlan::createLandingTaxi(FGAIAircraft *ac, FGAirport *apt,
293                                 double radius, const string& fltType, 
294                                 const string& acType, const string& airline)
295 {
296   double heading, lat, lon;
297   apt->getDynamics()->getAvailableParking(&lat, &lon, &heading, 
298         &gateId, radius, fltType, acType, airline);
299   
300   SGGeod lastWptPos = 
301     SGGeod::fromDeg(waypoints.back()->longitude, waypoints.back()->latitude);
302   FGGroundNetwork* gn = apt->getDynamics()->getGroundNetwork();
303   
304    // Find a route from runway end to parking/gate.
305   if (!gn->exists()) {
306     createDefaultLandingTaxi(ac, apt);
307     return;
308   }
309   
310         intVec ids;
311   int runwayId = gn->findNearestNode(lastWptPos);
312   // A negative gateId indicates an overflow parking, use a
313   // fallback mechanism for this. 
314   // Starting from gate 0 is a bit of a hack...
315   //FGTaxiRoute route;
316   delete taxiRoute;
317   taxiRoute = new FGTaxiRoute;
318   if (gateId >= 0)
319     *taxiRoute = gn->findShortestRoute(runwayId, gateId);
320   else
321     *taxiRoute = gn->findShortestRoute(runwayId, 0);
322   intVecIterator i;
323   
324   if (taxiRoute->empty()) {
325     createDefaultLandingTaxi(ac, apt);
326     return;
327   }
328   
329   int node;
330   taxiRoute->first();
331   int size = taxiRoute->size();
332   // Omit the last two waypoints, as 
333   // those are created by createParking()
334   int route;
335   for (int i = 0; i < size-2; i++) {
336     taxiRoute->next(&node, &route);
337     char buffer[10];
338     snprintf (buffer, 10, "%d", node);
339     FGTaxiNode *tn = gn->findNode(node);
340     waypoint* wpt = createOnGround(ac, buffer, tn->geod(), apt->getElevation(), 15);
341     wpt->routeIndex = route;
342     waypoints.push_back(wpt);
343   }
344 }
345
346 /*******************************************************************
347  * CreateTakeOff 
348  * initialize the Aircraft at the parking location
349  ******************************************************************/
350 void FGAIFlightPlan::createTakeOff(FGAIAircraft *ac, bool firstFlight, FGAirport *apt, double speed, const string &fltType)
351 {
352     double accel   = ac->getPerformance()->acceleration();
353     double vRotate = ac->getPerformance()->vRotate();
354     // Acceleration = dV / dT
355     // Acceleration X dT = dV
356     // dT = dT / Acceleration
357     //d = (Vf^2 - Vo^2) / (2*a)
358     double accelTime = (vRotate - 15) / accel;
359     //cerr << "Using " << accelTime << " as total acceleration time" << endl;
360     double accelDistance = (vRotate*vRotate - 15*15) / (2*accel);
361     //cerr << "Using " << accelDistance << " " << accel << " " << vRotate << endl;
362     waypoint *wpt;
363     // Get the current active runway, based on code from David Luff
364     // This should actually be unified and extended to include 
365     // Preferential runway use schema's 
366     // NOTE: DT (2009-01-18: IIRC, this is currently already the case, 
367     // because the getActive runway function takes care of that.
368     if (firstFlight)
369     {
370         string rwyClass = getRunwayClassFromTrafficType(fltType);
371         double heading = ac->getTrafficRef()->getCourse();
372         apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway, heading);
373         rwy = apt->getRunwayByIdent(activeRunway);
374     }
375
376     double airportElev = apt->getElevation();
377     // Acceleration point, 105 meters into the runway,
378     SGGeod accelPoint = rwy->pointOnCenterline(105.0);
379     wpt = createOnGround(ac, "accel", accelPoint, airportElev, speed);
380     waypoints.push_back(wpt); 
381  
382     //Start Climbing to 3000 ft. Let's do this 
383     // at the center of the runway for now:
384     SGGeod rotate = rwy->pointOnCenterline(105.0+accelDistance);
385     wpt = cloneWithPos(ac, wpt, "SOC", rotate);
386     wpt->altitude  = airportElev+1000;
387     wpt->on_ground = false;
388     waypoints.push_back(wpt);
389
390     wpt = cloneWithPos(ac, wpt, "3000 ft", rwy->end());
391     wpt->altitude  = airportElev+3000;
392     waypoints.push_back(wpt);
393
394     // Finally, add two more waypoints, so that aircraft will remain under
395     // Tower control until they have reached the 3000 ft climb point
396     SGGeod pt = rwy->pointOnCenterline(5000 + rwy->lengthM() * 0.5);
397     wpt = cloneWithPos(ac, wpt, "5000 ft", pt);
398     wpt->altitude  = airportElev+5000;
399     waypoints.push_back(wpt);
400 }
401   
402 /*******************************************************************
403  * CreateClimb
404  * initialize the Aircraft at the parking location
405  ******************************************************************/
406 void FGAIFlightPlan::createClimb(FGAIAircraft *ac, bool firstFlight, FGAirport *apt, double speed, double alt, const string &fltType)
407 {
408   waypoint *wpt;
409   bool planLoaded = false;
410   string fPLName;
411
412   if (firstFlight) {
413     string rwyClass = getRunwayClassFromTrafficType(fltType);
414     double heading = ac->getTrafficRef()->getCourse();
415     apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway, heading);
416     rwy = apt->getRunwayByIdent(activeRunway);
417   }
418   if (fgGetBool("/sim/traffic-manager/use-custom-scenery-data") == true) {
419        string_list sc = globals->get_fg_scenery();
420        char buffer[64];
421        // NOTE: Currently for testing only. A slightly more elaborate naming convention
422        // needs to be dropped here.
423        snprintf(buffer, 64, "%s.SID-%s-01.xml", apt->getId().c_str(), activeRunway.c_str() );
424        string airportDir = expandICAODirs(apt->getId());
425        for (string_list_iterator i = sc.begin(); i != sc.end(); i++) {
426            SGPath aptpath( *i );
427            aptpath.append( "Airports" );
428            aptpath.append ( airportDir );
429            aptpath.append( string(buffer) );
430            if (aptpath.exists()) {
431                planLoaded = loadSID(aptpath.str());
432                //cerr << "Reading " << aptpath.str() << endl;
433            }
434         }
435   }
436   if (!planLoaded) {
437       SGGeod climb1 = rwy->pointOnCenterline(10*SG_NM_TO_METER);
438       wpt = createInAir(ac, "10000ft climb", climb1, speed, 10000);
439       wpt->gear_down = true;
440       wpt->flaps_down= true;
441       waypoints.push_back(wpt); 
442
443       SGGeod climb2 = rwy->pointOnCenterline(20*SG_NM_TO_METER);
444       wpt = cloneWithPos(ac, wpt, "18000ft climb", climb2);
445       wpt->altitude  = 18000;
446       waypoints.push_back(wpt); 
447    }
448 }
449
450 bool FGAIFlightPlan::loadSID(const string& filename)
451 {
452   SGPropertyNode root;
453   try {
454       readProperties(filename, &root);
455   } catch (const sg_exception &e) {
456       SG_LOG(SG_GENERAL, SG_ALERT,
457        "Error reading AI flight plan: " << filename);
458        // cout << path.str() << endl;
459      return false;
460   }
461
462   SGPropertyNode * node = root.getNode("flightplan");
463   for (int i = 0; i < node->nChildren(); i++) { 
464      //cout << "Reading waypoint " << i << endl;        
465      waypoint* wpt = new waypoint;
466      SGPropertyNode * wpt_node = node->getChild(i);
467      wpt->name      = wpt_node->getStringValue("name", "END");
468      wpt->latitude  = wpt_node->getDoubleValue("lat", 0);
469      wpt->longitude = wpt_node->getDoubleValue("lon", 0);
470      wpt->altitude  = wpt_node->getDoubleValue("alt", 0);
471      wpt->speed     = wpt_node->getDoubleValue("ktas", 0);
472      wpt->crossat   = wpt_node->getDoubleValue("crossat", -10000);
473      wpt->gear_down = wpt_node->getBoolValue("gear-down", false);
474      wpt->flaps_down= wpt_node->getBoolValue("flaps-down", false);
475      wpt->on_ground = wpt_node->getBoolValue("on-ground", false);
476      wpt->time_sec   = wpt_node->getDoubleValue("time-sec", 0);
477      wpt->time       = wpt_node->getStringValue("time", "");
478
479      if (wpt->name == "END") wpt->finished = true;
480      else wpt->finished = false;
481
482      waypoints.push_back( wpt );
483    }
484
485   //wpt_iterator = waypoints.begin();
486   //cout << waypoints.size() << " waypoints read." << endl;
487   return true;
488 }
489
490 // NOTE: This is just copied from Airports/readXML. 
491 string FGAIFlightPlan::expandICAODirs(const string in){
492      //cerr << "Expanding " << in << endl;
493      if (in.size() == 4) {
494           char buffer[11];
495           snprintf(buffer, 11, "%c/%c/%c", in[0], in[1], in[2]);
496           //cerr << "result: " << buffer << endl;
497           return string(buffer);
498      } else {
499            return in;
500      }
501      //exit(1);
502 }
503
504
505 /*******************************************************************
506  * CreateDecent
507  * initialize the Aircraft at the parking location
508  ******************************************************************/
509 void FGAIFlightPlan::createDecent(FGAIAircraft *ac, FGAirport *apt, const string &fltType)
510 {
511   // Ten thousand ft. Slowing down to 240 kts
512   waypoint *wpt;
513
514   //Beginning of Decent
515   //string name;
516   // allow "mil" and "gen" as well
517   string rwyClass = getRunwayClassFromTrafficType(fltType);
518   double heading = ac->getTrafficRef()->getCourse();
519   apt->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway, heading);
520   rwy = apt->getRunwayByIdent(activeRunway);
521      
522   SGGeod descent1 = rwy->pointOnCenterline(-100000); // 100km out
523   wpt = createInAir(ac, "Dec 10000ft", descent1, apt->getElevation(), 240);
524   wpt->crossat   = 10000;
525   waypoints.push_back(wpt);  
526   
527   // Three thousand ft. Slowing down to 160 kts
528   SGGeod descent2 = rwy->pointOnCenterline(-8*SG_NM_TO_METER); // 8nm out
529   wpt = createInAir(ac, "DEC 3000ft", descent2, apt->getElevation(), 160);
530   wpt->crossat   = 3000;
531   wpt->gear_down = true;
532   wpt->flaps_down= true;
533   waypoints.push_back(wpt);
534 }
535 /*******************************************************************
536  * CreateLanding
537  * initialize the Aircraft at the parking location
538  ******************************************************************/
539 void FGAIFlightPlan::createLanding(FGAIAircraft *ac, FGAirport *apt)
540 {
541   // Ten thousand ft. Slowing down to 150 kts
542   waypoint *wpt;
543   double aptElev = apt->getElevation();
544   //Runway Threshold
545   wpt = createOnGround(ac, "Threshold", rwy->threshold(), aptElev, 150);
546   wpt->crossat = apt->getElevation();
547   waypoints.push_back(wpt); 
548
549  // Roll-out
550   wpt = createOnGround(ac, "Center", rwy->geod(), aptElev, 30);
551   waypoints.push_back(wpt);
552
553   SGGeod rollOut = rwy->pointOnCenterline(rwy->lengthM() * 0.9);
554   wpt = createOnGround(ac, "Roll Out", rollOut, aptElev, 15);
555   wpt->crossat   = apt->getElevation();
556   waypoints.push_back(wpt); 
557 }
558
559 /*******************************************************************
560  * CreateParking
561  * initialize the Aircraft at the parking location
562  ******************************************************************/
563 void FGAIFlightPlan::createParking(FGAIAircraft *ac, FGAirport *apt, double radius)
564 {
565   waypoint* wpt;
566   double aptElev = apt->getElevation();
567   double lat, lat2;
568   double lon, lon2;
569   double az2;
570   double heading;
571   apt->getDynamics()->getParking(gateId, &lat, &lon, &heading);
572   heading += 180.0;
573   if (heading > 360)
574     heading -= 360; 
575   geo_direct_wgs_84 ( 0, lat, lon, heading, 
576                       2.2*radius,           
577                       &lat2, &lon2, &az2 );
578   wpt = createOnGround(ac, "taxiStart", SGGeod::fromDeg(lon2, lat2), aptElev, 10);
579   waypoints.push_back(wpt);
580   
581   geo_direct_wgs_84 ( 0, lat, lon, heading, 
582                       0.1 *radius,           
583                       &lat2, &lon2, &az2 );
584           
585   wpt = createOnGround(ac, "taxiStart2", SGGeod::fromDeg(lon2, lat2), aptElev, 10);
586   waypoints.push_back(wpt);   
587
588   wpt = createOnGround(ac, "END", SGGeod::fromDeg(lon, lat), aptElev, 10);
589   waypoints.push_back(wpt);
590 }
591
592 /**
593  *
594  * @param fltType a string describing the type of
595  * traffic, normally used for gate assignments
596  * @return a converted string that gives the runway
597  * preference schedule to be used at aircraft having
598  * a preferential runway schedule implemented (i.e.
599  * having a rwyprefs.xml file
600  * 
601  * Currently valid traffic types for gate assignment:
602  * - gate (commercial gate)
603  * - cargo (commercial gargo),
604  * - ga (general aviation) ,
605  * - ul (ultralight),
606  * - mil-fighter (military - fighter),
607  * - mil-transport (military - transport)
608  *
609  * Valid runway classes:
610  * - com (commercial traffic: jetliners, passenger and cargo)
611  * - gen (general aviation)
612  * - ul (ultralight: I can imagine that these may share a runway with ga on some airports)
613  * - mil (all military traffic)
614  */
615 string FGAIFlightPlan::getRunwayClassFromTrafficType(string fltType)
616 {
617     if ((fltType == "gate") || (fltType == "cargo")) { 
618         return string("com");
619     }
620     if (fltType == "ga") {
621         return string ("gen");
622     }
623     if (fltType == "ul") {
624         return string("ul");
625     }
626     if ((fltType == "mil-fighter") || (fltType == "mil-transport")) { 
627         return string("mil");
628     }
629    return string("com");
630 }