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);
59 createClimb(firstFlight, dep, speed, alt);
62 createCruise(firstFlight, dep,arr, latitude, longitude, speed, alt);
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;
86 /*******************************************************************
88 * initialize the Aircraft at the parking location
89 ******************************************************************/
90 void FGAIFlightPlan::createPushBack(bool firstFlight, FGAirport *dep,
94 const string& fltType,
95 const string& aircraftType,
96 const string& airline)
105 //int currWpt = wpt_iterator - waypoints.begin();
106 // Erase all existing waypoints.
109 // We only need to get a valid parking if this is the first leg.
110 // Otherwise use the current aircraft position.
113 if (!(dep->getDynamics()->getAvailableParking(&lat, &lon,
116 aircraftType, airline)))
118 SG_LOG(SG_INPUT, SG_WARN, "Could not find parking for a " <<
120 " of flight type " << fltType <<
121 " of airline " << airline <<
122 " at airport " << dep->getId());
127 dep->getDynamics()->getParking(gateId, &lat, &lon, &heading);
132 waypoint *wpt = new waypoint;
135 wpt->longitude = lon;
136 wpt->altitude = dep->getElevation();
138 wpt->crossat = -10000;
139 wpt->gear_down = true;
140 wpt->flaps_down= true;
141 wpt->finished = false;
142 wpt->on_ground = true;
144 waypoints.push_back(wpt);
146 geo_direct_wgs_84 ( 0, lat, lon, heading,
148 &lat2, &lon2, &az2 );
151 wpt->latitude = lat2;
152 wpt->longitude = lon2;
153 wpt->altitude = dep->getElevation();
155 wpt->crossat = -10000;
156 wpt->gear_down = true;
157 wpt->flaps_down= true;
158 wpt->finished = false;
159 wpt->on_ground = true;
161 waypoints.push_back(wpt);
162 geo_direct_wgs_84 ( 0, lat, lon, heading,
164 &lat2, &lon2, &az2 );
166 wpt->name = "taxiStart";
167 wpt->latitude = lat2;
168 wpt->longitude = lon2;
169 wpt->altitude = dep->getElevation();
171 wpt->crossat = -10000;
172 wpt->gear_down = true;
173 wpt->flaps_down= true;
174 wpt->finished = false;
175 wpt->on_ground = true;
177 waypoints.push_back(wpt);
180 /*******************************************************************
182 * initialize the Aircraft at the parking location
183 ******************************************************************/
184 void FGAIFlightPlan::createTaxi(bool firstFlight, int direction,
185 FGAirport *apt, double latitude, double longitude,
186 double radius, const string& fltType,
187 const string& acType, const string& airline)
191 double lat2, lon2, az2;
194 int nrWaypointsToSkip;
198 // If this function is called during initialization,
199 // make sure we obtain a valid gate ID first
200 // and place the model at the location of the gate.
203 if (!(apt->getDynamics()->getAvailableParking(&lat, &lon,
208 SG_LOG(SG_INPUT, SG_WARN, "Could not find parking for a " <<
210 " of flight type " << fltType <<
211 " of airline " << airline <<
212 " at airport " << apt->getId());
214 //waypoint *wpt = new waypoint;
215 //wpt->name = "park";
216 //wpt->latitude = lat;
217 //wpt->longitude = lon;
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;
225 //waypoints.push_back(wpt);
227 // "NOTE: this is currently fixed to "com" for commercial traffic
228 // Should be changed to be used dynamically to allow "gen" and "mil"
230 apt->getDynamics()->getActiveRunway("com", 1, activeRunway);
231 if (!(globals->get_runways()->search(apt->getId(),
235 SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
237 " at airport " << apt->getId());
241 // Determine the beginning of he runway
242 heading = rwy._heading;
243 double azimuth = heading + 180.0;
244 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
245 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
246 rwy._length * SG_FEET_TO_METER * 0.5 - 5.0,
247 &lat2, &lon2, &az2 );
249 if (apt->getDynamics()->getGroundNetwork()->exists())
252 int runwayId = apt->getDynamics()->getGroundNetwork()->findNearestNode(lat2,
256 // A negative gateId indicates an overflow parking, use a
257 // fallback mechanism for this.
258 // Starting from gate 0 in this case is a bit of a hack
259 // which requires a more proper solution later on.
263 taxiRoute = new FGTaxiRoute;
265 *taxiRoute = apt->getDynamics()->getGroundNetwork()->findShortestRoute(gateId,
268 *taxiRoute = apt->getDynamics()->getGroundNetwork()->findShortestRoute(0, runwayId);
271 if (taxiRoute->empty()) {
272 //Add the runway startpoint;
274 wpt->name = "Airport Center";
275 wpt->latitude = latitude;
276 wpt->longitude = longitude;
277 wpt->altitude = apt->getElevation();
279 wpt->crossat = -10000;
280 wpt->gear_down = true;
281 wpt->flaps_down= true;
282 wpt->finished = false;
283 wpt->on_ground = true;
285 waypoints.push_back(wpt);
287 //Add the runway startpoint;
289 wpt->name = "Runway Takeoff";
290 wpt->latitude = lat2;
291 wpt->longitude = lon2;
292 wpt->altitude = apt->getElevation();
294 wpt->crossat = -10000;
295 wpt->gear_down = true;
296 wpt->flaps_down= true;
297 wpt->finished = false;
298 wpt->on_ground = true;
300 waypoints.push_back(wpt);
304 bool isPushBackPoint = false;
306 // If this is called during initialization, randomly
307 // skip a number of waypoints to get a more realistic
309 isPushBackPoint = true;
310 int nrWaypoints = taxiRoute->size();
311 nrWaypointsToSkip = rand() % nrWaypoints;
312 // but make sure we always keep two active waypoints
313 // to prevent a segmentation fault
314 for (int i = 0; i < nrWaypointsToSkip-2; i++) {
315 isPushBackPoint = false;
316 taxiRoute->next(&node);
319 //chop off the first two waypoints, because
320 // those have already been created
321 // by create pushback
322 int size = taxiRoute->size();
324 taxiRoute->next(&node);
325 taxiRoute->next(&node);
329 while(taxiRoute->next(&node, &route))
331 //FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findSegment(node)->getEnd();
333 snprintf (buffer, 10, "%d", node);
334 FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findNode(node);
337 wpt->name = string(buffer); // fixme: should be the name of the taxiway
338 wpt->latitude = tn->getLatitude();
339 wpt->longitude = tn->getLongitude();
340 // Elevation is currently disregarded when on_ground is true
341 // because the AIModel obtains a periodic ground elevation estimate.
342 wpt->altitude = apt->getElevation();
343 if (isPushBackPoint) {
345 isPushBackPoint = false;
350 wpt->crossat = -10000;
351 wpt->gear_down = true;
352 wpt->flaps_down= true;
353 wpt->finished = false;
354 wpt->on_ground = true;
355 wpt->routeIndex = route;
356 waypoints.push_back(wpt);
359 // finally, rewind the taxiRoute object to the point where we started
360 // generating the Flightplan, for AI use.
361 // This is a bit tricky, because the
364 for (int i = 0; i < nrWaypointsToSkip-1; i++) {
365 taxiRoute->next(&node);
368 int size = taxiRoute->size();
370 //taxiRoute->next(&node);
371 //taxiRoute->next(&node);
372 //taxiRoute->next(&node);
375 } // taxiRoute not empty
379 // This is the fallback mechanism, in case no ground network is available
380 //Add the runway startpoint;
382 wpt->name = "Airport Center";
383 wpt->latitude = apt->getLatitude();
384 wpt->longitude = apt->getLongitude();
385 wpt->altitude = apt->getElevation();
387 wpt->crossat = -10000;
388 wpt->gear_down = true;
389 wpt->flaps_down= true;
390 wpt->finished = false;
391 wpt->on_ground = true;
393 waypoints.push_back(wpt);
395 //Add the runway startpoint;
397 wpt->name = "Runway Takeoff";
398 wpt->latitude = lat2;
399 wpt->longitude = lon2;
400 wpt->altitude = apt->getElevation();
402 wpt->crossat = -10000;
403 wpt->gear_down = true;
404 wpt->flaps_down= true;
405 wpt->finished = false;
406 wpt->on_ground = true;
408 waypoints.push_back(wpt);
413 apt->getDynamics()->getAvailableParking(&lat, &lon, &heading,
414 &gateId, radius, fltType,
417 double lat3 = (*(waypoints.end()-1))->latitude;
418 double lon3 = (*(waypoints.end()-1))->longitude;
419 //cerr << (*(waypoints.end()-1))->name << endl;
421 // Find a route from runway end to parking/gate.
422 if (apt->getDynamics()->getGroundNetwork()->exists())
425 int runwayId = apt->getDynamics()->getGroundNetwork()->findNearestNode(lat3,
427 // A negative gateId indicates an overflow parking, use a
428 // fallback mechanism for this.
429 // Starting from gate 0 is a bit of a hack...
433 taxiRoute = new FGTaxiRoute;
435 *taxiRoute = apt->getDynamics()->getGroundNetwork()->findShortestRoute(runwayId,
438 *taxiRoute = apt->getDynamics()->getGroundNetwork()->findShortestRoute(runwayId, 0);
441 // No route found: go from gate directly to runway
442 if (taxiRoute->empty()) {
443 //Add the runway startpoint;
445 wpt->name = "Airport Center";
446 wpt->latitude = latitude;
447 wpt->longitude = longitude;
448 wpt->altitude = apt->getElevation();
450 wpt->crossat = -10000;
451 wpt->gear_down = true;
452 wpt->flaps_down= true;
453 wpt->finished = false;
454 wpt->on_ground = true;
456 waypoints.push_back(wpt);
458 //Add the runway startpoint;
460 wpt->name = "Runway Takeoff";
461 wpt->latitude = lat3;
462 wpt->longitude = lon3;
463 wpt->altitude = apt->getElevation();
465 wpt->crossat = -10000;
466 wpt->gear_down = true;
467 wpt->flaps_down= true;
468 wpt->finished = false;
469 wpt->on_ground = true;
471 waypoints.push_back(wpt);
475 int size = taxiRoute->size();
476 // Omit the last two waypoints, as
477 // those are created by createParking()
479 for (int i = 0; i < size-2; i++)
481 taxiRoute->next(&node, &route);
483 snprintf (buffer, 10, "%d", node);
484 //FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findNode(node);
485 FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findNode(node);
487 //wpt->name = "taxiway"; // fixme: should be the name of the taxiway
488 wpt->name = string(buffer);// fixme: should be the name of the taxiway
489 wpt->latitude = tn->getLatitude();
490 wpt->longitude = tn->getLongitude();
491 wpt->altitude = apt->getElevation();
493 wpt->crossat = -10000;
494 wpt->gear_down = true;
495 wpt->flaps_down= true;
496 wpt->finished = false;
497 wpt->on_ground = true;
498 wpt->routeIndex = route;
499 waypoints.push_back(wpt);
501 //taxiRoute->first();
502 //taxiRoute->next(&node);
507 // Use a fallback mechanism in case no ground network is available
508 // obtain the location of the gate entrance point
512 geo_direct_wgs_84 ( 0, lat, lon, heading,
514 &lat2, &lon2, &az2 );
516 wpt->name = "Airport Center";
517 wpt->latitude = apt->getLatitude();
518 wpt->longitude = apt->getLongitude();
519 wpt->altitude = apt->getElevation();
521 wpt->crossat = -10000;
522 wpt->gear_down = true;
523 wpt->flaps_down= true;
524 wpt->finished = false;
525 wpt->on_ground = true;
527 waypoints.push_back(wpt);
530 wpt->name = "Begin Parking"; //apt->getId(); //wpt_node->getStringValue("name", "END");
531 wpt->latitude = lat2;
532 wpt->longitude = lon2;
533 wpt->altitude = apt->getElevation();
535 wpt->crossat = -10000;
536 wpt->gear_down = true;
537 wpt->flaps_down= true;
538 wpt->finished = false;
539 wpt->on_ground = true;
541 waypoints.push_back(wpt);
547 apt->getDynamics()->getParking(gateId, &lat, &lon, &heading);
553 wpt->name = "END"; //wpt_node->getStringValue("name", "END");
555 wpt->longitude = lon;
558 wpt->crossat = -10000;
559 wpt->gear_down = true;
560 wpt->flaps_down= true;
561 wpt->finished = false;
562 wpt->on_ground = true;
564 waypoints.push_back(wpt);
570 /*******************************************************************
572 * initialize the Aircraft at the parking location
573 ******************************************************************/
574 void FGAIFlightPlan::createTakeOff(bool firstFlight, FGAirport *apt, double speed)
578 double lat2, lon2, az2;
581 // Get the current active runway, based on code from David Luff
582 // This should actually be unified and extended to include
583 // Preferential runway use schema's
587 // "NOTE: this is currently fixed to "com" for commercial traffic
588 // Should be changed to be used dynamically to allow "gen" and "mil"
590 apt->getDynamics()->getActiveRunway("com", 1, activeRunway);
591 if (!(globals->get_runways()->search(apt->getId(),
595 SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
597 " at airport " << apt->getId());
601 // Acceleration point, 105 meters into the runway,
602 heading = rwy._heading;
603 double azimuth = heading + 180.0;
604 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
605 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
606 rwy._length * SG_FEET_TO_METER * 0.5 - 105.0,
607 &lat2, &lon2, &az2 );
610 wpt->latitude = lat2;
611 wpt->longitude = lon2;
612 wpt->altitude = apt->getElevation();
614 wpt->crossat = -10000;
615 wpt->gear_down = true;
616 wpt->flaps_down= true;
617 wpt->finished = false;
618 wpt->on_ground = true;
620 waypoints.push_back(wpt);
626 //Start Climbing to 3000 ft. Let's do this
627 // at the center of the runway for now:
629 geo_direct_wgs_84 ( 0, lat, lon, heading,
630 2560 * SG_FEET_TO_METER,
631 &lat2, &lon2, &az2 );
635 wpt->latitude = rwy._lat;
636 wpt->longitude = rwy._lon;
637 wpt->altitude = apt->getElevation()+1000;
639 wpt->crossat = -10000;
640 wpt->gear_down = true;
641 wpt->flaps_down= true;
642 wpt->finished = false;
643 wpt->on_ground = false;
645 waypoints.push_back(wpt);
648 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
649 rwy._length * SG_FEET_TO_METER,
650 &lat2, &lon2, &az2 );
653 wpt->name = "3000 ft";
654 wpt->latitude = lat2;
655 wpt->longitude = lon2;
656 wpt->altitude = apt->getElevation()+3000;
658 wpt->crossat = -10000;
659 wpt->gear_down = true;
660 wpt->flaps_down= true;
661 wpt->finished = false;
662 wpt->on_ground = false;
664 waypoints.push_back(wpt);
666 // Finally, add two more waypoints, so that aircraft will remain under
667 // Tower control until they have reached the 3000 ft climb point
670 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
672 &lat2, &lon2, &az2 );
676 wpt->name = "5000 ft";
677 wpt->latitude = lat2;
678 wpt->longitude = lon2;
679 wpt->altitude = apt->getElevation()+5000;
681 wpt->crossat = -10000;
682 wpt->gear_down = true;
683 wpt->flaps_down= true;
684 wpt->finished = false;
685 wpt->on_ground = false;
687 waypoints.push_back(wpt);
689 // geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
691 // &lat2, &lon2, &az2 );
692 // wpt = new waypoint;
693 // wpt->name = "5100 ft";
694 // wpt->latitude = lat2;
695 // wpt->longitude = lon2;
696 // wpt->altitude = apt->getElevation()+5100;
697 // wpt->speed = speed;
698 // wpt->crossat = -10000;
699 // wpt->gear_down = true;
700 // wpt->flaps_down= true;
701 // wpt->finished = false;
702 // wpt->on_ground = false;
703 // wpt->routeIndex = 0;
704 // waypoints.push_back(wpt);
707 /*******************************************************************
709 * initialize the Aircraft at the parking location
710 ******************************************************************/
711 void FGAIFlightPlan::createClimb(bool firstFlight, FGAirport *apt, double speed, double alt)
715 double lat2, lon2, az2;
723 // "NOTE: this is currently fixed to "com" for commercial traffic
724 // Should be changed to be used dynamically to allow "gen" and "mil"
726 apt->getDynamics()->getActiveRunway("com", 1, activeRunway);
727 if (!(globals->get_runways()->search(apt->getId(),
731 SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
733 " at airport " << apt->getId());
739 heading = rwy._heading;
740 double azimuth = heading + 180.0;
741 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
742 //cerr << "Creating climb at : " << rwy._id << " " << rwy._rwy_no << endl;
743 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
745 &lat2, &lon2, &az2 );
747 wpt->name = "10000ft climb";
748 wpt->latitude = lat2;
749 wpt->longitude = lon2;
750 wpt->altitude = 10000;
752 wpt->crossat = -10000;
753 wpt->gear_down = true;
754 wpt->flaps_down= true;
755 wpt->finished = false;
756 wpt->on_ground = false;
758 waypoints.push_back(wpt);
761 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
763 &lat2, &lon2, &az2 );
765 wpt->name = "18000ft climb";
766 wpt->latitude = lat2;
767 wpt->longitude = lon2;
768 wpt->altitude = 18000;
770 wpt->crossat = -10000;
771 wpt->gear_down = true;
772 wpt->flaps_down= true;
773 wpt->finished = false;
774 wpt->on_ground = false;
776 waypoints.push_back(wpt);
780 // /*******************************************************************
782 // * initialize the Aircraft at the parking location
783 // ******************************************************************/
784 // void FGAIFlightPlan::createCruise(bool firstFlight, FGAirport *dep,
785 // FGAirport *arr, double latitude,
786 // double longitude, double speed,
789 // double wind_speed;
790 // double wind_heading;
792 // double lat, lon, az;
793 // double lat2, lon2, az2;
797 // wpt = new waypoint;
798 // wpt->name = "Cruise"; //wpt_node->getStringValue("name", "END");
799 // wpt->latitude = latitude;
800 // wpt->longitude = longitude;
801 // wpt->altitude = alt;
802 // wpt->speed = speed;
803 // wpt->crossat = -10000;
804 // wpt->gear_down = false;
805 // wpt->flaps_down= false;
806 // wpt->finished = false;
807 // wpt->on_ground = false;
808 // waypoints.push_back(wpt);
811 // // should be changed dynamically to allow "gen" and "mil"
812 // arr->getDynamics()->getActiveRunway("com", 2, activeRunway);
813 // if (!(globals->get_runways()->search(arr->getId(),
817 // SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
819 // " at airport " << arr->getId());
822 // heading = rwy._heading;
823 // azimuth = heading + 180.0;
824 // while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
827 // geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
829 // &lat2, &lon2, &az2 );
830 // wpt = new waypoint;
831 // wpt->name = "BOD";
832 // wpt->latitude = lat2;
833 // wpt->longitude = lon2;
834 // wpt->altitude = alt;
835 // wpt->speed = speed;
836 // wpt->crossat = alt;
837 // wpt->gear_down = false;
838 // wpt->flaps_down= false;
839 // wpt->finished = false;
840 // wpt->on_ground = false;
841 // waypoints.push_back(wpt);
844 /*******************************************************************
846 * initialize the Aircraft at the parking location
847 ******************************************************************/
848 void FGAIFlightPlan::createDecent(FGAirport *apt)
851 // Ten thousand ft. Slowing down to 240 kts
854 double lat2, lon2, az2;
859 //Beginning of Decent
861 // allow "mil" and "gen" as well
862 apt->getDynamics()->getActiveRunway("com", 2, activeRunway);
863 if (!(globals->get_runways()->search(apt->getId(),
867 SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
869 " at airport " << apt->getId());
873 heading = rwy._heading;
874 azimuth = heading + 180.0;
875 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
876 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
878 &lat2, &lon2, &az2 );
881 wpt->name = "Dec 10000ft"; //wpt_node->getStringValue("name", "END");
882 wpt->latitude = lat2;
883 wpt->longitude = lon2;
884 wpt->altitude = apt->getElevation();
886 wpt->crossat = 10000;
887 wpt->gear_down = false;
888 wpt->flaps_down= false;
889 wpt->finished = false;
890 wpt->on_ground = false;
892 waypoints.push_back(wpt);
894 // Three thousand ft. Slowing down to 160 kts
895 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
897 &lat2, &lon2, &az2 );
899 wpt->name = "DEC 3000ft"; //wpt_node->getStringValue("name", "END");
900 wpt->latitude = lat2;
901 wpt->longitude = lon2;
902 wpt->altitude = apt->getElevation();
905 wpt->gear_down = true;
906 wpt->flaps_down= true;
907 wpt->finished = false;
908 wpt->on_ground = false;
910 waypoints.push_back(wpt);
912 /*******************************************************************
914 * initialize the Aircraft at the parking location
915 ******************************************************************/
916 void FGAIFlightPlan::createLanding(FGAirport *apt)
918 // Ten thousand ft. Slowing down to 150 kts
921 double lat2, lon2, az2;
927 heading = rwy._heading;
928 azimuth = heading + 180.0;
929 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
932 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
933 rwy._length*0.45 * SG_FEET_TO_METER,
934 &lat2, &lon2, &az2 );
936 wpt->name = "Threshold"; //wpt_node->getStringValue("name", "END");
937 wpt->latitude = lat2;
938 wpt->longitude = lon2;
939 wpt->altitude = apt->getElevation();
941 wpt->crossat = apt->getElevation();
942 wpt->gear_down = true;
943 wpt->flaps_down= true;
944 wpt->finished = false;
945 wpt->on_ground = true;
947 waypoints.push_back(wpt);
949 //Full stop at the runway centerpoint
950 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
952 &lat2, &lon2, &az2 );
954 wpt->name = "Center"; //wpt_node->getStringValue("name", "END");
955 wpt->latitude = rwy._lat;
956 wpt->longitude = rwy._lon;
957 wpt->altitude = apt->getElevation();
959 wpt->crossat = -10000;
960 wpt->gear_down = true;
961 wpt->flaps_down= true;
962 wpt->finished = false;
963 wpt->on_ground = true;
965 waypoints.push_back(wpt);
967 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
968 rwy._length*0.45 * SG_FEET_TO_METER,
969 &lat2, &lon2, &az2 );
971 wpt->name = "Threshold"; //wpt_node->getStringValue("name", "END");
972 wpt->latitude = lat2;
973 wpt->longitude = lon2;
974 wpt->altitude = apt->getElevation();
976 wpt->crossat = apt->getElevation();
977 wpt->gear_down = true;
978 wpt->flaps_down= true;
979 wpt->finished = false;
980 wpt->on_ground = true;
982 waypoints.push_back(wpt);
985 /*******************************************************************
987 * initialize the Aircraft at the parking location
988 ******************************************************************/
989 void FGAIFlightPlan::createParking(FGAirport *apt, double radius)
996 apt->getDynamics()->getParking(gateId, &lat, &lon, &heading);
1000 geo_direct_wgs_84 ( 0, lat, lon, heading,
1002 &lat2, &lon2, &az2 );
1004 wpt->name = "taxiStart";
1005 wpt->latitude = lat2;
1006 wpt->longitude = lon2;
1007 wpt->altitude = apt->getElevation();
1009 wpt->crossat = -10000;
1010 wpt->gear_down = true;
1011 wpt->flaps_down= true;
1012 wpt->finished = false;
1013 wpt->on_ground = true;
1014 wpt->routeIndex = 0;
1015 waypoints.push_back(wpt);
1016 geo_direct_wgs_84 ( 0, lat, lon, heading,
1018 &lat2, &lon2, &az2 );
1020 wpt->name = "taxiStart";
1021 wpt->latitude = lat2;
1022 wpt->longitude = lon2;
1023 wpt->altitude = apt->getElevation();
1025 wpt->crossat = -10000;
1026 wpt->gear_down = true;
1027 wpt->flaps_down= true;
1028 wpt->finished = false;
1029 wpt->on_ground = true;
1030 wpt->routeIndex = 0;
1031 waypoints.push_back(wpt);
1034 wpt->name = "END"; //wpt_node->getStringValue("name", "END");
1035 wpt->latitude = lat;
1036 wpt->longitude = lon;
1037 wpt->altitude = apt->getElevation();
1039 wpt->crossat = -10000;
1040 wpt->gear_down = true;
1041 wpt->flaps_down= true;
1042 wpt->finished = false;
1043 wpt->on_ground = true;
1044 wpt->routeIndex = 0;
1045 waypoints.push_back(wpt);