]> git.mxchange.org Git - flightgear.git/blob - src/Airports/gnnode.hxx
initialize release_keys array
[flightgear.git] / src / Airports / gnnode.hxx
1 // This program is free software; you can redistribute it and/or
2 // modify it under the terms of the GNU General Public License as
3 // published by the Free Software Foundation; either version 2 of the
4 // License, or (at your option) any later version.
5 //
6 // This program is distributed in the hope that it will be useful, but
7 // WITHOUT ANY WARRANTY; without even the implied warranty of
8 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
9 // General Public License for more details.
10 //
11 // You should have received a copy of the GNU General Public License
12 // along with this program; if not, write to the Free Software
13 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
14 //
15
16 #ifndef _GN_NODE_HXX_
17 #define _GN_NODE_HXX_
18
19 #include <vector>
20 #include <string>
21 #include <simgear/compiler.h>
22
23 SG_USING_STD(string);
24 SG_USING_STD(vector);
25
26 class FGTaxiSegment;
27 typedef vector<FGTaxiSegment*>  FGTaxiSegmentVector;
28 typedef FGTaxiSegmentVector::iterator FGTaxiSegmentVectorIterator;
29
30 bool sortByHeadingDiff(FGTaxiSegment *a, FGTaxiSegment *b);
31 bool sortByLength     (FGTaxiSegment *a, FGTaxiSegment *b);
32 double processPosition(const string& pos);
33
34 class FGTaxiNode 
35 {
36 private:
37   double lat;
38   double lon;
39   int index;
40
41   bool isOnRunway;
42   int  holdType;
43   FGTaxiSegmentVector next; // a vector of pointers to all the segments leaving from this node
44
45   // used in way finding
46   double pathScore;
47   FGTaxiNode* previousNode;
48   FGTaxiSegment* previousSeg;
49
50 public:
51   FGTaxiNode() :
52       lat (0.0),
53       lon (0.0),
54       index(0),
55       isOnRunway(false),
56       holdType(0),
57       pathScore(0),
58       previousNode(0),
59       previousSeg(0)
60 {
61 };
62
63   FGTaxiNode(const FGTaxiNode &other) :
64       lat(other.lat),
65       lon(other.lon),
66       index(other.index),
67       isOnRunway(other.isOnRunway),
68       holdType(other.holdType),
69       next(other.next),
70       pathScore(other.pathScore),
71       previousNode(other.previousNode),
72       previousSeg(other.previousSeg)
73 {
74 };
75
76 FGTaxiNode &operator =(const FGTaxiNode &other)
77 {
78    lat          = other.lat;
79    lon          = other.lon;
80    index        = other.index;
81    isOnRunway   = other.isOnRunway;
82    holdType     = other.holdType;
83    next         = other.next;
84    pathScore    = other.pathScore;
85    previousNode = other.previousNode;
86    previousSeg  = other.previousSeg;
87    return *this;
88 };
89
90   void setIndex(int idx)                  { index = idx;                 };
91   void setLatitude (double val)           { lat = val;                   };
92   void setLongitude(double val)           { lon = val;                   };
93   void setLatitude (const string& val)    { lat = processPosition(val);  };
94   void setLongitude(const string& val)    { lon = processPosition(val);  };
95   void addSegment(FGTaxiSegment *segment) { next.push_back(segment);     };
96   void setHoldPointType(int val)          { holdType = val;              };
97   void setOnRunway(bool val)              { isOnRunway = val;            };
98
99   void setPathScore   (double val)         { pathScore    = val; };
100   void setPreviousNode(FGTaxiNode *val)    { previousNode = val; };
101   void setPreviousSeg (FGTaxiSegment *val) { previousSeg  = val; };
102
103   FGTaxiNode    *getPreviousNode()    { return previousNode; };
104   FGTaxiSegment *getPreviousSegment() { return previousSeg;  };
105
106   double getPathScore() { return pathScore; };
107   double getLatitude() { return lat;};
108   double getLongitude(){ return lon;};
109
110   int getIndex() { return index; };
111   int getHoldPointType() { return holdType; };
112   bool getIsOnRunway() { return isOnRunway; };
113
114   FGTaxiNode *getAddress() { return this;};
115   FGTaxiSegmentVectorIterator getBeginRoute() { return next.begin(); };
116   FGTaxiSegmentVectorIterator getEndRoute()   { return next.end();   }; 
117   bool operator<(const FGTaxiNode &other) const { return index < other.index; };
118
119   void sortEndSegments(bool);
120
121 };
122
123 typedef vector<FGTaxiNode*> FGTaxiNodeVector;
124 typedef FGTaxiNodeVector::iterator FGTaxiNodeVectorIterator;
125
126 #endif