- for (unsigned int k=0; k<aps.size(); ++k) {
- if (aps[k]->route(aRoute.back(), aRoute)) {
- return true;
- }
- } // of initial approach iteration
-
- SG_LOG(SG_GENERAL, SG_INFO, ident() << ": unable to find transition to runway "
- << aRwy->ident() << ", assume vectors");
-
- WayptRef v(new ATCVectors(NULL, this));
- aRoute.push_back(v);
- return aps.front()->routeFromVectors(aRoute);
-}
-
-pair<flightgear::SID*, WayptRef>
-FGAirport::selectSID(const SGGeod& aDest, FGRunway* aRwy)
-{
- loadProcedures();
-
- WayptRef enroute;
- flightgear::SID* sid = NULL;
- double d = 1e9;
-
- for (unsigned int i=0; i<mSIDs.size(); ++i) {
- if (aRwy && !mSIDs[i]->isForRunway(aRwy)) {
- continue;
- }
-
- WayptRef e = mSIDs[i]->findBestTransition(aDest);
- if (!e) {
- continue; // strange, but let's not worry about it
- }
-
- // assert(e->isFixedPosition());
- double ed = SGGeodesy::distanceM(aDest, e->position());
- if (ed < d) { // new best match
- enroute = e;
- d = ed;
- sid = mSIDs[i];
- }
- } // of SID iteration
-
- if (!mSIDs.empty() && !sid) {
- SG_LOG(SG_GENERAL, SG_INFO, ident() << "selectSID, no SID found (runway="
- << (aRwy ? aRwy->ident() : "no runway preference"));
- }
-
- return std::make_pair(sid, enroute);
-}
-
-pair<STAR*, WayptRef>
-FGAirport::selectSTAR(const SGGeod& aOrigin, FGRunway* aRwy)
-{
- loadProcedures();
-
- WayptRef enroute;
- STAR* star = NULL;
- double d = 1e9;
-
- for (unsigned int i=0; i<mSTARs.size(); ++i) {
- if (!mSTARs[i]->isForRunway(aRwy)) {
- continue;
- }
-
- SG_LOG(SG_GENERAL, SG_INFO, "STAR " << mSTARs[i]->ident() << " is valid for runway");
- WayptRef e = mSTARs[i]->findBestTransition(aOrigin);
- if (!e) {
- continue; // strange, but let's not worry about it
- }
-
- // assert(e->isFixedPosition());
- double ed = SGGeodesy::distanceM(aOrigin, e->position());
- if (ed < d) { // new best match
- enroute = e;
- d = ed;
- star = mSTARs[i];
- }
- } // of STAR iteration
-
- return std::make_pair(star, enroute);
+ SGPropertyNode_ptr rootNode = new SGPropertyNode;
+ readProperties(path.str(), rootNode);
+ readILSData(rootNode);
+ cache->stampCacheFile(path);
+
+// we loaded data, tell the caller it might need to reload things
+ return true;
+}
+
+void FGAirport::readILSData(SGPropertyNode* aRoot)
+{
+ NavDataCache* cache = NavDataCache::instance();
+
+ // find the entry matching the runway
+ SGPropertyNode* runwayNode, *ilsNode;
+ for (int i=0; (runwayNode = aRoot->getChild("runway", i)) != NULL; ++i) {
+ for (int j=0; (ilsNode = runwayNode->getChild("ils", j)) != NULL; ++j) {
+ // must match on both nav-ident and runway ident, to support the following:
+ // - runways with multiple distinct ILS installations (KEWD, for example)
+ // - runways where both ends share the same nav ident (LFAT, for example)
+ PositionedID ils = cache->findILS(guid(), ilsNode->getStringValue("rwy"),
+ ilsNode->getStringValue("nav-id"));
+ if (ils == 0) {
+ SG_LOG(SG_GENERAL, SG_INFO, "reading ILS data for " << ident() <<
+ ", couldn;t find runway/navaid for:" <<
+ ilsNode->getStringValue("rwy") << "/" <<
+ ilsNode->getStringValue("nav-id"));
+ continue;
+ }
+
+ double hdgDeg = ilsNode->getDoubleValue("hdg-deg"),
+ lon = ilsNode->getDoubleValue("lon"),
+ lat = ilsNode->getDoubleValue("lat"),
+ elevM = ilsNode->getDoubleValue("elev-m");
+
+ cache->updateILS(ils, SGGeod::fromDegM(lon, lat, elevM), hdgDeg);
+ } // of ILS iteration
+ } // of runway iteration