]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/route.cxx
Bug #927 - flightplan XML loading.
[flightgear.git] / src / Navaids / route.cxx
index b52a3f5746f60221373bff2ac273b5afcac33abc..9123d24c3059b0cc3cb6698b0d928fead8b7219f 100644 (file)
@@ -237,7 +237,17 @@ WayptRef Waypt::createFromProperties(RouteBase* aOwner, SGPropertyNode_ptr aProp
       "Waypt::createFromProperties");
   }
   
-  WayptRef nd(createInstance(aOwner, aProp->getStringValue("type")));
+  try {
+    WayptRef nd(createInstance(aOwner, aProp->getStringValue("type")));
+    nd->initFromProperties(aProp);
+    return nd;
+  } catch (sg_exception& e) {
+    SG_LOG(SG_GENERAL, SG_WARN, "failed to create waypoint, trying basic:" << e.getMessage());
+  }
+  
+// if we failed to make the waypoint, try again making a basic waypoint.
+// this handles the case where a navaid waypoint is missing, for example
+  WayptRef nd(new BasicWaypt(aOwner));
   nd->initFromProperties(aProp);
   return nd;
 }
@@ -330,7 +340,7 @@ void RouteBase::dumpRouteToKML(const WayptVec& aRoute, const std::string& aName)
   std::fstream f;
   f.open(p.str().c_str(), fstream::out | fstream::app);
   if (!f.is_open()) {
-    SG_LOG(SG_GENERAL, SG_WARN, "unable to open:" << p.str());
+    SG_LOG(SG_NAVAID, SG_WARN, "unable to open:" << p.str());
     return;
   }
   
@@ -376,10 +386,10 @@ void RouteBase::loadAirportProcedures(const SGPath& aPath, FGAirport* aApt)
     NavdataVisitor visitor(aApt, aPath);
     readXML(aPath.str(), visitor);
   } catch (sg_io_exception& ex) {
-    SG_LOG(SG_GENERAL, SG_WARN, "failure parsing procedures: " << aPath.str() <<
+    SG_LOG(SG_NAVAID, SG_WARN, "failure parsing procedures: " << aPath.str() <<
       "\n\t" << ex.getMessage() << "\n\tat:" << ex.getLocation().asString());
   } catch (sg_exception& ex) {
-    SG_LOG(SG_GENERAL, SG_WARN, "failure parsing procedures: " << aPath.str() <<
+    SG_LOG(SG_NAVAID, SG_WARN, "failure parsing procedures: " << aPath.str() <<
       "\n\t" << ex.getMessage());
   }
 }