#ifndef _GROUNDNETWORK_HXX_
#define _GROUNDNETWORK_HXX_
-#include <osg/Geode>
-#include <osg/Geometry>
-#include <osg/MatrixTransform>
-#include <osg/Shape>
-
-
#include <simgear/compiler.h>
#include <string>
#include <vector>
#include <list>
-
-class Block;
+#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 std::vector<FGTaxiSegment*> FGTaxiSegmentVector;
-typedef std::vector<FGTaxiSegment*>::iterator FGTaxiSegmentVectorIterator;
+typedef FGTaxiSegmentVector::iterator FGTaxiSegmentVectorIterator;
-//typedef vector<FGTaxiSegment*> FGTaxiSegmentPointerVector;
-//typedef vector<FGTaxiSegment*>::iterator FGTaxiSegmentPointerVectorIterator;
+typedef std::map<int, FGTaxiNode_ptr> IndexTaxiNodeMap;
class Block
{
class FGTaxiSegment
{
private:
- int startNode;
- int endNode;
- double length;
- double heading;
- SGGeod center;
+ const PositionedID startNode;
+ const PositionedID endNode;
+
bool isActive;
- bool isPushBackRoute;
BlockList blockTimes;
- FGTaxiNode *start;
- FGTaxiNode *end;
+
int index;
FGTaxiSegment *oppositeDirection;
-
-
+ friend class FGGroundNetwork;
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(PositionedID start, PositionedID end);
+
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 setDimensions(double elevation);
void block(int id, time_t blockTime, time_t now);
void unblock(time_t now);
bool hasBlock(time_t now);
- FGTaxiNode * getEnd() {
- return end;
- };
- FGTaxiNode * getStart() {
- return start;
- };
- double getLength() {
- return length;
- };
+ FGTaxiNode * getEnd() const;
+ FGTaxiNode * getStart() const;
+
+ double getLength() const;
+
+ // compute the center of the arc
+ SGGeod getCenter() const;
+
+ double getHeading() const;
+
int getIndex() {
- return index;
- };
- double getLatitude() {
- return center.getLatitudeDeg();
- };
- double getLongitude() {
- return center.getLongitudeDeg();
- };
- double getHeading() {
- return heading;
- };
- bool isPushBack() {
- return isPushBackRoute;
+ return index;
};
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);
-
-
-
-
};
class FGTaxiRoute
{
private:
- intVec nodes;
- intVec routes;
+ PositionedIDVec nodes;
double distance;
-// int depth;
- intVecIterator currNode;
- intVecIterator currRoute;
+ PositionedIDVec::iterator currNode;
public:
FGTaxiRoute() {
distance = 0;
currNode = nodes.begin();
- currRoute = routes.begin();
};
- FGTaxiRoute(intVec nds, intVec rts, double dist, int dpth) {
+
+ FGTaxiRoute(const PositionedIDVec& nds, double dist, int dpth) {
nodes = nds;
- routes = rts;
distance = dist;
currNode = nodes.begin();
- currRoute = routes.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())
+ currNode(nodes.begin())
{};
bool operator< (const FGTaxiRoute &other) const {
return distance < other.distance;
};
bool empty () {
- return nodes.begin() == nodes.end();
+ return nodes.empty();
};
- bool next(int *nde);
- bool next(int *nde, int *rte);
- void rewind(int legNr);
-
+ bool next(PositionedID *nde);
+
void first() {
currNode = nodes.begin();
- currRoute = routes.begin();
};
int size() {
return nodes.size();
int nodesLeft() {
return nodes.end() - currNode;
};
-
-// int getDepth() { return depth; };
};
typedef std::vector<FGTaxiRoute> TaxiRouteVector;
//int maxDepth;
int count;
int version;
- FGTaxiNodeVector nodes;
- FGTaxiNodeVector pushBackNodes;
+
FGTaxiSegmentVector segments;
- //intVec route;
- //intVec nodesStack;
- //intVec routesStack;
- TaxiRouteVector routes;
+
TrafficVector activeTraffic;
TrafficVectorIterator currTraffic;
double heading, double speed, double alt);
-
+ void parseCache();
+
+ void loadSegments();
public:
FGGroundNetwork();
~FGGroundNetwork();
-
- void addNode (const FGTaxiNode& node);
- void addNodes (FGParkingVec *parkings);
- void addSegment(const FGTaxiSegment& seg);
- void setVersion (int v) { version = v;};
+ void setVersion (int v) { version = v;};
int getVersion() { return version; };
- void init();
+ void init(FGAirport* pr);
bool exists() {
return hasNetwork;
};
towerController = twrCtrlr;
};
- int findNearestNode(double lat, double lon);
- int findNearestNode(const SGGeod& aGeod);
- int findNearestNodeOnRunway(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;
- };
+ int findNearestNode(const SGGeod& aGeod) const;
+ int findNearestNodeOnRunway(const SGGeod& aGeod, FGRunway* aRunway = NULL) const;
+
+ FGTaxiNode *findNode(PositionedID idx) const;
+ FGTaxiSegment *findSegment(unsigned idx) const;
+
+ /**
+ * Find the taxiway segment joining two (ground-net) nodes. Returns
+ * NULL if no such segment exists.
+ * It is permitted to pass 0 for the 'to' ID, indicating that any
+ * segment originating at 'from' is acceptable.
+ */
+ FGTaxiSegment* findSegment(PositionedID from, PositionedID to) const;
+
+ FGTaxiRoute findShortestRoute(PositionedID start, PositionedID end, bool fullSearch=true);
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
double lat, double lon, double hdg, double spd, double alt,