1 /******************************************************************************
2 * AIFlightPlanCreate.cxx
3 * Written by Durk Talsma, started May, 2004.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 **************************************************************************/
20 #include "AIFlightPlan.hxx"
21 #include <simgear/math/sg_geodesy.hxx>
22 #include <Airports/runways.hxx>
24 #include <Environment/environment_mgr.hxx>
25 #include <Environment/environment.hxx>
28 /* FGAIFlightPlan::create()
29 * dynamically create a flight plan for AI traffic, based on data provided by the
30 * Traffic Manager, when reading a filed flightplan failes. (DT, 2004/07/10)
32 * This is the top-level function, and the only one that is publicly available.
37 // Check lat/lon values during initialization;
38 void FGAIFlightPlan::create(FGAirport *dep, FGAirport *arr, int legNr,
39 double alt, double speed, double latitude,
40 double longitude, bool firstFlight,double radius,
41 const string& fltType, const string& aircraftType,
42 const string& airline)
44 int currWpt = wpt_iterator - waypoints.begin();
48 createPushBack(firstFlight,dep, latitude, longitude,
49 radius, fltType, aircraftType, airline);
52 createTaxi(firstFlight, 1, dep, latitude, longitude,
53 radius, fltType, aircraftType, airline);
56 createTakeOff(firstFlight, dep, speed, fltType);
59 createClimb(firstFlight, dep, speed, alt, fltType);
62 createCruise(firstFlight, dep,arr, latitude, longitude, speed, alt, fltType);
65 createDecent(arr, fltType);
71 createTaxi(false, 2, arr, latitude, longitude, radius,
72 fltType, aircraftType, airline);
75 createParking(arr, radius);
79 SG_LOG(SG_INPUT, SG_ALERT, "AIFlightPlan::create() attempting to create unknown leg"
80 " this is probably an internal program error");
82 wpt_iterator = waypoints.begin()+currWpt;
91 /*******************************************************************
93 * initialize the Aircraft at the parking location
94 ******************************************************************/
95 void FGAIFlightPlan::createTaxi(bool firstFlight, int direction,
96 FGAirport *apt, double latitude, double longitude,
97 double radius, const string& fltType,
98 const string& acType, const string& airline)
102 double lat2, lon2, az2;
105 int nrWaypointsToSkip;
109 // If this function is called during initialization,
110 // make sure we obtain a valid gate ID first
111 // and place the model at the location of the gate.
114 if (!(apt->getDynamics()->getAvailableParking(&lat, &lon,
119 SG_LOG(SG_INPUT, SG_WARN, "Could not find parking for a " <<
121 " of flight type " << fltType <<
122 " of airline " << airline <<
123 " at airport " << apt->getId());
125 //waypoint *wpt = new waypoint;
126 //wpt->name = "park";
127 //wpt->latitude = lat;
128 //wpt->longitude = lon;
129 //wpt->altitude = apt->getElevation();
131 //wpt->crossat = -10000;
132 //wpt->gear_down = true;
133 //wpt->flaps_down= true;
134 //wpt->finished = false;
135 //wpt->on_ground = true;
136 //waypoints.push_back(wpt);
138 string rwyClass = getRunwayClassFromTrafficType(fltType);
139 apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway);
140 if (!(globals->get_runways()->search(apt->getId(),
144 SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
146 " at airport " << apt->getId() << " of class " << rwyClass << " (1)");
150 // Determine the beginning of he runway
151 heading = rwy._heading;
152 double azimuth = heading + 180.0;
153 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
154 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
155 rwy._length * SG_FEET_TO_METER * 0.5 - 5.0,
156 &lat2, &lon2, &az2 );
158 if (apt->getDynamics()->getGroundNetwork()->exists())
161 int runwayId = apt->getDynamics()->getGroundNetwork()->findNearestNode(lat2,
165 // A negative gateId indicates an overflow parking, use a
166 // fallback mechanism for this.
167 // Starting from gate 0 in this case is a bit of a hack
168 // which requires a more proper solution later on.
171 taxiRoute = new FGTaxiRoute;
173 // Determine which node to start from.
175 // Find out which node to start from
176 FGParking *park = apt->getDynamics()->getParking(gateId);
178 node = park->getPushBackPoint();
184 // HAndle case where parking doens't have a node
185 if ((node == 0) && park) {
189 node = lastNodeVisited;
193 //cerr << "Using node " << node << endl;
194 *taxiRoute = apt->getDynamics()->getGroundNetwork()->findShortestRoute(node, runwayId);
197 if (taxiRoute->empty()) {
198 //Add the runway startpoint;
200 wpt->name = "Airport Center";
201 wpt->latitude = latitude;
202 wpt->longitude = longitude;
203 wpt->altitude = apt->getElevation();
205 wpt->crossat = -10000;
206 wpt->gear_down = true;
207 wpt->flaps_down= true;
208 wpt->finished = false;
209 wpt->on_ground = true;
211 waypoints.push_back(wpt);
213 //Add the runway startpoint;
215 wpt->name = "Runway Takeoff";
216 wpt->latitude = lat2;
217 wpt->longitude = lon2;
218 wpt->altitude = apt->getElevation();
220 wpt->crossat = -10000;
221 wpt->gear_down = true;
222 wpt->flaps_down= true;
223 wpt->finished = false;
224 wpt->on_ground = true;
226 waypoints.push_back(wpt);
230 //bool isPushBackPoint = false;
233 // If this is called during initialization, randomly
234 // skip a number of waypoints to get a more realistic
236 //isPushBackPoint = true;
237 int nrWaypoints = taxiRoute->size();
238 nrWaypointsToSkip = rand() % nrWaypoints;
239 // but make sure we always keep two active waypoints
240 // to prevent a segmentation fault
241 for (int i = 0; i < nrWaypointsToSkip-2; i++) {
242 //isPushBackPoint = false;
243 taxiRoute->next(&node);
245 apt->getDynamics()->releaseParking(gateId);
247 if (taxiRoute->size() > 1) {
248 taxiRoute->next(&node); // chop off the first waypoint, because that is already the last of the pushback route
252 while(taxiRoute->next(&node, &route))
254 //FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findSegment(node)->getEnd();
256 snprintf (buffer, 10, "%d", node);
257 FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findNode(node);
260 wpt->name = string(buffer); // fixme: should be the name of the taxiway
261 wpt->latitude = tn->getLatitude();
262 wpt->longitude = tn->getLongitude();
263 // Elevation is currently disregarded when on_ground is true
264 // because the AIModel obtains a periodic ground elevation estimate.
265 wpt->altitude = apt->getElevation();
267 wpt->crossat = -10000;
268 wpt->gear_down = true;
269 wpt->flaps_down= true;
270 wpt->finished = false;
271 wpt->on_ground = true;
272 wpt->routeIndex = route;
273 waypoints.push_back(wpt);
277 // finally, rewind the taxiRoute object to the point where we started
278 // generating the Flightplan, for AI use.
279 // This is a bit tricky, because the
282 for (int i = 0; i < nrWaypointsToSkip-1; i++) {
283 taxiRoute->next(&node);
286 int size = taxiRoute->size();
288 //taxiRoute->next(&node);
289 //taxiRoute->next(&node);
290 //taxiRoute->next(&node);
293 } // taxiRoute not empty
297 // This is the fallback mechanism, in case no ground network is available
298 //Add the runway startpoint;
300 wpt->name = "Airport Center";
301 wpt->latitude = apt->getLatitude();
302 wpt->longitude = apt->getLongitude();
303 wpt->altitude = apt->getElevation();
305 wpt->crossat = -10000;
306 wpt->gear_down = true;
307 wpt->flaps_down= true;
308 wpt->finished = false;
309 wpt->on_ground = true;
311 waypoints.push_back(wpt);
313 //Add the runway startpoint;
315 wpt->name = "Runway Takeoff";
316 wpt->latitude = lat2;
317 wpt->longitude = lon2;
318 wpt->altitude = apt->getElevation();
320 wpt->crossat = -10000;
321 wpt->gear_down = true;
322 wpt->flaps_down= true;
323 wpt->finished = false;
324 wpt->on_ground = true;
326 waypoints.push_back(wpt);
331 apt->getDynamics()->getAvailableParking(&lat, &lon, &heading,
332 &gateId, radius, fltType,
335 double lat3 = (*(waypoints.end()-1))->latitude;
336 double lon3 = (*(waypoints.end()-1))->longitude;
337 //cerr << (*(waypoints.end()-1))->name << endl;
339 // Find a route from runway end to parking/gate.
340 if (apt->getDynamics()->getGroundNetwork()->exists())
343 int runwayId = apt->getDynamics()->getGroundNetwork()->findNearestNode(lat3,
345 // A negative gateId indicates an overflow parking, use a
346 // fallback mechanism for this.
347 // Starting from gate 0 is a bit of a hack...
350 taxiRoute = new FGTaxiRoute;
352 *taxiRoute = apt->getDynamics()->getGroundNetwork()->findShortestRoute(runwayId,
355 *taxiRoute = apt->getDynamics()->getGroundNetwork()->findShortestRoute(runwayId, 0);
358 // No route found: go from gate directly to runway
359 if (taxiRoute->empty()) {
360 //Add the runway startpoint;
362 wpt->name = "Airport Center";
363 wpt->latitude = latitude;
364 wpt->longitude = longitude;
365 wpt->altitude = apt->getElevation();
367 wpt->crossat = -10000;
368 wpt->gear_down = true;
369 wpt->flaps_down= true;
370 wpt->finished = false;
371 wpt->on_ground = true;
373 waypoints.push_back(wpt);
375 //Add the runway startpoint;
377 wpt->name = "Runway Takeoff";
378 wpt->latitude = lat3;
379 wpt->longitude = lon3;
380 wpt->altitude = apt->getElevation();
382 wpt->crossat = -10000;
383 wpt->gear_down = true;
384 wpt->flaps_down= true;
385 wpt->finished = false;
386 wpt->on_ground = true;
388 waypoints.push_back(wpt);
392 int size = taxiRoute->size();
393 // Omit the last two waypoints, as
394 // those are created by createParking()
396 for (int i = 0; i < size-2; i++)
398 taxiRoute->next(&node, &route);
400 snprintf (buffer, 10, "%d", node);
401 //FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findNode(node);
402 FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findNode(node);
404 //wpt->name = "taxiway"; // fixme: should be the name of the taxiway
405 wpt->name = string(buffer);// fixme: should be the name of the taxiway
406 wpt->latitude = tn->getLatitude();
407 wpt->longitude = tn->getLongitude();
408 wpt->altitude = apt->getElevation();
410 wpt->crossat = -10000;
411 wpt->gear_down = true;
412 wpt->flaps_down= true;
413 wpt->finished = false;
414 wpt->on_ground = true;
415 wpt->routeIndex = route;
416 waypoints.push_back(wpt);
418 //taxiRoute->first();
419 //taxiRoute->next(&node);
424 // Use a fallback mechanism in case no ground network is available
425 // obtain the location of the gate entrance point
429 geo_direct_wgs_84 ( 0, lat, lon, heading,
431 &lat2, &lon2, &az2 );
433 wpt->name = "Airport Center";
434 wpt->latitude = apt->getLatitude();
435 wpt->longitude = apt->getLongitude();
436 wpt->altitude = apt->getElevation();
438 wpt->crossat = -10000;
439 wpt->gear_down = true;
440 wpt->flaps_down= true;
441 wpt->finished = false;
442 wpt->on_ground = true;
444 waypoints.push_back(wpt);
447 wpt->name = "Begin Parking"; //apt->getId(); //wpt_node->getStringValue("name", "END");
448 wpt->latitude = lat2;
449 wpt->longitude = lon2;
450 wpt->altitude = apt->getElevation();
452 wpt->crossat = -10000;
453 wpt->gear_down = true;
454 wpt->flaps_down= true;
455 wpt->finished = false;
456 wpt->on_ground = true;
458 waypoints.push_back(wpt);
464 apt->getDynamics()->getParking(gateId, &lat, &lon, &heading);
470 wpt->name = "END"; //wpt_node->getStringValue("name", "END");
472 wpt->longitude = lon;
475 wpt->crossat = -10000;
476 wpt->gear_down = true;
477 wpt->flaps_down= true;
478 wpt->finished = false;
479 wpt->on_ground = true;
481 waypoints.push_back(wpt);
487 /*******************************************************************
489 * initialize the Aircraft at the parking location
490 ******************************************************************/
491 void FGAIFlightPlan::createTakeOff(bool firstFlight, FGAirport *apt, double speed, const string &fltType)
495 double lat2, lon2, az2;
498 // Get the current active runway, based on code from David Luff
499 // This should actually be unified and extended to include
500 // Preferential runway use schema's
504 string rwyClass = getRunwayClassFromTrafficType(fltType);
505 apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway);
506 if (!(globals->get_runways()->search(apt->getId(),
510 SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
512 " at airport " << apt->getId()<< " of class " << rwyClass << " (2)");
516 // Acceleration point, 105 meters into the runway,
517 heading = rwy._heading;
518 double azimuth = heading + 180.0;
519 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
520 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
521 rwy._length * SG_FEET_TO_METER * 0.5 - 105.0,
522 &lat2, &lon2, &az2 );
525 wpt->latitude = lat2;
526 wpt->longitude = lon2;
527 wpt->altitude = apt->getElevation();
529 wpt->crossat = -10000;
530 wpt->gear_down = true;
531 wpt->flaps_down= true;
532 wpt->finished = false;
533 wpt->on_ground = true;
535 waypoints.push_back(wpt);
541 //Start Climbing to 3000 ft. Let's do this
542 // at the center of the runway for now:
544 geo_direct_wgs_84 ( 0, lat, lon, heading,
545 2560 * SG_FEET_TO_METER,
546 &lat2, &lon2, &az2 );
550 wpt->latitude = rwy._lat;
551 wpt->longitude = rwy._lon;
552 wpt->altitude = apt->getElevation()+1000;
554 wpt->crossat = -10000;
555 wpt->gear_down = true;
556 wpt->flaps_down= true;
557 wpt->finished = false;
558 wpt->on_ground = false;
560 waypoints.push_back(wpt);
563 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
564 rwy._length * SG_FEET_TO_METER,
565 &lat2, &lon2, &az2 );
568 wpt->name = "3000 ft";
569 wpt->latitude = lat2;
570 wpt->longitude = lon2;
571 wpt->altitude = apt->getElevation()+3000;
573 wpt->crossat = -10000;
574 wpt->gear_down = true;
575 wpt->flaps_down= true;
576 wpt->finished = false;
577 wpt->on_ground = false;
579 waypoints.push_back(wpt);
581 // Finally, add two more waypoints, so that aircraft will remain under
582 // Tower control until they have reached the 3000 ft climb point
585 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
587 &lat2, &lon2, &az2 );
591 wpt->name = "5000 ft";
592 wpt->latitude = lat2;
593 wpt->longitude = lon2;
594 wpt->altitude = apt->getElevation()+5000;
596 wpt->crossat = -10000;
597 wpt->gear_down = true;
598 wpt->flaps_down= true;
599 wpt->finished = false;
600 wpt->on_ground = false;
602 waypoints.push_back(wpt);
604 // geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
606 // &lat2, &lon2, &az2 );
607 // wpt = new waypoint;
608 // wpt->name = "5100 ft";
609 // wpt->latitude = lat2;
610 // wpt->longitude = lon2;
611 // wpt->altitude = apt->getElevation()+5100;
612 // wpt->speed = speed;
613 // wpt->crossat = -10000;
614 // wpt->gear_down = true;
615 // wpt->flaps_down= true;
616 // wpt->finished = false;
617 // wpt->on_ground = false;
618 // wpt->routeIndex = 0;
619 // waypoints.push_back(wpt);
622 /*******************************************************************
624 * initialize the Aircraft at the parking location
625 ******************************************************************/
626 void FGAIFlightPlan::createClimb(bool firstFlight, FGAirport *apt, double speed, double alt, const string &fltType)
630 double lat2, lon2, az2;
638 string rwyClass = getRunwayClassFromTrafficType(fltType);
639 apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway);
640 if (!(globals->get_runways()->search(apt->getId(),
644 SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
646 " at airport " << apt->getId()<< " of class " << rwyClass << " (3)");
652 heading = rwy._heading;
653 double azimuth = heading + 180.0;
654 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
655 //cerr << "Creating climb at : " << rwy._id << " " << rwy._rwy_no << endl;
656 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
658 &lat2, &lon2, &az2 );
660 wpt->name = "10000ft climb";
661 wpt->latitude = lat2;
662 wpt->longitude = lon2;
663 wpt->altitude = 10000;
665 wpt->crossat = -10000;
666 wpt->gear_down = true;
667 wpt->flaps_down= true;
668 wpt->finished = false;
669 wpt->on_ground = false;
671 waypoints.push_back(wpt);
674 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
676 &lat2, &lon2, &az2 );
678 wpt->name = "18000ft climb";
679 wpt->latitude = lat2;
680 wpt->longitude = lon2;
681 wpt->altitude = 18000;
683 wpt->crossat = -10000;
684 wpt->gear_down = true;
685 wpt->flaps_down= true;
686 wpt->finished = false;
687 wpt->on_ground = false;
689 waypoints.push_back(wpt);
693 // /*******************************************************************
695 // * initialize the Aircraft at the parking location
696 // ******************************************************************/
697 // void FGAIFlightPlan::createCruise(bool firstFlight, FGAirport *dep,
698 // FGAirport *arr, double latitude,
699 // double longitude, double speed,
702 // double wind_speed;
703 // double wind_heading;
705 // double lat, lon, az;
706 // double lat2, lon2, az2;
710 // wpt = new waypoint;
711 // wpt->name = "Cruise"; //wpt_node->getStringValue("name", "END");
712 // wpt->latitude = latitude;
713 // wpt->longitude = longitude;
714 // wpt->altitude = alt;
715 // wpt->speed = speed;
716 // wpt->crossat = -10000;
717 // wpt->gear_down = false;
718 // wpt->flaps_down= false;
719 // wpt->finished = false;
720 // wpt->on_ground = false;
721 // waypoints.push_back(wpt);
724 // // should be changed dynamically to allow "gen" and "mil"
725 // arr->getDynamics()->getActiveRunway("com", 2, activeRunway);
726 // if (!(globals->get_runways()->search(arr->getId(),
730 // SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
732 // " at airport " << arr->getId());
735 // heading = rwy._heading;
736 // azimuth = heading + 180.0;
737 // while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
740 // geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
742 // &lat2, &lon2, &az2 );
743 // wpt = new waypoint;
744 // wpt->name = "BOD";
745 // wpt->latitude = lat2;
746 // wpt->longitude = lon2;
747 // wpt->altitude = alt;
748 // wpt->speed = speed;
749 // wpt->crossat = alt;
750 // wpt->gear_down = false;
751 // wpt->flaps_down= false;
752 // wpt->finished = false;
753 // wpt->on_ground = false;
754 // waypoints.push_back(wpt);
757 /*******************************************************************
759 * initialize the Aircraft at the parking location
760 ******************************************************************/
761 void FGAIFlightPlan::createDecent(FGAirport *apt, const string &fltType)
764 // Ten thousand ft. Slowing down to 240 kts
767 double lat2, lon2, az2;
772 //Beginning of Decent
774 // allow "mil" and "gen" as well
775 string rwyClass = getRunwayClassFromTrafficType(fltType);
776 apt->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway);
777 if (!(globals->get_runways()->search(apt->getId(),
781 SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
783 " at airport " << apt->getId()<< " of class " << rwyClass << " (4)");
787 heading = rwy._heading;
788 azimuth = heading + 180.0;
789 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
790 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
792 &lat2, &lon2, &az2 );
795 wpt->name = "Dec 10000ft"; //wpt_node->getStringValue("name", "END");
796 wpt->latitude = lat2;
797 wpt->longitude = lon2;
798 wpt->altitude = apt->getElevation();
800 wpt->crossat = 10000;
801 wpt->gear_down = false;
802 wpt->flaps_down= false;
803 wpt->finished = false;
804 wpt->on_ground = false;
806 waypoints.push_back(wpt);
808 // Three thousand ft. Slowing down to 160 kts
809 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
811 &lat2, &lon2, &az2 );
813 wpt->name = "DEC 3000ft"; //wpt_node->getStringValue("name", "END");
814 wpt->latitude = lat2;
815 wpt->longitude = lon2;
816 wpt->altitude = apt->getElevation();
819 wpt->gear_down = true;
820 wpt->flaps_down= true;
821 wpt->finished = false;
822 wpt->on_ground = false;
824 waypoints.push_back(wpt);
826 /*******************************************************************
828 * initialize the Aircraft at the parking location
829 ******************************************************************/
830 void FGAIFlightPlan::createLanding(FGAirport *apt)
832 // Ten thousand ft. Slowing down to 150 kts
835 double lat2, lon2, az2;
841 heading = rwy._heading;
842 azimuth = heading + 180.0;
843 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
846 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
847 rwy._length*0.45 * SG_FEET_TO_METER,
848 &lat2, &lon2, &az2 );
850 wpt->name = "Threshold"; //wpt_node->getStringValue("name", "END");
851 wpt->latitude = lat2;
852 wpt->longitude = lon2;
853 wpt->altitude = apt->getElevation();
855 wpt->crossat = apt->getElevation();
856 wpt->gear_down = true;
857 wpt->flaps_down= true;
858 wpt->finished = false;
859 wpt->on_ground = true;
861 waypoints.push_back(wpt);
863 //Full stop at the runway centerpoint
864 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
866 &lat2, &lon2, &az2 );
868 wpt->name = "Center"; //wpt_node->getStringValue("name", "END");
869 wpt->latitude = rwy._lat;
870 wpt->longitude = rwy._lon;
871 wpt->altitude = apt->getElevation();
873 wpt->crossat = -10000;
874 wpt->gear_down = true;
875 wpt->flaps_down= true;
876 wpt->finished = false;
877 wpt->on_ground = true;
879 waypoints.push_back(wpt);
881 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
882 rwy._length*0.45 * SG_FEET_TO_METER,
883 &lat2, &lon2, &az2 );
885 wpt->name = "Threshold"; //wpt_node->getStringValue("name", "END");
886 wpt->latitude = lat2;
887 wpt->longitude = lon2;
888 wpt->altitude = apt->getElevation();
890 wpt->crossat = apt->getElevation();
891 wpt->gear_down = true;
892 wpt->flaps_down= true;
893 wpt->finished = false;
894 wpt->on_ground = true;
896 waypoints.push_back(wpt);
899 /*******************************************************************
901 * initialize the Aircraft at the parking location
902 ******************************************************************/
903 void FGAIFlightPlan::createParking(FGAirport *apt, double radius)
910 apt->getDynamics()->getParking(gateId, &lat, &lon, &heading);
914 geo_direct_wgs_84 ( 0, lat, lon, heading,
916 &lat2, &lon2, &az2 );
918 wpt->name = "taxiStart";
919 wpt->latitude = lat2;
920 wpt->longitude = lon2;
921 wpt->altitude = apt->getElevation();
923 wpt->crossat = -10000;
924 wpt->gear_down = true;
925 wpt->flaps_down= true;
926 wpt->finished = false;
927 wpt->on_ground = true;
929 waypoints.push_back(wpt);
930 geo_direct_wgs_84 ( 0, lat, lon, heading,
932 &lat2, &lon2, &az2 );
934 wpt->name = "taxiStart";
935 wpt->latitude = lat2;
936 wpt->longitude = lon2;
937 wpt->altitude = apt->getElevation();
939 wpt->crossat = -10000;
940 wpt->gear_down = true;
941 wpt->flaps_down= true;
942 wpt->finished = false;
943 wpt->on_ground = true;
945 waypoints.push_back(wpt);
948 wpt->name = "END"; //wpt_node->getStringValue("name", "END");
950 wpt->longitude = lon;
951 wpt->altitude = apt->getElevation();
953 wpt->crossat = -10000;
954 wpt->gear_down = true;
955 wpt->flaps_down= true;
956 wpt->finished = false;
957 wpt->on_ground = true;
959 waypoints.push_back(wpt);
964 * @param fltType a string describing the type of
965 * traffic, normally used for gate assignments
966 * @return a converted string that gives the runway
967 * preference schedule to be used at aircraft having
968 * a preferential runway schedule implemented (i.e.
969 * having a rwyprefs.xml file
971 * Currently valid traffic types for gate assignment:
972 * - gate (commercial gate)
973 * - cargo (commercial gargo),
974 * - ga (general aviation) ,
976 * - mil-fighter (military - fighter),
977 * - mil-transport (military - transport)
979 * Valid runway classes:
980 * - com (commercial traffic: jetliners, passenger and cargo)
981 * - gen (general aviation)
982 * - ul (ultralight: I can imagine that these may share a runway with ga on some airports)
983 * - mil (all military traffic)
985 string FGAIFlightPlan::getRunwayClassFromTrafficType(string fltType)
987 if ((fltType == "gate") || (fltType == "cargo")) {
988 return string("com");
990 if (fltType == "ga") {
991 return string ("gen");
993 if (fltType == "ul") {
996 if ((fltType == "mil-fighter") || (fltType == "mil-transport")) {
997 return string("mil");
999 return string("com");