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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 **************************************************************************/
21 #include "AIFlightPlan.hxx"
22 #include <simgear/math/sg_geodesy.hxx>
23 #include <Airports/runways.hxx>
25 #include <Environment/environment_mgr.hxx>
26 #include <Environment/environment.hxx>
29 /* FGAIFlightPlan::create()
30 * dynamically create a flight plan for AI traffic, based on data provided by the
31 * Traffic Manager, when reading a filed flightplan failes. (DT, 2004/07/10)
33 * This is the top-level function, and the only one that publicly available.
38 // Check lat/lon values during initialization;
39 void FGAIFlightPlan::create(FGAirport *dep, FGAirport *arr, int legNr, double alt, double speed,
40 double latitude, double longitude, bool firstFlight,
41 double radius, const string& fltType, const string& aircraftType, const string& airline)
43 int currWpt = wpt_iterator - waypoints.begin();
47 //cerr << "Creating Push_Back" << endl;
48 createPushBack(firstFlight,dep, latitude, longitude, radius, fltType, aircraftType, airline);
49 //cerr << "Done" << endl;
52 //cerr << "Creating Taxi" << endl;
53 createTaxi(firstFlight, 1, dep, latitude, longitude, radius, fltType, aircraftType, airline);
56 //cerr << "Creating TAkeoff" << endl;
57 createTakeOff(firstFlight, dep, speed);
60 //cerr << "Creating Climb" << endl;
61 createClimb(firstFlight, dep, speed, alt);
64 //cerr << "Creating Cruise" << endl;
65 createCruise(firstFlight, dep,arr, latitude, longitude, speed, alt);
68 //cerr << "Creating Decent" << endl;
72 //cerr << "Creating Landing" << endl;
76 //cerr << "Creating Taxi 2" << endl;
77 createTaxi(false, 2, arr, latitude, longitude, radius, fltType, aircraftType, airline);
80 //cerr << "Creating Parking" << endl;
85 cerr << "Unknown case: " << legNr << endl;
87 wpt_iterator = waypoints.begin()+currWpt;
91 /*******************************************************************
93 * initialize the Aircraft at the parking location
94 ******************************************************************/
95 void FGAIFlightPlan::createPushBack(bool firstFlight, FGAirport *dep,
99 const string& fltType,
100 const string& aircraftType,
101 const string& airline)
110 //int currWpt = wpt_iterator - waypoints.begin();
111 // Erase all existing waypoints.
114 // We only need to get a valid parking if this is the first leg.
115 // Otherwise use the current aircraft position.
118 if (!(dep->getDynamics()->getAvailableParking(&lat, &lon,
121 aircraftType, airline)))
123 cerr << "Could not find parking " << endl;
128 dep->getDynamics()->getParking(gateId, &lat, &lon, &heading);
131 //heading = getHeading();
136 waypoint *wpt = new waypoint;
139 wpt->longitude = lon;
140 wpt->altitude = dep->getElevation();
142 wpt->crossat = -10000;
143 wpt->gear_down = true;
144 wpt->flaps_down= true;
145 wpt->finished = false;
146 wpt->on_ground = true;
147 waypoints.push_back(wpt);
149 // Add park twice, because it uses park once for initialization and once
150 // to trigger the departure ATC message
151 geo_direct_wgs_84 ( 0, lat, lon, heading,
153 &lat2, &lon2, &az2 );
156 wpt->latitude = lat2;
157 wpt->longitude = lon2;
158 wpt->altitude = dep->getElevation();
160 wpt->crossat = -10000;
161 wpt->gear_down = true;
162 wpt->flaps_down= true;
163 wpt->finished = false;
164 wpt->on_ground = true;
165 waypoints.push_back(wpt);
166 geo_direct_wgs_84 ( 0, lat, lon, heading,
167 radius, // push back one entire aircraft radius
168 &lat2, &lon2, &az2 );
170 wpt->name = "taxiStart";
171 wpt->latitude = lat2;
172 wpt->longitude = lon2;
173 wpt->altitude = dep->getElevation();
175 wpt->crossat = -10000;
176 wpt->gear_down = true;
177 wpt->flaps_down= true;
178 wpt->finished = false;
179 wpt->on_ground = true;
180 waypoints.push_back(wpt);
185 /*******************************************************************
187 * initialize the Aircraft at the parking location
188 ******************************************************************/
189 void FGAIFlightPlan::createTaxi(bool firstFlight, int direction, FGAirport *apt, double latitude, double longitude, double radius, const string& fltType, const string& acType, const string& airline)
196 double lat2, lon2, az2;
200 // Erase all existing waypoints.
201 // wpt_vector_iterator i= waypoints.begin();
203 //int currWpt = wpt_iterator - waypoints.begin();
207 // "NOTE: this is currently fixed to "com" for commercial traffic
208 // Should be changed to be used dynamically to allow "gen" and "mil"
210 apt->getDynamics()->getActiveRunway("com", 1, activeRunway);
211 if (!(globals->get_runways()->search(apt->getId(),
215 cout << "Failed to find runway for " << apt->getId() << endl;
216 // Hmm, how do we handle a potential error like this?
220 //apt->getActiveRunway(string("com"), 1, test);
223 heading = rwy._heading;
224 double azimuth = heading + 180.0;
225 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
226 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
227 rwy._length * SG_FEET_TO_METER * 0.5 - 5.0,
228 &lat2, &lon2, &az2 );
229 if (apt->getDynamics()->getGroundNetwork()->exists())
232 int runwayId = apt->getDynamics()->getGroundNetwork()->findNearestNode(lat2, lon2);
233 //int currId = apt->getGroundNetwork()->findNearestNode(latitude,longitude);
236 // A negative gateId indicates an overflow parking, use a
237 // fallback mechanism for this.
238 // Starting from gate 0 is a bit of a hack...
241 route = apt->getDynamics()->getGroundNetwork()->findShortestRoute(gateId, runwayId);
243 route = apt->getDynamics()->getGroundNetwork()->findShortestRoute(0, runwayId);
245 //cerr << "creating route : ";
246 // No route found: go from gate directly to runway
248 //Add the runway startpoint;
250 wpt->name = "Airport Center";
251 wpt->latitude = latitude;
252 wpt->longitude = longitude;
253 wpt->altitude = apt->getElevation();
255 wpt->crossat = -10000;
256 wpt->gear_down = true;
257 wpt->flaps_down= true;
258 wpt->finished = false;
259 wpt->on_ground = true;
260 waypoints.push_back(wpt);
262 //Add the runway startpoint;
264 wpt->name = "Runway Takeoff";
265 wpt->latitude = lat2;
266 wpt->longitude = lon2;
267 wpt->altitude = apt->getElevation();
269 wpt->crossat = -10000;
270 wpt->gear_down = true;
271 wpt->flaps_down= true;
272 wpt->finished = false;
273 wpt->on_ground = true;
274 waypoints.push_back(wpt);
278 while(route.next(&node))
281 //cerr << "Creating Node: " << node << endl;
282 FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findNode(node);
285 wpt->name = "taxiway"; // fixme: should be the name of the taxiway
286 wpt->latitude = tn->getLatitude();
287 wpt->longitude = tn->getLongitude();
288 wpt->altitude = apt->getElevation(); // should maybe be tn->elev too
290 wpt->crossat = -10000;
291 wpt->gear_down = true;
292 wpt->flaps_down= true;
293 wpt->finished = false;
294 wpt->on_ground = true;
295 waypoints.push_back(wpt);
303 //Add the runway startpoint;
305 wpt->name = "Airport Center";
306 wpt->latitude = apt->getLatitude();
307 wpt->longitude = apt->getLongitude();
308 wpt->altitude = apt->getElevation();
310 wpt->crossat = -10000;
311 wpt->gear_down = true;
312 wpt->flaps_down= true;
313 wpt->finished = false;
314 wpt->on_ground = true;
315 waypoints.push_back(wpt);
317 //Add the runway startpoint;
319 wpt->name = "Runway Takeoff";
320 wpt->latitude = lat2;
321 wpt->longitude = lon2;
322 wpt->altitude = apt->getElevation();
324 wpt->crossat = -10000;
325 wpt->gear_down = true;
326 wpt->flaps_down= true;
327 wpt->finished = false;
328 wpt->on_ground = true;
329 waypoints.push_back(wpt);
330 //wpt = new waypoint;
331 //wpt->finished = false;
332 //waypoints.push_back(wpt); // add one more to prevent a segfault.
338 // "NOTE: this is currently fixed to "com" for commercial traffic
339 // Should be changed to be used dynamically to allow "gen" and "mil"
341 //apt->getActiveRunway("com", 1, name);
342 //if (!(globals->get_runways()->search(apt->getId(),
346 //cout << "Failed to find runway for " << apt->getId() << endl;
347 // Hmm, how do we handle a potential error like this?
351 //apt->getActiveRunway(string("com"), 1, test);
354 //heading = rwy._heading;
355 //double azimuth = heading + 180.0;
356 //while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
357 //geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
358 // rwy._length * SG_FEET_TO_METER * 0.5 - 5.0,
359 // &lat2, &lon2, &az2 );
360 apt->getDynamics()->getAvailableParking(&lat, &lon, &heading, &gateId, radius, fltType, acType, airline);
364 geo_direct_wgs_84 ( 0, lat, lon, heading,
366 &lat2, &lon2, &az2 );
367 double lat3 = (*(waypoints.end()-1))->latitude;
368 double lon3 = (*(waypoints.end()-1))->longitude;
369 cerr << (*(waypoints.end()-1))->name << endl;
370 if (apt->getDynamics()->getGroundNetwork()->exists())
373 int runwayId = apt->getDynamics()->getGroundNetwork()->findNearestNode(lat3, lon3);
374 //int currId = apt->getGroundNetwork()->findNearestNode(latitude,longitude);
377 // A negative gateId indicates an overflow parking, use a
378 // fallback mechanism for this.
379 // Starting from gate 0 is a bit of a hack...
382 route = apt->getDynamics()->getGroundNetwork()->findShortestRoute(runwayId, gateId);
384 route = apt->getDynamics()->getGroundNetwork()->findShortestRoute(runwayId, 0);
386 //cerr << "creating route : ";
387 // No route found: go from gate directly to runway
389 //Add the runway startpoint;
391 wpt->name = "Airport Center";
392 wpt->latitude = latitude;
393 wpt->longitude = longitude;
394 wpt->altitude = apt->getElevation();
396 wpt->crossat = -10000;
397 wpt->gear_down = true;
398 wpt->flaps_down= true;
399 wpt->finished = false;
400 wpt->on_ground = true;
401 waypoints.push_back(wpt);
403 //Add the runway startpoint;
405 wpt->name = "Runway Takeoff";
406 wpt->latitude = lat2;
407 wpt->longitude = lon2;
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 waypoints.push_back(wpt);
419 while(route.next(&node))
422 //cerr << "Creating Node: " << node << endl;
423 FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findNode(node);
426 wpt->name = "taxiway"; // fixme: should be the name of the taxiway
427 wpt->latitude = tn->getLatitude();
428 wpt->longitude = tn->getLongitude();
429 wpt->altitude = apt->getElevation(); // should maybe be tn->elev too
431 wpt->crossat = -10000;
432 wpt->gear_down = true;
433 wpt->flaps_down= true;
434 wpt->finished = false;
435 wpt->on_ground = true;
436 waypoints.push_back(wpt);
444 //Add the runway startpoint;
446 wpt->name = "Airport Center";
447 wpt->latitude = apt->getLatitude();
448 wpt->longitude = apt->getLongitude();
449 wpt->altitude = apt->getElevation();
451 wpt->crossat = -10000;
452 wpt->gear_down = true;
453 wpt->flaps_down= true;
454 wpt->finished = false;
455 wpt->on_ground = true;
456 waypoints.push_back(wpt);
463 // Add the final destination waypoint
465 wpt->name = "Begin Parking"; //apt->getId(); //wpt_node->getStringValue("name", "END");
466 wpt->latitude = lat2;
467 wpt->longitude = lon2;
468 wpt->altitude = apt->getElevation();
470 wpt->crossat = -10000;
471 wpt->gear_down = true;
472 wpt->flaps_down= true;
473 wpt->finished = false;
474 wpt->on_ground = true;
475 waypoints.push_back(wpt);
479 // wpt_iterator = waypoints.begin();
482 //wpt_iterator = waypoints.begin()+currWpt;
485 /*******************************************************************
487 * initialize the Aircraft at the parking location
488 ******************************************************************/
489 void FGAIFlightPlan::createTakeOff(bool firstFlight, FGAirport *apt, double speed)
496 double lat2, lon2, az2;
501 // Erase all existing waypoints.
502 // wpt_vector_iterator i= waypoints.begin();
503 //while(waypoints.begin() != waypoints.end())
506 // waypoints.erase(i);
511 // Get the current active runway, based on code from David Luff
512 // This should actually be unified and extended to include
513 // Preferential runway use schema's
517 // "NOTE: this is currently fixed to "com" for commercial traffic
518 // Should be changed to be used dynamically to allow "gen" and "mil"
520 apt->getDynamics()->getActiveRunway("com", 1, activeRunway);
521 if (!(globals->get_runways()->search(apt->getId(),
525 cout << "Failed to find runway for " << apt->getId() << endl;
526 // Hmm, how do we handle a potential error like this?
530 //apt->getActiveRunway(string("com"), 1, test);
534 heading = rwy._heading;
535 double azimuth = heading + 180.0;
536 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
537 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
538 rwy._length * SG_FEET_TO_METER * 0.5 - 105.0,
539 &lat2, &lon2, &az2 );
542 wpt->latitude = lat2;
543 wpt->longitude = lon2;
544 wpt->altitude = apt->getElevation();
546 wpt->crossat = -10000;
547 wpt->gear_down = true;
548 wpt->flaps_down= true;
549 wpt->finished = false;
550 wpt->on_ground = true;
551 waypoints.push_back(wpt);
557 //Next: the Start of Climb
558 geo_direct_wgs_84 ( 0, lat, lon, heading,
559 2560 * SG_FEET_TO_METER,
560 &lat2, &lon2, &az2 );
564 wpt->latitude = lat2;
565 wpt->longitude = lon2;
566 wpt->altitude = apt->getElevation()+3000;
568 wpt->crossat = -10000;
569 wpt->gear_down = true;
570 wpt->flaps_down= true;
571 wpt->finished = false;
572 wpt->on_ground = false;
573 waypoints.push_back(wpt);
574 // waypoints.push_back(wpt);
575 //waypoints.push_back(wpt); // add one more to prevent a segfault.
576 // wpt_iterator = waypoints.begin();
581 /*******************************************************************
583 * initialize the Aircraft at the parking location
584 ******************************************************************/
585 void FGAIFlightPlan::createClimb(bool firstFlight, FGAirport *apt, double speed, double alt)
592 double lat2, lon2, az2;
596 // Erase all existing waypoints.
597 // wpt_vector_iterator i= waypoints.begin();
598 //while(waypoints.begin() != waypoints.end())
601 // waypoints.erase(i);
606 // Get the current active runway, based on code from David Luff
607 // This should actually be unified and extended to include
608 // Preferential runway use schema's
612 // "NOTE: this is currently fixed to "com" for commercial traffic
613 // Should be changed to be used dynamically to allow "gen" and "mil"
615 apt->getDynamics()->getActiveRunway("com", 1, activeRunway);
616 if (!(globals->get_runways()->search(apt->getId(),
620 cout << "Failed to find runway for " << apt->getId() << endl;
621 // Hmm, how do we handle a potential error like this?
625 //apt->getActiveRunway(string("com"), 1, test);
630 heading = rwy._heading;
631 double azimuth = heading + 180.0;
632 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
633 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
635 &lat2, &lon2, &az2 );
637 wpt->name = "10000ft climb";
638 wpt->latitude = lat2;
639 wpt->longitude = lon2;
640 wpt->altitude = 10000;
642 wpt->crossat = -10000;
643 wpt->gear_down = true;
644 wpt->flaps_down= true;
645 wpt->finished = false;
646 wpt->on_ground = false;
647 waypoints.push_back(wpt);
650 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
652 &lat2, &lon2, &az2 );
654 wpt->name = "18000ft climb";
655 wpt->latitude = lat2;
656 wpt->longitude = lon2;
657 wpt->altitude = 18000;
659 wpt->crossat = -10000;
660 wpt->gear_down = true;
661 wpt->flaps_down= true;
662 wpt->finished = false;
663 wpt->on_ground = false;
664 waypoints.push_back(wpt);
665 //waypoints.push_back(wpt);
666 //waypoints.push_back(wpt); // add one more to prevent a segfault.
667 // wpt_iterator = waypoints.begin();
673 /*******************************************************************
675 * initialize the Aircraft at the parking location
676 ******************************************************************/
677 void FGAIFlightPlan::createCruise(bool firstFlight, FGAirport *dep, FGAirport *arr, double latitude, double longitude, double speed, double alt)
684 double lat2, lon2, az2;
689 // Erase all existing waypoints.
690 // wpt_vector_iterator i= waypoints.begin();
691 //while(waypoints.begin() != waypoints.end())
694 // waypoints.erase(i);
699 wpt->name = "Cruise"; //wpt_node->getStringValue("name", "END");
700 wpt->latitude = latitude;
701 wpt->longitude = longitude;
704 wpt->crossat = -10000;
705 wpt->gear_down = false;
706 wpt->flaps_down= false;
707 wpt->finished = false;
708 wpt->on_ground = false;
709 waypoints.push_back(wpt);
710 //Beginning of Decent
713 // should be changed dynamically to allow "gen" and "mil"
714 arr->getDynamics()->getActiveRunway("com", 2, activeRunway);
715 if (!(globals->get_runways()->search(arr->getId(),
719 cout << "Failed to find runway for " << arr->getId() << endl;
720 // Hmm, how do we handle a potential error like this?
724 //arr->getActiveRunway(string("com"), 1, test);
727 //cerr << "Altitude = " << alt << endl;
728 //cerr << "Done" << endl;
729 //if (arr->getId() == "EHAM")
731 // cerr << "Creating cruise to EHAM " << latitude << " " << longitude << endl;
733 heading = rwy._heading;
734 azimuth = heading + 180.0;
735 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
738 // Note: This places us at the location of the active
739 // runway during initial cruise. This needs to be
741 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
743 &lat2, &lon2, &az2 );
745 wpt->name = "BOD"; //wpt_node->getStringValue("name", "END");
746 wpt->latitude = lat2;
747 wpt->longitude = lon2;
751 wpt->gear_down = false;
752 wpt->flaps_down= false;
753 wpt->finished = false;
754 wpt->on_ground = false;
755 waypoints.push_back(wpt);
756 //waypoints.push_back(wpt);
757 //waypoints.push_back(wpt); // add one more to prevent a segfault.
758 //wpt_iterator = waypoints.begin();
763 /*******************************************************************
765 * initialize the Aircraft at the parking location
766 ******************************************************************/
767 void FGAIFlightPlan::createDecent(FGAirport *apt)
770 // Ten thousand ft. Slowing down to 240 kts
776 double lat2, lon2, az2;
781 //// Erase all existing waypoints.
782 // wpt_vector_iterator i= waypoints.begin();
783 //while(waypoints.begin() != waypoints.end())
786 // waypoints.erase(i);
790 //Beginning of Decent
792 // allow "mil" and "gen" as well
793 apt->getDynamics()->getActiveRunway("com", 2, activeRunway);
794 if (!(globals->get_runways()->search(apt->getId(),
798 cout << "Failed to find runway for " << apt->getId() << endl;
799 // Hmm, how do we handle a potential error like this?
803 //apt->getActiveRunway(string("com"), 1, test);
806 //cerr << "Done" << endl;
807 heading = rwy._heading;
808 azimuth = heading + 180.0;
809 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
813 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
815 &lat2, &lon2, &az2 );
818 wpt->name = "Dec 10000ft"; //wpt_node->getStringValue("name", "END");
819 wpt->latitude = lat2;
820 wpt->longitude = lon2;
821 wpt->altitude = apt->getElevation();
823 wpt->crossat = 10000;
824 wpt->gear_down = false;
825 wpt->flaps_down= false;
826 wpt->finished = false;
827 wpt->on_ground = false;
828 waypoints.push_back(wpt);
830 // Three thousand ft. Slowing down to 160 kts
831 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
833 &lat2, &lon2, &az2 );
835 wpt->name = "DEC 3000ft"; //wpt_node->getStringValue("name", "END");
836 wpt->latitude = lat2;
837 wpt->longitude = lon2;
838 wpt->altitude = apt->getElevation();
841 wpt->gear_down = true;
842 wpt->flaps_down= true;
843 wpt->finished = false;
844 wpt->on_ground = false;
845 waypoints.push_back(wpt);
846 //waypoints.push_back(wpt);
847 //waypoints.push_back(wpt); // add one more to prevent a segfault.
848 //wpt_iterator = waypoints.begin();
850 //if (apt->getId() == "EHAM")
852 // cerr << "Created Decend to EHAM " << lat2 << " " << lon2 << ": Runway = " << rwy._rwy_no
853 // << "heading " << heading << endl;
856 /*******************************************************************
858 * initialize the Aircraft at the parking location
859 ******************************************************************/
860 void FGAIFlightPlan::createLanding(FGAirport *apt)
862 // Ten thousand ft. Slowing down to 240 kts
868 double lat2, lon2, az2;
874 heading = rwy._heading;
875 azimuth = heading + 180.0;
876 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
879 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
880 rwy._length*0.45 * SG_FEET_TO_METER,
881 &lat2, &lon2, &az2 );
883 wpt->name = "Threshold"; //wpt_node->getStringValue("name", "END");
884 wpt->latitude = lat2;
885 wpt->longitude = lon2;
886 wpt->altitude = apt->getElevation();
888 wpt->crossat = apt->getElevation();
889 wpt->gear_down = true;
890 wpt->flaps_down= true;
891 wpt->finished = false;
892 wpt->on_ground = true;
893 waypoints.push_back(wpt);
895 //Full stop at the runway centerpoint
896 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
898 &lat2, &lon2, &az2 );
900 wpt->name = "Center"; //wpt_node->getStringValue("name", "END");
901 wpt->latitude = rwy._lat;
902 wpt->longitude = rwy._lon;
903 wpt->altitude = apt->getElevation();
905 wpt->crossat = -10000;
906 wpt->gear_down = true;
907 wpt->flaps_down= true;
908 wpt->finished = false;
909 wpt->on_ground = true;
910 waypoints.push_back(wpt);
912 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
913 rwy._length*0.45 * SG_FEET_TO_METER,
914 &lat2, &lon2, &az2 );
916 wpt->name = "Threshold"; //wpt_node->getStringValue("name", "END");
917 wpt->latitude = lat2;
918 wpt->longitude = lon2;
919 wpt->altitude = apt->getElevation();
921 wpt->crossat = apt->getElevation();
922 wpt->gear_down = true;
923 wpt->flaps_down= true;
924 wpt->finished = false;
925 wpt->on_ground = true;
926 waypoints.push_back(wpt);
927 //waypoints.push_back(wpt);
928 //waypoints.push_back(wpt); // add one more to prevent a segfault.
929 //wpt_iterator = waypoints.begin();
932 //if (apt->getId() == "EHAM")
934 // cerr << "Created Landing to EHAM " << lat2 << " " << lon2 << ": Runway = " << rwy._rwy_no
935 // << "heading " << heading << endl;
939 /*******************************************************************
941 * initialize the Aircraft at the parking location
942 ******************************************************************/
943 void FGAIFlightPlan::createParking(FGAirport *apt)
949 apt->getDynamics()->getParking(gateId, &lat, &lon, &heading);
954 // Erase all existing waypoints.
955 // wpt_vector_iterator i= waypoints.begin();
956 //while(waypoints.begin() != waypoints.end())
959 // waypoints.erase(i);
962 // And finally one more named "END"
964 wpt->name = "END"; //wpt_node->getStringValue("name", "END");
966 wpt->longitude = lon;
969 wpt->crossat = -10000;
970 wpt->gear_down = true;
971 wpt->flaps_down= true;
972 wpt->finished = false;
973 wpt->on_ground = true;
974 waypoints.push_back(wpt);
975 //waypoints.push_back(wpt);
976 //waypoints.push_back(wpt); // add one more to prevent a segfault.
977 //wpt_iterator = waypoints.begin();