- 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 {
- //cerr << "Creating direct forward departure route fragment" << endl;
- double lat2 = 0.0, lon2 = 0.0, az2 = 0.0;
- waypoint *wpt;
- geo_direct_wgs_84 ( 0, lat, lon, heading,
- 2, &lat2, &lon2, &az2 );
- wpt = new waypoint;
- wpt->name = "park2";
- wpt->latitude = lat2;
- wpt->longitude = lon2;
- wpt->altitude = dep->getElevation();
- wpt->speed = vTaxiReduced;
- wpt->crossat = -10000;
- wpt->gear_down = true;
- wpt->flaps_down= true;
- wpt->finished = false;
- wpt->on_ground = true;
- wpt->routeIndex = 0;
- waypoints.push_back(wpt);
-
- geo_direct_wgs_84 ( 0, lat, lon, heading,
- 4, &lat2, &lon2, &az2 );
- wpt = new waypoint;
- wpt->name = "name";
- wpt->latitude = lat2;
- wpt->longitude = lon2;
- wpt->altitude = dep->getElevation();
- wpt->speed = vTaxiReduced;
- wpt->crossat = -10000;
- wpt->gear_down = true;
- wpt->flaps_down= true;
- wpt->finished = false;
- wpt->on_ground = true;
- wpt->routeIndex = 0;
- waypoints.push_back(wpt);
-
- //cerr << "Creating final push forward point for gate " << gateId << endl;
- FGTaxiNode *tn = dep->getDynamics()->getGroundNetwork()->findNode(gateId);
- FGTaxiSegmentVectorIterator ts = tn->getBeginRoute();
- FGTaxiSegmentVectorIterator te = tn->getEndRoute();
- if (ts == te) {
- SG_LOG(SG_GENERAL, SG_ALERT, "Gate " << gateId << "doesn't seem to have routes associated with it.");
- //exit(1);
- }
- tn = (*ts)->getEnd();
- lastNodeVisited = tn->getIndex();
- if (tn == NULL) {
- SG_LOG(SG_GENERAL, SG_ALERT, "No valid taxinode found");
- exit(1);
- }
- wpt = new waypoint;
- wpt->name = "PushBackPoint";
- wpt->latitude = tn->getLatitude();
- wpt->longitude = tn->getLongitude();
- wpt->altitude = dep->getElevation();
- wpt->speed = vTaxiReduced;
- wpt->crossat = -10000;
- wpt->gear_down = true;
- wpt->flaps_down= true;
- wpt->finished = false;
- wpt->on_ground = true;
- wpt->routeIndex = (*ts)->getIndex();
- waypoints.push_back(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;
+ SGGeod coord = coord.fromDeg(tn->getLongitude(), tn->getLatitude());
+ FGAIWaypoint *wpt = createOnGround(ac, string(buffer), coord, dep->getElevation(), vTaxiBackward);
+
+ wpt->setRouteIndex(rte);
+ pushBackWaypoint(wpt);
+ }
+ // some special considerations for the last point:
+ waypoints.back()->setName(string("PushBackPoint"));
+ waypoints.back()->setSpeed(vTaxi);
+ ac->setTaxiClearanceRequest(true);
+ } else { // In case of a push forward departure...
+ ac->setTaxiClearanceRequest(false);
+ double lat2 = 0.0, lon2 = 0.0, az2 = 0.0;
+
+ //cerr << "Creating final push forward point for gate " << gateId << endl;
+ FGTaxiNode *tn = dep->getDynamics()->getGroundNetwork()->findNode(gateId);
+ FGTaxiSegmentVectorIterator ts = tn->getBeginRoute();
+ FGTaxiSegmentVectorIterator te = tn->getEndRoute();
+ // if the starting node equals the ending node, then there aren't any routes for this parking.
+ // in cases like these we should flag the gate as being inoperative and return false
+ if (ts == te) {
+ SG_LOG(SG_GENERAL, SG_ALERT, "Gate " << gateId << "doesn't seem to have routes associated with it.");
+ parking->setAvailable(false);
+ return false;
+ }
+ tn = (*ts)->getEnd();
+ lastNodeVisited = tn->getIndex();
+ if (tn == NULL) {
+ SG_LOG(SG_GENERAL, SG_ALERT, "No valid taxinode found");
+ exit(1);
+ }
+ double distance = (*ts)->getLength();
+ //cerr << "Length of push forward route = " << distance << " and heading is " << heading << endl;
+ lat2 = tn->getLatitude();
+ lon2 = tn->getLongitude();
+
+ for (int i = 1; i < 10; i++) {
+ geo_direct_wgs_84 ( 0, lat, lon, heading,
+ ((i / 10.0) * distance), &lat2, &lon2, &az2 );
+ char buffer[16];
+ snprintf(buffer, 16, "pushback-%02d", i);
+ SGGeod coord = coord.fromDeg(lon2, lat2);
+ //cerr << i << endl;
+ FGAIWaypoint *wpt = createOnGround(ac, string(buffer), coord, dep->getElevation(), vTaxiReduced);
+
+ wpt->setRouteIndex((*ts)->getIndex());
+ pushBackWaypoint(wpt);
+ }
+ // cerr << "Done " << endl;
+ waypoints.back()->setName(string("PushBackPoint"));
+ // cerr << "Done assinging new name" << endl;