]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/groundnetwork.cxx
Merge commit 'c8115f516c47fd389b34f59055d3c2e9a6b697e2' into next
[flightgear.git] / src / Airports / groundnetwork.cxx
index 7f82d2da266631c07f482b829b3d3c89954386b2..a6ad1f5c44a8c0f4653d3314814f1cb7e643581e 100644 (file)
@@ -145,13 +145,22 @@ void FGTaxiSegment::unblock(time_t now)
 /***************************************************************************
  * FGTaxiRoute
  **************************************************************************/
-bool FGTaxiRoute::next(PositionedID *nde)
+bool FGTaxiRoute::next(PositionedID *nde, int *rte)
 {
+    if (nodes.size() != (routes.size()) + 1) {
+        SG_LOG(SG_GENERAL, SG_ALERT, "ALERT: Misconfigured TaxiRoute : " << nodes.size() << " " << routes.size());
+        throw sg_range_exception("Misconfigured taxi route");
+    }
     if (currNode == nodes.end())
         return false;
-  
     *nde = *(currNode);
-
+    if (currNode != nodes.begin()) {
+        *rte = *(currRoute);
+        currRoute++;
+    } else {
+        // Handle special case for the first node. 
+        *rte = -1 * *(currRoute);
+    }
     currNode++;
     return true;
 };
@@ -255,7 +264,7 @@ void FGGroundNetwork::init(FGAirport* pr)
       segment->setIndex(index++);
       
       if (segment->oppositeDirection) {
-        continue; // already establish
+        continue; // already established
       }
       
       FGTaxiSegment* opp = findSegment(segment->endNode, segment->startNode);
@@ -469,14 +478,21 @@ FGTaxiRoute FGGroundNetwork::findShortestRoute(PositionedID start, PositionedID
   
     // assemble route from backtrace information
     PositionedIDVec nodes;
+    intVec routes;
     FGTaxiNode *bt = lastNode;
+    
     while (searchData[bt].previousNode != 0) {
         nodes.push_back(bt->guid());
+        FGTaxiSegment *segment = findSegment(searchData[bt].previousNode->guid(), bt->guid());
+        int idx = segment->getIndex();
+        routes.push_back(idx);
         bt = searchData[bt].previousNode;
+        
     }
     nodes.push_back(start);
     reverse(nodes.begin(), nodes.end());
-    return FGTaxiRoute(nodes, searchData[lastNode].score, 0);
+    reverse(routes.begin(), routes.end());
+    return FGTaxiRoute(nodes, routes, searchData[lastNode].score, 0);
 }
 
 /* ATC Related Functions */
@@ -489,7 +505,9 @@ void FGGroundNetwork::announcePosition(int id,
                                        double radius, int leg,
                                        FGAIAircraft * aircraft)
 {
+    
     assert(parent);
+    init(parent);
   
     TrafficVectorIterator i = activeTraffic.begin();
     // Search search if the current id alread has an entry
@@ -1140,7 +1158,6 @@ static void WorldCoordinate(osg::Matrix& obj_pos, double lat,
 
 void FGGroundNetwork::render(bool visible)
 {
-
     SGMaterialLib *matlib = globals->get_matlib();
     if (group) {
         //int nr = ;
@@ -1163,7 +1180,8 @@ void FGGroundNetwork::render(bool visible)
         //for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) {
         //double dx = 0;
         for   (TrafficVectorIterator i = activeTraffic.begin(); i != activeTraffic.end(); i++) {
-            // Handle start point
+            // Handle start point i.e. the segment that is connected to the aircraft itself on the starting end
+            // and to the the first "real" taxi segment on the other end. 
             int pos = i->getCurrentPosition() - 1;
             if (pos >= 0) {
 
@@ -1178,7 +1196,7 @@ void FGGroundNetwork::render(bool visible)
                 double coveredDistance = length * 0.5;
                 SGGeod center;
                 SGGeodesy::direct(start, heading, coveredDistance, center, az2);
-                //cerr << "Active Aircraft : Centerpoint = (" << center.getLatitudeDeg() << ", " << center.getLongitudeDeg() << "). Heading = " << heading << endl;
+                //std::cerr << "Active Aircraft : Centerpoint = (" << center.getLatitudeDeg() << ", " << center.getLongitudeDeg() << "). Heading = " << heading << std::endl;
                 ///////////////////////////////////////////////////////////////////////////////
                 // Make a helper function out of this
                 osg::Matrix obj_pos;
@@ -1242,8 +1260,9 @@ void FGGroundNetwork::render(bool visible)
                 group->addChild( obj_trans );
                 /////////////////////////////////////////////////////////////////////
             } else {
-                //cerr << "BIG FAT WARNING: current position is here : " << pos << endl;
+                //std::cerr << "BIG FAT WARNING: current position is here : " << pos << std::endl;
             }
+            // Next: Draw the other taxi segments. 
             for (intVecIterator j = (i)->getIntentions().begin(); j != (i)->getIntentions().end(); j++) {
                 osg::Matrix obj_pos;
                 int k = (*j)-1;