X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAirports%2Fgroundnetwork.hxx;h=a70fa2c099c2b78384517af64a07e4a603902a06;hb=49030e700ba276d5cd6ffa4f4e661a266fa0105c;hp=52b91ed0bd8382c3f9ebfa882ef338172526ffa8;hpb=c9813d1b5d79b4aad13c263690a0223086af25ac;p=flightgear.git diff --git a/src/Airports/groundnetwork.hxx b/src/Airports/groundnetwork.hxx index 52b91ed0b..a70fa2c09 100644 --- a/src/Airports/groundnetwork.hxx +++ b/src/Airports/groundnetwork.hxx @@ -24,54 +24,28 @@ #ifndef _GROUNDNETWORK_HXX_ #define _GROUNDNETWORK_HXX_ -#include STL_STRING +#include +#include + +#include #include -SG_USING_STD(string); -SG_USING_STD(vector); +using std::string; +using std::vector; +#include "gnnode.hxx" #include "parking.hxx" +#include class FGTaxiSegment; // forward reference +class FGAIFlightPlan; // forward reference +class FGAirport; // forward reference -typedef vector FGTaxiSegmentVector; -typedef vector FGTaxiSegmentPointerVector; -typedef vector::iterator FGTaxiSegmentVectorIterator; -typedef vector::iterator FGTaxiSegmentPointerVectorIterator; - -/************************************************************************************** - * class FGTaxiNode - *************************************************************************************/ -class FGTaxiNode -{ -private: - double lat; - double lon; - int index; - FGTaxiSegmentPointerVector next; // a vector 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;}; +typedef vector FGTaxiSegmentVector; +typedef vector::iterator FGTaxiSegmentVectorIterator; - int getIndex() { return index; }; - FGTaxiNode *getAddress() { return this;}; - FGTaxiSegmentPointerVectorIterator getBeginRoute() { return next.begin(); }; - FGTaxiSegmentPointerVectorIterator getEndRoute() { return next.end(); }; -}; - -typedef vector FGTaxiNodeVector; -typedef vector::iterator FGTaxiNodeVectorIterator; +//typedef vector FGTaxiSegmentPointerVector; +//typedef vector::iterator FGTaxiSegmentPointerVectorIterator; /*************************************************************************************** * class FGTaxiSegment @@ -82,48 +56,154 @@ private: int startNode; int endNode; double length; + double course; + double headingDiff; + bool isActive; + bool isPushBackRoute; FGTaxiNode *start; FGTaxiNode *end; int index; + FGTaxiSegment *oppositeDirection; + + 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; }; 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; }; 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;}; + + bool operator<(const FGTaxiSegment &other) const { return index < other.index; }; + bool hasSmallerHeadingDiff (const FGTaxiSegment &other) const { return headingDiff < other.headingDiff; }; + FGTaxiSegment *opposite() { return oppositeDirection; }; + void setCourseDiff(double crse); + }; + + typedef vector intVec; typedef vector::iterator intVecIterator; + + +/*************************************************************************************** + * class FGTaxiRoute + **************************************************************************************/ class FGTaxiRoute { private: intVec nodes; + intVec routes; double distance; + int depth; intVecIterator currNode; + intVecIterator currRoute; public: - FGTaxiRoute() { distance = 0; currNode = nodes.begin(); }; - FGTaxiRoute(intVec nds, double dist) { nodes = nds; distance = dist; currNode = nodes.begin();}; + FGTaxiRoute() { distance = 0; currNode = nodes.begin(); currRoute = routes.begin();}; + FGTaxiRoute(intVec nds, intVec rts, double dist, int dpth) { + nodes = nds; + routes = rts; + distance = dist; + 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 *val); + bool next(int *nde); + bool next(int *nde, int *rte); + void rewind(int legNr); - void first() { currNode = nodes.begin(); }; + void first() { currNode = nodes.begin(); currRoute = routes.begin(); }; + int size() { return nodes.size(); }; + int getDepth() { return depth; }; }; typedef vector TaxiRouteVector; @@ -132,21 +212,39 @@ typedef vector::iterator TaxiRouteVectorIterator; /************************************************************************************** * class FGGroundNetWork *************************************************************************************/ -class FGGroundNetwork +class FGGroundNetwork : public FGATCController { private: bool hasNetwork; + //int maxDepth; + int count; FGTaxiNodeVector nodes; + FGTaxiNodeVector pushBackNodes; FGTaxiSegmentVector segments; //intVec route; - intVec traceStack; + //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 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(); void addNode (const FGTaxiNode& node); void addNodes (FGParkingVec *parkings); @@ -154,11 +252,27 @@ public: void init(); bool exists() { return hasNetwork; }; + void setTowerController(FGTowerController *twrCtrlr) { towerController = twrCtrlr; }; int findNearestNode(double lat, double lon); FGTaxiNode *findNode(int idx); - FGTaxiRoute findShortestRoute(int start, int end); - void trace(FGTaxiNode *, int, int, double dist); - + FGTaxiSegment *findSegment(int 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, 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); + virtual FGATCInstruction getInstruction(int id); + + bool checkForCircularWaits(int id); }; + #endif