- } else {
- if (firstFlight) {
-
- if (!(dep->getDynamics()->getAvailableParking(&lat, &lon,
- &heading, &gateId,
- radius, fltType,
- aircraftType, airline))) {
- SG_LOG(SG_INPUT, SG_WARN, "Warning: Could not find parking for a " <<
- aircraftType <<
- " of flight type " << fltType <<
- " of airline " << airline <<
- " at airport " << dep->getId());
- return false;
- char buffer[10];
- snprintf (buffer, 10, "%d", gateId);
- //FGTaxiNode *tn = dep->getDynamics()->getGroundNetwork()->findNode(node);
- waypoint *wpt;
- wpt = new waypoint;
- wpt->name = string(buffer); // fixme: should be the name of the taxiway
- wpt->latitude = lat;
- wpt->longitude = lon;
- // Elevation is currently disregarded when on_ground is true
- // because the AIModel obtains a periodic ground elevation estimate.
- wpt->altitude = dep->getElevation();
- wpt->speed = vTaxiBackward;
- wpt->crossat = -10000;
- wpt->gear_down = true;
- wpt->flaps_down= true;
- wpt->finished = false;
- wpt->on_ground = true;
- wpt->routeIndex = -1;
- waypoints.push_back(wpt);
- }
- //cerr << "Success : GateId = " << gateId << endl;
- SG_LOG(SG_INPUT, SG_WARN, "Warning: Succesfully found a parking for a " <<
- aircraftType <<
- " of flight type " << fltType <<
- " of airline " << airline <<
- " at airport " << dep->getId());
- } else {
- //cerr << "Push Back follow-up Flight" << endl;
- dep->getDynamics()->getParking(gateId, &lat, &lon, &heading);
- }
- if (gateId < 0) {
- createPushBackFallBack(ac, firstFlight, dep, latitude, longitude,
- radius, fltType, aircraftType, airline);
- return true;
-
- }
- //cerr << "getting parking " << gateId;
- //cerr << " for a " <<
- // aircraftType <<
- // " of flight type " << fltType <<
- // " of airline " << airline <<
- // " at airport " << dep->getId() << endl;
- FGParking *parking = dep->getDynamics()->getParking(gateId);
- int pushBackNode = parking->getPushBackPoint();
-
-
- pushBackRoute = parking->getPushBackRoute();
- if ((pushBackNode > 0) && (pushBackRoute == 0)) {
- int node, rte;
- FGTaxiRoute route;
- //cerr << "Creating push-back for " << gateId << " (" << parking->getName() << ") using push-back point " << pushBackNode << endl;
- route = dep->getDynamics()->getGroundNetwork()->findShortestRoute(gateId, pushBackNode, false);
- parking->setPushBackRoute(new FGTaxiRoute(route));
-
-
- pushBackRoute = parking->getPushBackRoute();
- int size = pushBackRoute->size();
- if (size < 2) {
- SG_LOG(SG_GENERAL, SG_WARN, "Push back route from gate " << gateId << " has only " << size << " nodes.");
- SG_LOG(SG_GENERAL, SG_WARN, "Using " << pushBackNode);
- }
- pushBackRoute->first();
- waypoint *wpt;
- while(pushBackRoute->next(&node, &rte))
- {
- //FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findSegment(node)->getEnd();
- char buffer[10];
- snprintf (buffer, 10, "%d", node);
- FGTaxiNode *tn = dep->getDynamics()->getGroundNetwork()->findNode(node);
- //ids.pop_back();
- wpt = new waypoint;
- wpt->name = string(buffer); // fixme: should be the name of the taxiway
- wpt->latitude = tn->getLatitude();
- wpt->longitude = tn->getLongitude();
- // Elevation is currently disregarded when on_ground is true
- // because the AIModel obtains a periodic ground elevation estimate.
- wpt->altitude = dep->getElevation();
- wpt->speed = vTaxiBackward;
- wpt->crossat = -10000;
- wpt->gear_down = true;
- wpt->flaps_down= true;
- wpt->finished = false;
- wpt->on_ground = true;
- wpt->routeIndex = rte;
- waypoints.push_back(wpt);
- }
- // some special considerations for the last point:
- wpt->name = string("PushBackPoint");
- wpt->speed = vTaxi;
- //for (wpt_vector_iterator i = waypoints.begin(); i != waypoints.end(); i++) {
- // cerr << "Waypoint Name: " << (*i)->name << endl;
- //}
- } else {
- /*
- string rwyClass = getRunwayClassFromTrafficType(fltType);
-
- // Only set this if it hasn't been set by ATC already.
- if (activeRunway.empty()) {
- //cerr << "Getting runway for " << ac->getTrafficRef()->getCallSign() << " at " << apt->getId() << endl;
- double depHeading = ac->getTrafficRef()->getCourse();
- dep->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway,
- depHeading);
- }
- rwy = dep->getRunwayByIdent(activeRunway);
- SGGeod runwayTakeoff = rwy->pointOnCenterline(5.0);
-
- FGGroundNetwork *gn = dep->getDynamics()->getGroundNetwork();
- if (!gn->exists()) {
- createDefaultTakeoffTaxi(ac, dep, rwy);
- return true;
- }
- int runwayId = gn->findNearestNode(runwayTakeoff);
- int node = 0;
- // Find out which node to start from
- FGParking *park = dep->getDynamics()->getParking(gateId);
- if (park) {
- node = park->getPushBackPoint();
- }