]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/markerbeacon.cxx
Fix some leaks on reset
[flightgear.git] / src / Navaids / markerbeacon.cxx
index 3a49e328056fb4f0cedad3b82c10f3ffee051d17..82726e8e1042293411872f536189f17960a7ff51 100644 (file)
   #include "config.h"
 #endif
 
-#include <simgear/structure/exception.hxx>
-#include <simgear/debug/logstream.hxx>
-
 #include <Navaids/markerbeacon.hxx>
 #include <Airports/runways.hxx>
-#include <Navaids/navdb.hxx>
+#include <Navaids/NavDataCache.hxx>
 
 using std::string;
 
-FGPositioned::Type
-FGMarkerBeaconRecord::mapType(int aTy)
-{
-  switch (aTy) {
-  case 7: return FGPositioned::OM;
-  case 8: return FGPositioned::MM;
-  case 9: return FGPositioned::IM;
-  default:
-    throw sg_range_exception("Got a non-marker-beacon-type", 
-      "FGMarkerBeaconRecord::mapType");
-  }
-}
-
-FGMarkerBeaconRecord*
-FGMarkerBeaconRecord::create(int aTy, const string& aName, const SGGeod& aPos)
+FGMarkerBeaconRecord::FGMarkerBeaconRecord(PositionedID aGuid, Type aTy,
+                                           PositionedID aRunway, const SGGeod& aPos) :
+  FGPositioned(aGuid, aTy, string(), aPos),
+  _runway(aRunway)
 {
-  Type fgpTy = mapType(aTy);
-  FGRunway* runway = getRunwayFromName(aName);
-  SGGeod pos(aPos);
-  // fudge elevation to the runway elevation if it's not specified
-  if (fabs(pos.getElevationFt()) < 0.01) {
-    pos.setElevationFt(runway->elevation());
-  }
-  
-  return new FGMarkerBeaconRecord(fgpTy, runway, pos);
 }
 
-
-FGMarkerBeaconRecord::FGMarkerBeaconRecord(Type aTy, FGRunway* aRunway, const SGGeod& aPos) :
-  FGPositioned(aTy, string(), aPos),
-  _runway(aRunway)
+FGRunwayRef FGMarkerBeaconRecord::runway() const
 {
-}
+    FGPositioned* p = flightgear::NavDataCache::instance()->loadById(_runway);
+    assert(p->type() == FGPositioned::RUNWAY);
+    return static_cast<FGRunway*>(p);
+}
\ No newline at end of file