]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/groundnetwork.hxx
Update FGRunway to process information from threshold.xml files.
[flightgear.git] / src / Airports / groundnetwork.hxx
index 425b2d559fa4283ba3f9364ca2d5192031466255..10a78b275abc236cfd547bf229358a9333684243 100644 (file)
 #include <simgear/compiler.h>
 #include <simgear/route/waypoint.hxx>
 
-
-#include STL_STRING
+#include <string>
 #include <vector>
 
-SG_USING_STD(string);
-SG_USING_STD(vector);
+using std::string;
+using std::vector;
 
+#include "gnnode.hxx"
 #include "parking.hxx"
-#include "trafficcontrol.hxx"
-
-
+#include <ATC/trafficcontrol.hxx>
 
 class FGTaxiSegment; // forward reference
 class FGAIFlightPlan; // forward reference
@@ -49,49 +47,6 @@ typedef vector<FGTaxiSegment*>::iterator FGTaxiSegmentVectorIterator;
 //typedef vector<FGTaxiSegment*> FGTaxiSegmentPointerVector;
 //typedef vector<FGTaxiSegment*>::iterator FGTaxiSegmentPointerVectorIterator;
 
-/**************************************************************************************
- * class FGTaxiNode
- *************************************************************************************/
-class FGTaxiNode 
-{
-private:
-  double lat;
-  double lon;
-  int index;
-  FGTaxiSegmentVector next; // a vector of pointers to all the segments leaving from this node
-  
-public:
-  FGTaxiNode();
-  FGTaxiNode(double, double, int);
-
-  void setIndex(int idx)                  { index = idx;};
-  void setLatitude (double val)           { lat = val;};
-  void setLongitude(double val)           { lon = val;};
-  void setLatitude (const string& val)           { lat = processPosition(val);  };
-  void setLongitude(const string& val)           { lon = processPosition(val);  };
-  void addSegment(FGTaxiSegment *segment) { next.push_back(segment); };
-  
-  double getLatitude() { return lat;};
-  double getLongitude(){ return lon;};
-
-  int getIndex() { return index; };
-  FGTaxiNode *getAddress() { return this;};
-  FGTaxiSegmentVectorIterator getBeginRoute() { return next.begin(); };
-  FGTaxiSegmentVectorIterator getEndRoute()   { return next.end();   }; 
-  bool operator<(const FGTaxiNode &other) const { return index < other.index; };
-
-  void sortEndSegments(bool);
-
-  // used in way finding
-  double pathscore;
-  FGTaxiNode* previousnode;
-  FGTaxiSegment* previousseg;
-  
-};
-
-typedef vector<FGTaxiNode*> FGTaxiNodeVector;
-typedef vector<FGTaxiNode*>::iterator FGTaxiNodeVectorIterator;
-
 /***************************************************************************************
  * class FGTaxiSegment
  **************************************************************************************/
@@ -104,6 +59,7 @@ private:
   double course;
   double headingDiff;
   bool isActive;
+  bool isPushBackRoute;
   FGTaxiNode *start;
   FGTaxiNode *end;
   int index;
@@ -112,8 +68,51 @@ private:
  
 
 public:
-  FGTaxiSegment();
-  //FGTaxiSegment(FGTaxiNode *, FGTaxiNode *, int);
+  FGTaxiSegment() :
+      startNode(0),
+      endNode(0),
+      length(0),
+      course(0),
+      headingDiff(0),
+      isActive(0),
+      isPushBackRoute(0),
+      start(0),
+      end(0),
+      index(0),
+      oppositeDirection(0)
+  {
+  };
+
+  FGTaxiSegment         (const FGTaxiSegment &other) :
+      startNode         (other.startNode),
+      endNode           (other.endNode),
+      length            (other.length),
+      course            (other.course),
+      headingDiff       (other.headingDiff),
+      isActive          (other.isActive),
+      isPushBackRoute   (other.isPushBackRoute),
+      start             (other.start),
+      end               (other.end),
+      index             (other.index),
+      oppositeDirection (other.oppositeDirection)
+  {
+  };
+
+  FGTaxiSegment& operator=(const FGTaxiSegment &other)
+  {
+      startNode          = other.startNode;
+      endNode            = other.endNode;
+      length             = other.length;
+      course             = other.course;
+      headingDiff        = other.headingDiff;
+      isActive           = other.isActive;
+      isPushBackRoute    = other.isPushBackRoute;
+      start              = other.start;
+      end                = other.end;
+      index              = other.index;
+      oppositeDirection  = other.oppositeDirection;
+      return *this;
+  };
 
   void setIndex        (int val) { index     = val; };
   void setStartNodeRef (int val) { startNode = val; };
