- //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)) { // Load the already established route for this gate
- 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_AI, SG_WARN, "Push back route from gate " << gateId << " has only " << size << " nodes.");
- SG_LOG(SG_AI, SG_WARN, "Using " << pushBackNode);
- }
- pushBackRoute->first();
- 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_AI, SG_ALERT, "Gate " << gateId << "doesn't seem to have routes associated with it.");
- parking->setAvailable(false);
- return false;
+
+ route.first();
+ PositionedID node, previous= 0;
+
+ while (route.next(&node))
+ {
+ char buffer[10];
+ snprintf (buffer, 10, "%lld", node);
+ FGTaxiNode *tn = groundNet->findNode(node);
+ FGAIWaypoint *wpt = createOnGround(ac, string(buffer), tn->geod(), dep->getElevation(), vTaxiBackward);
+
+ if (previous) {
+ FGTaxiSegment* segment = groundNet->findSegment(previous, node);
+ wpt->setRouteIndex(segment->getIndex());
+ } else {
+ // not on the route yet, make up a unique segment ID
+ int x = (int) tn->guid();
+ wpt->setRouteIndex(x);