]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/groundnetwork.hxx
Alexis Bory:
[flightgear.git] / src / Airports / groundnetwork.hxx
index 78f1282d6d1b35ba298519e43afd404c32fb5f80..9b73e2e81d08e7909626e7a3243ead090615d809 100644 (file)
 #ifndef _GROUNDNETWORK_HXX_
 #define _GROUNDNETWORK_HXX_
 
-#include <osg/Geode>
-#include <osg/Geometry>
-#include <osg/MatrixTransform>
-#include <osg/Shape>
-
-
 #include <simgear/compiler.h>
-#include <simgear/route/waypoint.hxx>
 
 #include <string>
 #include <vector>
 #include <list>
-
-class Block;
-using std::string;
-using std::vector;
-using std::list;
+#include <map>
 
 #include "gnnode.hxx"
 #include "parking.hxx"
 #include <ATC/trafficcontrol.hxx>
 
 
+class Block;
+class FGRunway;
 class FGTaxiSegment; // forward reference
 class FGAIFlightPlan; // forward reference
 class FGAirport;      // forward reference
 
-typedef vector<FGTaxiSegment*>  FGTaxiSegmentVector;
-typedef vector<FGTaxiSegment*>::iterator FGTaxiSegmentVectorIterator;
+typedef std::vector<FGTaxiSegment*>  FGTaxiSegmentVector;
+typedef FGTaxiSegmentVector::iterator FGTaxiSegmentVectorIterator;
 
-//typedef vector<FGTaxiSegment*> FGTaxiSegmentPointerVector;
-//typedef vector<FGTaxiSegment*>::iterator FGTaxiSegmentPointerVectorIterator;
+typedef std::map<int, FGTaxiNode_ptr> IndexTaxiNodeMap;
 
 class Block
 {
@@ -73,7 +63,7 @@ public:
     bool operator< (const Block &other) const { return blocktime < other.blocktime; };
 };
 
-typedef vector<Block> BlockList;
+typedef std::vector<Block> BlockList;
 typedef BlockList::iterator BlockListIterator;
 
 /***************************************************************************************
@@ -86,7 +76,6 @@ private:
     int endNode;
     double length;
     double heading;
-    SGGeod center;
     bool isActive;
     bool isPushBackRoute;
     BlockList blockTimes;
@@ -95,75 +84,19 @@ private:
     int index;
     FGTaxiSegment *oppositeDirection;
 
-
-
 public:
-    FGTaxiSegment() :
-            startNode(0),
-            endNode(0),
-            length(0),
-            heading(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),
-            heading           (other.heading),
-            center            (other.center),
-            isActive          (other.isActive),
-            isPushBackRoute   (other.isPushBackRoute),
-            blockTimes        (other.blockTimes),
-            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;
-        heading            = other.heading;
-        center             = other.center;
-        isActive           = other.isActive;
-        isPushBackRoute    = other.isPushBackRoute;
-        blockTimes         = other.blockTimes;
-        start              = other.start;
-        end                = other.end;
-        index              = other.index;
-        oppositeDirection  = other.oppositeDirection;
-        return *this;
-    };
-
+  FGTaxiSegment(int start, int end, bool isPushBack);
+  
     void setIndex        (int val) {
         index     = val;
     };
-    void setStartNodeRef (int val) {
-        startNode = val;
-    };
-    void setEndNodeRef   (int val) {
-        endNode   = val;
-    };
 
     void setOpposite(FGTaxiSegment *opp) {
         oppositeDirection = opp;
     };
 
-    void setStart(FGTaxiNodeVector *nodes);
-    void setEnd  (FGTaxiNodeVector *nodes);
-    void setPushBackType(bool val) {
-        isPushBackRoute = val;
-    };
+    bool bindToNodes(const IndexTaxiNodeMap& nodes);
+  
     void setDimensions(double elevation);
     void block(int id, time_t blockTime, time_t now);
     void unblock(time_t now); 
@@ -181,12 +114,10 @@ public:
     int getIndex() {
         return index;
     };
-    double getLatitude()  {
-        return center.getLatitudeDeg();
-    };
-    double getLongitude() {
-        return center.getLongitudeDeg();
-    };
+  
+    // compute the center of the arc
+    SGGeod getCenter() const;
+  
     double getHeading()   {
         return heading;
     };
@@ -196,10 +127,6 @@ public:
 
     int getPenalty(int nGates);
 
-    FGTaxiSegment *getAddress() {
-        return this;
-    };
-
     bool operator<(const FGTaxiSegment &other) const {
         return index < other.index;
     };
@@ -207,18 +134,13 @@ public:
     FGTaxiSegment *opposite() {
         return oppositeDirection;
     };
-    void setCourseDiff(double crse);
-
-
-
-
 };
 
 
 
 
-typedef vector<int> intVec;
-typedef vector<int>::iterator intVecIterator;
+typedef std::vector<int> intVec;
+typedef std::vector<int>::iterator intVecIterator;
 
 
 
@@ -293,8 +215,8 @@ public:
 //  int getDepth() { return depth; };
 };
 
-typedef vector<FGTaxiRoute> TaxiRouteVector;
-typedef vector<FGTaxiRoute>::iterator TaxiRouteVectorIterator;
+typedef std::vector<FGTaxiRoute> TaxiRouteVector;
+typedef std::vector<FGTaxiRoute>::iterator TaxiRouteVectorIterator;
 
 /**************************************************************************************
  * class FGGroundNetWork
@@ -308,12 +230,12 @@ private:
     //int maxDepth;
     int count;
     int version;
-    FGTaxiNodeVector    nodes;
-    FGTaxiNodeVector    pushBackNodes;
+  
+    IndexTaxiNodeMap nodes;
+    FGTaxiNodeVector pushBackNodes;
+  
     FGTaxiSegmentVector segments;
-    //intVec route;
-    //intVec nodesStack;
-    //intVec routesStack;
+
     TaxiRouteVector routes;
     TrafficVector activeTraffic;
     TrafficVectorIterator currTraffic;
@@ -332,14 +254,14 @@ private:
                            double heading, double speed, double alt);
 
 
-
+    void parseCache();
 public:
     FGGroundNetwork();
     ~FGGroundNetwork();
 
-    void addNode   (const FGTaxiNode& node);
+    void addNode   (FGTaxiNode* node);
     void addNodes  (FGParkingVec *parkings);
-    void addSegment(const FGTaxiSegment& seg);
+    void addSegment(FGTaxiSegment* seg);
     void setVersion (int v) { version = v;};
     
     int getVersion() { return version; };
@@ -352,9 +274,8 @@ public:
         towerController = twrCtrlr;
     };
 
-    int findNearestNode(double lat, double lon);
     int findNearestNode(const SGGeod& aGeod);
-    int findNearestNodeOnRunway(const SGGeod& aGeod);
+    int findNearestNodeOnRunway(const SGGeod& aGeod, FGRunway* aRunway = NULL);
 
     FGTaxiNode *findNode(unsigned idx);
     FGTaxiSegment *findSegment(unsigned idx);
@@ -381,7 +302,7 @@ public:
                                 AtcMsgDir msgDir);
     bool checkForCircularWaits(int id);
     virtual void render(bool);
-    virtual string getName();
+    virtual std::string getName();
     virtual void update(double dt);
 
     void saveElevationCache();