-
-SGPropertyNode* ilsDataForRunwayAndNavaid(FGRunway* aRunway, const std::string& aNavIdent)
-{
- if (!fgGetBool("/sim/paths/use-custom-scenery-data")) {
- return NULL;
- }
-
- if (!aRunway) {
- return NULL;
- }
-
- FGAirport* apt = aRunway->airport();
-// find (or load) the airprot ILS data
- AirportPropertyMap::iterator it = static_airportIlsData.find(apt);
- if (it == static_airportIlsData.end()) {
- SGPath path;
- if (!XMLLoader::findAirportData(apt->ident(), "ils", path)) {
- // no ils.xml file for this airpot, insert a NULL entry so we don't
- // check again
- static_airportIlsData.insert(it, std::make_pair(apt, SGPropertyNode_ptr()));
- return NULL;
- }
-
- SGPropertyNode_ptr rootNode = new SGPropertyNode;
- readProperties(path.str(), rootNode);
- it = static_airportIlsData.insert(it, std::make_pair(apt, rootNode));
- } // of ils.xml file not loaded
-
- if (!it->second) {
- return NULL;
- }
-
-// find the entry matching the runway
- SGPropertyNode* runwayNode, *ilsNode;
- for (int i=0; (runwayNode = it->second->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)
- if ((ilsNode->getStringValue("nav-id") == aNavIdent) &&
- (ilsNode->getStringValue("rwy") == aRunway->ident()))
- {
- return ilsNode;
- }
- } // of ILS iteration
- } // of runway iteration
-
- return NULL;
-}
-
-FGRunway* getRunwayFromName(const std::string& aName)
-{
- vector<string> parts = simgear::strutils::split(aName);
- if (parts.size() < 2) {
- SG_LOG(SG_GENERAL, SG_WARN, "getRunwayFromName: malformed name:" << aName);
- return NULL;
- }
-
- const FGAirport* apt = fgFindAirportID(parts[0]);
- if (!apt) {
- SG_LOG(SG_GENERAL, SG_WARN, "navaid " << aName << " associated with bogus airport ID:" << parts[0]);
- return NULL;
- }