]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/markerbeacon.cxx
Prepare and implement reinit methods for instruments
[flightgear.git] / src / Navaids / markerbeacon.cxx
index 9eaeff2cd27dac67395fa29fad514911f94fedbe..0af44c3a4c812cbb2eb0ba254048ab72597f1682 100644 (file)
 #include <simgear/structure/exception.hxx>
 #include <simgear/debug/logstream.hxx>
 
-#include "Navaids/markerbeacon.hxx"
-#include "Airports/runways.hxx"
-#include "Navaids/navdb.hxx"
+#include <Navaids/markerbeacon.hxx>
+#include <Airports/runways.hxx>
+#include <Navaids/navdb.hxx>
 
 using std::string;
 
 FGPositioned::Type
-FGMarkerBeacon::mapType(int aTy)
+FGMarkerBeaconRecord::mapType(int aTy)
 {
   switch (aTy) {
   case 7: return FGPositioned::OM;
@@ -42,27 +42,33 @@ FGMarkerBeacon::mapType(int aTy)
   case 9: return FGPositioned::IM;
   default:
     throw sg_range_exception("Got a non-marker-beacon-type", 
-      "FGMarkerBeacon::mapType");
+      "FGMarkerBeaconRecord::mapType");
   }
 }
 
-FGMarkerBeacon*
-FGMarkerBeacon::create(int aTy, const string& aName, const SGGeod& aPos)
+FGMarkerBeaconRecord*
+FGMarkerBeaconRecord::create(int aTy, const string& aName, const SGGeod& aPos)
 {
   Type fgpTy = mapType(aTy);
   FGRunway* runway = getRunwayFromName(aName);
+  if (!runway)
+  {
+      SG_LOG(SG_GENERAL, SG_WARN, "Failed to create beacon for unknown runway '" << aName << "'.");
+      return NULL;
+  }
   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 FGMarkerBeacon(fgpTy, runway, pos);
+  return new FGMarkerBeaconRecord(fgpTy, runway, pos);
 }
 
 
-FGMarkerBeacon::FGMarkerBeacon(Type aTy, FGRunway* aRunway, const SGGeod& aPos) :
+FGMarkerBeaconRecord::FGMarkerBeaconRecord(Type aTy, FGRunway* aRunway, const SGGeod& aPos) :
   FGPositioned(aTy, string(), aPos),
   _runway(aRunway)
 {
+  init(true); // init FGPositioned
 }