@@ -123,14 +122,19 @@ public:
 
   void setStart(FGTaxiNodeVector *nodes);
   void setEnd  (FGTaxiNodeVector *nodes);
+  void setPushBackType(bool val) { isPushBackRoute = val; };
   void setTrackDistance();
 
   FGTaxiNode * getEnd() { return end;};
   FGTaxiNode * getStart() { return start; };
   double getLength() { return length; };
   int getIndex() { return index; };
+  
+  bool isPushBack() { return isPushBackRoute; };
+
+  int getPenalty(int nGates);
 
- FGTaxiSegment *getAddress() { return this;};
 FGTaxiSegment *getAddress() { return this;};
 
   bool operator<(const FGTaxiSegment &other) const { return index < other.index; };
   bool hasSmallerHeadingDiff (const FGTaxiSegment &other) const { return headingDiff < other.headingDiff; };
@@ -171,6 +175,26 @@ public:
     currNode = nodes.begin();
     depth = dpth;
   };
+
+  FGTaxiRoute& operator= (const FGTaxiRoute &other) {
+    nodes = other.nodes;
+    routes = other.routes;
+    distance = other.distance;
+    depth = other.depth;
+    currNode = nodes.begin();
+    currRoute = routes.begin();
+    return *this;
+  };
+
+  FGTaxiRoute(const FGTaxiRoute& copy) :
+    nodes(copy.nodes),
+    routes(copy.routes),
+    distance(copy.distance),
+    depth(copy.depth),
+    currNode(nodes.begin()),
+    currRoute(routes.begin())
+  {};
+
   bool operator< (const FGTaxiRoute &other) const {return distance < other.distance; };
   bool empty () { return nodes.begin() == nodes.end(); };
   bool next(int *nde); 
@@ -185,10 +209,6 @@ public:
 typedef vector<FGTaxiRoute> TaxiRouteVector;
 typedef vector<FGTaxiRoute>::iterator TaxiRouteVectorIterator;
 
-bool sortByHeadingDiff(FGTaxiSegment *a, FGTaxiSegment *b);
-bool sortByLength     (FGTaxiSegment *a, FGTaxiSegment *b);
-
-
 /**************************************************************************************
  * class FGGroundNetWork
  *************************************************************************************/
@@ -199,28 +219,28 @@ private:
   //int maxDepth;
   int count;
   FGTaxiNodeVector    nodes;
+  FGTaxiNodeVector    pushBackNodes;
   FGTaxiSegmentVector segments;
   //intVec route;
-  intVec nodesStack;
-  intVec routesStack;
+  //intVec nodesStack;
+  //intVec routesStack;
   TaxiRouteVector routes;
   TrafficVector activeTraffic;
   TrafficVectorIterator currTraffic;
-  SGWayPoint destination;
-  
+
   bool foundRoute;
   double totalDistance, maxDistance;
   FGTowerController *towerController;
   FGAirport *parent;
-  
 
-  void printRoutingError(string);
+
+  //void printRoutingError(string);
 
   void checkSpeedAdjustment(int id, double lat, double lon, 
                            double heading, double speed, double alt);
   void checkHoldPosition(int id, double lat, double lon, 
                         double heading, double speed, double alt);
-  
+
 public:
   FGGroundNetwork();
   ~FGGroundNetwork();
@@ -232,17 +252,22 @@ public:
   void init();
   bool exists() { return hasNetwork; };
   void setTowerController(FGTowerController *twrCtrlr) { towerController = twrCtrlr; };
+  
   int findNearestNode(double lat, double lon);
-  FGTaxiNode *findNode(int idx);
-  FGTaxiSegment *findSegment(int idx);
-  FGTaxiRoute findShortestRoute(int start, int end);
+  int findNearestNode(const SGGeod& aGeod);
+  
+  FGTaxiNode *findNode(unsigned idx);
+  FGTaxiSegment *findSegment(unsigned idx);
+  FGTaxiRoute findShortestRoute(int start, int end, bool fullSearch=true);
   //void trace(FGTaxiNode *, int, int, double dist);
 
+  int getNrOfNodes() { return nodes.size(); };
+
   void setParent(FGAirport *par) { parent = par; };
 
   virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute, 
                                double lat, double lon, double hdg, double spd, double alt, 
-                               double radius, int leg, string callsign);
+                               double radius, int leg, FGAIAircraft *aircraft);
   virtual void signOff(int id);
   virtual void update(int id, double lat, double lon, double heading, double speed, double alt, double dt);
   virtual bool hasInstruction(int id);