]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/sidstar.cxx
httpd: provide more airport information in geojson
[flightgear.git] / src / Airports / sidstar.cxx
index cbeac9aed884655699d183336fa3b8497b27ca46..af7a020c958de0b769908283f9b7e878c17ab7db 100644 (file)
 //
 // $Id$
 
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
 #include <iostream>
 #include <stdlib.h>
 
 #include <simgear/props/props.hxx>
 #include <simgear/props/props_io.hxx>
 
-
-
-#include <Airports/simple.hxx>
-
+#include <AIModel/AIFlightPlan.hxx>
+#include <Airports/airport.hxx>
 
 #include "sidstar.hxx"
 
 using std::cerr;
 using std::endl;
+using std::string;
 
 FGSidStar::FGSidStar(FGAirport *ap) {
      id = ap->getId();
@@ -42,7 +45,6 @@ FGSidStar::FGSidStar(FGAirport *ap) {
 
 FGSidStar::FGSidStar(const FGSidStar &other) {
      cerr << "TODO" << endl;
-     exit(1);
 }
 
 void FGSidStar::load(SGPath filename) {
@@ -51,7 +53,7 @@ void FGSidStar::load(SGPath filename) {
   string name;
   try {
       readProperties(filename.str(), &root);
-  } catch (const sg_exception &e) {
+  } catch (const sg_exception &) {
       SG_LOG(SG_GENERAL, SG_ALERT,
        "Error reading AI flight plan: " << filename.str());
        // cout << path.str() << endl;
@@ -69,23 +71,25 @@ void FGSidStar::load(SGPath filename) {
      fp->setName(name);
      SGPropertyNode * wpts_node = fpl_node->getNode("wpts");
      for (int j = 0; j < wpts_node->nChildren(); j++) { 
-          FGAIFlightPlan::waypoint* wpt = new FGAIFlightPlan::waypoint;
+          FGAIWaypoint* wpt = new FGAIWaypoint;
           SGPropertyNode * wpt_node = wpts_node->getChild(j);
           //cerr << "Reading waypoint " << j << wpt_node->getStringValue("name", "END") << endl;
-          wpt->name      = wpt_node->getStringValue("name", "END");
-          wpt->latitude  = wpt_node->getDoubleValue("lat", 0);
-          wpt->longitude = wpt_node->getDoubleValue("lon", 0);
-          wpt->altitude  = wpt_node->getDoubleValue("alt", 0);
-          wpt->speed     = wpt_node->getDoubleValue("ktas", 0);
-          wpt->crossat   = wpt_node->getDoubleValue("crossat", -10000);
-          wpt->gear_down = wpt_node->getBoolValue("gear-down", false);
-          wpt->flaps_down= wpt_node->getBoolValue("flaps-down", false);
-          wpt->on_ground = wpt_node->getBoolValue("on-ground", false);
-          wpt->time_sec   = wpt_node->getDoubleValue("time-sec", 0);
-          wpt->time       = wpt_node->getStringValue("time", "");
-
-          if (wpt->name == "END") wpt->finished = true;
-          else wpt->finished = false;
+          wpt->setName        (wpt_node->getStringValue("name", "END"));
+          wpt->setLatitude    (wpt_node->getDoubleValue("lat", 0));
+          wpt->setLongitude   (wpt_node->getDoubleValue("lon", 0));
+          wpt->setAltitude    (wpt_node->getDoubleValue("alt", 0));
+          wpt->setSpeed       (wpt_node->getDoubleValue("ktas", 0));
+          wpt->setCrossat     (wpt_node->getDoubleValue("crossat", -10000));
+          wpt->setGear_down   (wpt_node->getBoolValue("gear-down", false));
+          wpt->setFlaps_down  (wpt_node->getBoolValue("flaps-down", false));
+          wpt->setOn_ground   (wpt_node->getBoolValue("on-ground", false));
+          wpt->setTime_sec    (wpt_node->getDoubleValue("time-sec", 0));
+          wpt->setTime        (wpt_node->getStringValue("time", ""));
+
+          if (wpt->contains("END")) 
+                wpt->setFinished(true);
+          else 
+                wpt->setFinished(false);
 
           // 
           fp->addWaypoint( wpt );
@@ -113,4 +117,4 @@ FGAIFlightPlan *FGSidStar::getBest(string activeRunway, double heading)
      } else {
         return 0;
     }
-}
\ No newline at end of file
+}