+ return cache->insertNavaid(type, string(), name, pos, 0, 0, 0,
+ arp.first, arp.second);
+ }
+
+ if (range < 0.01) {
+ range = defaultNavRange(ident, type);
+ }
+
+ AirportRunwayPair arp;
+ FGRunway* runway = NULL;
+
+ // FIXME - also relate DMEs, but only ILS/LOC DMEs - need a heuristic
+ // on the DME naming string
+ if ((type >= FGPositioned::ILS) && (type <= FGPositioned::GS)) {
+ arp = cache->findAirportRunway(name);
+ if (arp.second) {
+ runway = static_cast<FGRunway*>(cache->loadById(arp.second));
+ assert(runway);
+#if 0
+ // code is disabled since it's causing some problems, see
+ // http://code.google.com/p/flightgear-bugs/issues/detail?id=926
+ if (elev_ft < 0.01) {
+ // snap to runway elevation
+ pos.setElevationFt(runway->geod().getElevationFt());
+ }
+#endif
+ } // of found runway in the DB
+ } // of type is runway-related
+
+ bool isLoc = (type == FGPositioned::ILS) || (type == FGPositioned::LOC);
+ if (runway && autoAlignLocalizers && isLoc) {
+ alignLocaliserWithRunway(runway, ident, pos, multiuse);
+ }
+
+ // silently multiply adf frequencies by 100 so that adf
+ // vs. nav/loc frequency lookups can use the same code.
+ if (type == FGPositioned::NDB) {
+ freq *= 100;
+ }
+
+ PositionedID r = cache->insertNavaid(type, ident, name, pos, freq, range, multiuse,
+ arp.first, arp.second);
+
+ if (isLoc) {
+ cache->setRunwayILS(arp.second, r);
+ }
+
+ return r;
+}
+
+// load and initialize the navigational databases
+bool navDBInit(const SGPath& path)
+{