]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/groundnetwork.hxx
Alexis Bory:
[flightgear.git] / src / Airports / groundnetwork.hxx
index cec19d38bfcc666659ca0db819185f03c03dd606..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>
-
-using std::string;
-using std::vector;
+#include <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 std::map<int, FGTaxiNode_ptr> IndexTaxiNodeMap;
+
+class Block
+{
+private:
+    int id;
+    time_t blocktime;
+    time_t touch;
+public:
+    Block(int i, time_t bt, time_t curr) { id = i; blocktime= bt; touch = curr; };
+    ~Block() {};
+    int getId() { return id; };
+    void updateTimeStamps(time_t bt, time_t now) { blocktime = (bt < blocktime) ? bt : blocktime; touch = now; };
+    const time_t getBlockTime() const { return blocktime; };
+    time_t getTimeStamp() { return touch; };
+    bool operator< (const Block &other) const { return blocktime < other.blocktime; };
+};
 
-//typedef vector<FGTaxiSegment*> FGTaxiSegmentPointerVector;
-//typedef vector<FGTaxiSegment*>::iterator FGTaxiSegmentPointerVectorIterator;
+typedef std::vector<Block> BlockList;
+typedef BlockList::iterator BlockListIterator;
 
 /***************************************************************************************
  * class FGTaxiSegment
@@ -64,95 +76,31 @@ private:
     int endNode;
     double length;
     double heading;
-    SGGeod center;
     bool isActive;
     bool isPushBackRoute;
-    bool isBlocked;
+    BlockList blockTimes;
     FGTaxiNode *start;
     FGTaxiNode *end;
     int index;
     FGTaxiSegment *oppositeDirection;
 
-
-
 public:
-    FGTaxiSegment() :
-            startNode(0),
-            endNode(0),
-            length(0),
-            heading(0),
-            isActive(0),
-            isPushBackRoute(0),
-            isBlocked(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),
-            isBlocked         (other.isBlocked),
-            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;
-        isBlocked          = other.isBlocked;
-        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() {
-        isBlocked = true;
-    }
-    void unblock() {
-        isBlocked = false;
-    };
-    bool hasBlock() {
-        return isBlocked;
-    };
+    void block(int id, time_t blockTime, time_t now);
+    void unblock(time_t now); 
+    bool hasBlock(time_t now);
 
     FGTaxiNode * getEnd() {
         return end;
@@ -166,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;
     };
@@ -181,10 +127,6 @@ public:
 
     int getPenalty(int nGates);
 
-    FGTaxiSegment *getAddress() {
-        return this;
-    };
-
     bool operator<(const FGTaxiSegment &other) const {
         return index < other.index;
     };
@@ -192,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;
 
 
 
@@ -278,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
@@ -292,12 +229,13 @@ private:
     time_t nextSave;
     //int maxDepth;
     int count;
-    FGTaxiNodeVector    nodes;
-    FGTaxiNodeVector    pushBackNodes;
+    int version;
+  
+    IndexTaxiNodeMap nodes;
+    FGTaxiNodeVector pushBackNodes;
+  
     FGTaxiSegmentVector segments;
-    //intVec route;
-    //intVec nodesStack;
-    //intVec routesStack;
+
     TaxiRouteVector routes;
     TrafficVector activeTraffic;
     TrafficVectorIterator currTraffic;
@@ -316,14 +254,17 @@ 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; };
 
     void init();
     bool exists() {
@@ -333,8 +274,8 @@ public:
         towerController = twrCtrlr;
     };
 
-    int findNearestNode(double lat, double lon);
     int findNearestNode(const SGGeod& aGeod);
+    int findNearestNodeOnRunway(const SGGeod& aGeod, FGRunway* aRunway = NULL);
 
     FGTaxiNode *findNode(unsigned idx);
     FGTaxiSegment *findSegment(unsigned idx);
@@ -361,10 +302,11 @@ 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();
+    void addVersion(int v) {version = v; };
 };