]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/LevelDXML.cxx
Interim windows build fix
[flightgear.git] / src / Navaids / LevelDXML.cxx
index 49ab15d3f0f6db0e44a49d5e9e15281c6277b72e..6f28c34a93fc8d057ed1e5e71ecd3eaa37b0f34c 100644 (file)
@@ -10,7 +10,7 @@
 #include <simgear/misc/sg_path.hxx>
 
 #include <Navaids/waypoint.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 
 using std::string;
 using std::vector;
@@ -69,6 +69,8 @@ void NavdataVisitor::startElement(const char* name, const XMLAttributes &atts)
     _speed = 0.0;
     _altRestrict = RESTRICT_NONE;
     _altitude = 0.0;
+    _overflightWaypt = false; // default to Fly-by
+    _courseFlag = false; // default to heading
   } else if (tag == "Approach") {
     _ident = atts.getValue("Name");
     _waypoints.clear();
@@ -86,7 +88,7 @@ void NavdataVisitor::startElement(const char* name, const XMLAttributes &atts)
     _transition = new Transition(_transIdent, PROCEDURE_RUNWAY_TRANSITION, _procedure);
     _transWaypts.clear();
   } else {
-    
+    // nothing here, we warn on unrecognized in endElement
   }
 }
 
@@ -193,14 +195,24 @@ void NavdataVisitor::endElement(const char* name)
     _holdRighthanded = (_text == "Right");
   } else if (tag == "Hld_td_value") {
     _holdTD = atof(_text.c_str());
+  } else if (tag == "Hdg_Crs") {
+    _courseFlag = atoi(_text.c_str());
   } else if (tag == "Hdg_Crs_value") {
-    _course = atof(_text.c_str());
+    _courseOrHeading = atof(_text.c_str());
   } else if (tag == "DMEtoIntercept") {
     _dmeDistance = atof(_text.c_str());
   } else if (tag == "RadialtoIntercept") {
     _radial = atof(_text.c_str());
+  } else if (tag == "Flytype") {
+    // values are 'Fly-by' and 'Fly-over'
+    _overflightWaypt = (_text == "Fly-over");
+  } else if ((tag == "AltitudeCons") ||
+             (tag == "BankLimit") ||
+             (tag == "Sp_Turn"))
+  {
+    // ignored but don't warn
   } else {
-    
+    SG_LOG(SG_IO, SG_INFO, "unrecognized Level-D XML element:" << tag);
   }
 }
 
@@ -238,19 +250,19 @@ Waypt* NavdataVisitor::buildWaypoint(RouteBase* owner)
     wp = new ATCVectors(owner, _airport);
   } else if ((_wayptType == "Intc") || (_wayptType == "VorRadialIntc")) {
     SGGeod pos(SGGeod::fromDeg(_longitude, _latitude));
-    wp = new RadialIntercept(owner, _wayptName, pos, _course, _radial);
+    wp = new RadialIntercept(owner, _wayptName, pos, _courseOrHeading, _radial);
   } else if (_wayptType == "DmeIntc") {
     SGGeod pos(SGGeod::fromDeg(_longitude, _latitude));
-    wp = new DMEIntercept(owner, _wayptName, pos, _course, _dmeDistance);
+    wp = new DMEIntercept(owner, _wayptName, pos, _courseOrHeading, _dmeDistance);
   } else if (_wayptType == "ConstHdgtoAlt") {
-    wp = new HeadingToAltitude(owner, _wayptName, _course);
+    wp = new HeadingToAltitude(owner, _wayptName, _courseOrHeading);
   } else if (_wayptType == "PBD") {
     SGGeod pos(SGGeod::fromDeg(_longitude, _latitude)), pos2;
     double az2;
-    SGGeodesy::direct(pos, _course, _dmeDistance, pos2, az2);
+    SGGeodesy::direct(pos, _courseOrHeading, _dmeDistance, pos2, az2);
     wp = new BasicWaypt(pos2, _wayptName, owner);
   } else {
-    SG_LOG(SG_GENERAL, SG_ALERT, "implement waypoint type:" << _wayptType);
+    SG_LOG(SG_NAVAID, SG_ALERT, "implement waypoint type:" << _wayptType);
     throw sg_format_exception("Unrecognized waypt type", _wayptType);
   }
   
@@ -263,6 +275,10 @@ Waypt* NavdataVisitor::buildWaypoint(RouteBase* owner)
     wp->setSpeed(_speed, RESTRICT_AT); // or _BELOW?
   }
   
+  if (_overflightWaypt) {
+    wp->setFlag(WPT_OVERFLIGHT);
+  }
+  
   return wp;
 }
 
@@ -327,11 +343,11 @@ void NavdataVisitor::pi (const char * target, const char * data) {
 }
 
 void NavdataVisitor::warning (const char * message, int line, int column) {
-  SG_LOG(SG_IO, SG_WARN, "Warning: " << message << " (" << line << ',' << column << ')');
+  SG_LOG(SG_NAVAID, SG_WARN, "Warning: " << message << " (" << line << ',' << column << ')');
 }
 
 void NavdataVisitor::error (const char * message, int line, int column) {
-  SG_LOG(SG_IO, SG_ALERT, "Error: " << message << " (" << line << ',' << column << ')');
+  SG_LOG(SG_NAVAID, SG_ALERT, "Error: " << message << " (" << line << ',' << column << ')');
 }
 
 }