]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/groundnetwork.cxx
Merge branch 'next' of gitorious.org:fg/flightgear into next
[flightgear.git] / src / Airports / groundnetwork.cxx
index 12faa8515a783aeefcdc1eb591269362b002fca8..a3a3245fe9af7d711be60af249d1cd22abc483d7 100644 (file)
@@ -220,6 +220,7 @@ FGGroundNetwork::FGGroundNetwork()
     count = 0;
     currTraffic = activeTraffic.begin();
     group = 0;
+    version = 0;
     networkInitialized = false;
 
 }
@@ -452,6 +453,28 @@ int FGGroundNetwork::findNearestNode(const SGGeod & aGeod)
     return index;
 }
 
+int FGGroundNetwork::findNearestNodeOnRunway(const SGGeod & aGeod)
+{
+    double minDist = HUGE_VAL;
+    int index = -1;
+
+    for (FGTaxiNodeVectorIterator itr = nodes.begin(); itr != nodes.end();
+            itr++) {
+        if (!((*itr)->getIsOnRunway())) {
+            continue;
+        }
+        double d = SGGeodesy::distanceM(aGeod, (*itr)->getGeod());
+        if (d < minDist) {
+            minDist = d;
+            index = (*itr)->getIndex();
+            //cerr << "Minimum distance of " << minDist << " for index " << index << endl;
+        }
+    }
+
+    return index;
+}
+
+
 int FGGroundNetwork::findNearestNode(double lat, double lon)
 {
     return findNearestNode(SGGeod::fromDeg(lon, lat));