]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/groundnetwork.cxx
Canvas: Add new element type map for geo mapping.
[flightgear.git] / src / Airports / groundnetwork.cxx
index bf4d24f7ddaff0df524cd9e3982952e203c180c6..a63002eac87ed95e4cb24aee6e6ef4886fa89270 100644 (file)
@@ -35,7 +35,6 @@
 #include <osg/Shape>
 
 #include <simgear/debug/logstream.hxx>
-#include <simgear/route/waypoint.hxx>
 #include <simgear/scene/material/EffectGeode.hxx>
 #include <simgear/scene/material/matlib.hxx>
 #include <simgear/scene/material/mat.hxx>
@@ -531,7 +530,7 @@ FGTaxiNode *FGGroundNetwork::findNode(unsigned idx)
                                    return itr->getAddress();
                                    } */
 
-    if ((idx >= 0) && (idx < nodes.size()))
+    if (idx < nodes.size())
         return nodes[idx]->getAddress();
     else
         return 0;
@@ -580,9 +579,23 @@ FGTaxiRoute FGGroundNetwork::findShortestRoute(int start, int end,
     }
 
     FGTaxiNode *firstNode = findNode(start);
+    if (!firstNode)
+    {
+        SG_LOG(SG_GENERAL, SG_ALERT,
+               "Error in ground network. Failed to find first waypoint: " << start
+               << " at " << ((parent) ? parent->getId() : "<unknown>"));
+        return FGTaxiRoute();
+    }
     firstNode->setPathScore(0);
 
     FGTaxiNode *lastNode = findNode(end);
+    if (!lastNode)
+    {
+        SG_LOG(SG_GENERAL, SG_ALERT,
+               "Error in ground network. Failed to find last waypoint: " << end
+               << " at " << ((parent) ? parent->getId() : "<unknown>"));
+        return FGTaxiRoute();
+    }
 
     FGTaxiNodeVector unvisited(*currNodesSet);  // working copy
 
@@ -606,6 +619,13 @@ FGTaxiRoute FGGroundNetwork::findShortestRoute(int start, int end,
                     seg != best->getEndRoute(); seg++) {
                 if (fullSearch || (*seg)->isPushBack()) {
                     FGTaxiNode *tgt = (*seg)->getEnd();
+                    if (!tgt)
+                    {
+                        SG_LOG(SG_GENERAL, SG_ALERT,
+                               "Error in ground network. Found empty segment "
+                               << " at " << ((parent) ? parent->getId() : "<unknown>"));
+                        return FGTaxiRoute();
+                    }
                     double alt =
                         best->getPathScore() + (*seg)->getLength() +
                         (*seg)->getPenalty(nParkings);
@@ -872,7 +892,7 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
     TrafficVectorIterator current, closest, closestOnNetwork;
     TrafficVectorIterator i = activeTraffic.begin();
     bool otherReasonToSlowDown = false;
-    bool previousInstruction;
+//    bool previousInstruction;
     if (activeTraffic.size()) {
         //while ((i->getId() != id) && (i != activeTraffic.end()))
         while (i != activeTraffic.end()) {
@@ -891,10 +911,10 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
     current = i;
     //closest = current;
 
-    previousInstruction = current->getSpeedAdjustment();
+//    previousInstruction = current->getSpeedAdjustment();
     double mindist = HUGE_VAL;
     if (activeTraffic.size()) {
-        double course, dist, bearing, minbearing, az2;
+        double course, dist, bearing, az2; // minbearing,
         SGGeod curr(SGGeod::fromDegM(lon, lat, alt));
         //TrafficVector iterator closest;
         closest = current;
@@ -916,7 +936,7 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
                 mindist = dist;
                 closest = i;
                 closestOnNetwork = i;
-                minbearing = bearing;
+//                minbearing = bearing;
                 
             }
         }
@@ -940,7 +960,7 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
                     //     << endl;
                     mindist = dist;
                     closest = i;
-                    minbearing = bearing;
+//                    minbearing = bearing;
                     otherReasonToSlowDown = true;
                 }
             }
@@ -1306,7 +1326,7 @@ static void WorldCoordinate(osg::Matrix& obj_pos, double lat,
                             double lon, double elev, double hdg, double slope)
 {
     SGGeod geod = SGGeod::fromDegM(lon, lat, elev);
-    obj_pos = geod.makeZUpFrame();
+    obj_pos = makeZUpFrame(geod);
     // hdg is not a compass heading, but a counter-clockwise rotation
     // around the Z axis
     obj_pos.preMult(osg::Matrix::rotate(hdg * SGD_DEGREES_TO_RADIANS,
@@ -1338,7 +1358,7 @@ void FGGroundNetwork::render(bool visible)
         group = new osg::Group;
         FGScenery * local_scenery = globals->get_scenery();
         // double elevation_meters = 0.0;
-        double elevation_feet = 0.0;
+//        double elevation_feet = 0.0;
         time_t now = time(NULL) + fgGetLong("/sim/time/warp");
         //for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) {
         //double dx = 0;
@@ -1378,7 +1398,7 @@ void FGGroundNetwork::render(bool visible)
                     SGGeod center2 = end;
                     center2.setElevationM(SG_MAX_ELEVATION_M);
                     if (local_scenery->get_elevation_m( center2, elevationEnd, NULL )) {
-                        elevation_feet = elevationEnd * SG_METER_TO_FEET + 0.5;
+//                        elevation_feet = elevationEnd * SG_METER_TO_FEET + 0.5;
                         //elevation_meters += 0.5;
                     }
                     else {
@@ -1438,7 +1458,7 @@ void FGGroundNetwork::render(bool visible)
                         SGGeod center2 = segments[k]->getStart()->getGeod();
                         center2.setElevationM(SG_MAX_ELEVATION_M);
                         if (local_scenery->get_elevation_m( center2, elevationStart, NULL )) {
-                            elevation_feet = elevationStart * SG_METER_TO_FEET + 0.5;
+//                            elevation_feet = elevationStart * SG_METER_TO_FEET + 0.5;
                             //elevation_meters += 0.5;
                         }
                         else {
@@ -1450,7 +1470,7 @@ void FGGroundNetwork::render(bool visible)
                         SGGeod center2 = segments[k]->getEnd()->getGeod();
                         center2.setElevationM(SG_MAX_ELEVATION_M);
                         if (local_scenery->get_elevation_m( center2, elevationEnd, NULL )) {
-                            elevation_feet = elevationEnd * SG_METER_TO_FEET + 0.5;
+//                            elevation_feet = elevationEnd * SG_METER_TO_FEET + 0.5;
                             //elevation_meters += 0.5;
                         }
                         else {